-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marker setIcon breaks if called before marker is added to the map #311
Comments
I guess this would be possible if we listened to the "featureparse" event of the GeoJSON layer. Then we could use the (undocumented?) setIcon method of Marker to change the icon for the marker. Does this sound feasible? |
After looking further it doesn't seem possible to change the icon via setIcon in the featureparse event as the marker hasn't been added to the map yet and errors get thrown. |
Yep, seems more logical to do this through |
Your last commit cause errors when removeLayer is called on marker. |
Thanks, fixed |
I'm getting an error when I try to use
The code I'm trying is:
Has this issue re-emerged or am I just not using it correctly?
|
What Leaflet version? How do you define |
I'm using I'm defining my icon using the following:
|
It should actually be just
|
@dsample, Did this fix your problem? |
Sorry for not replying sooner, yes, that fixed it, thanks. |
I have been having a similar issue and cannot get it to work. I have a geojson file describing points, polygons and lines. I want each point to have it's own marker icon, so in the feature properties I describe the icon url I want. I am working with this example: http://leaflet.cloudmade.com/examples/geojson.html and have modified lightRailStop to be
and the leafletembed code to
I get the same error as above, What am I doing wrong? :S I am using Leaflet 0.3.1 stable (February 14, 2012) |
While working on the GeoJSON examples page I was wondering if it would be possible to pass more than just the LatLng to the pointToLayer method? This way you could look at the GeoJSON properties and style your marker accordingly, like you can do now with LineString and Polygon. The way it is now (I think) your pointToLayer method can only return the same object (Marker, CircleMarker, etc) without regards to anything in the GeoJSON properties.
I might be wrong on all of this though?
The text was updated successfully, but these errors were encountered: