Modify marker icon, color or size
Hi,
Thanks for developing this library, very useful. I am just starting to use it and I am also a Django beginner. Could you give an example on how could I modify the marker icon / color / size.
For example, I am trying to modify the marker, but I get a 'non-readable image' icon.
class modelAdmin(LeafletAdminListMixin, LeafletGeoAdminMixin, admin.ModelAdmin):
....
def get_geojson_feature_icon_style(self, request, name, o, queryset):
return {
'iconUrl': '.static/piles/images/icon.png',
'iconSize': [32, 32],
'iconAnchor': [16, 32],
'popupAnchor': [0, -32],
}
Thanks!
Hi @saraivajp you wrote the proper code, but probably you didn't refer the iconUrl properly, using relative URL. Start the URL from the slash / to have a reference relative from the root of your domain, for example:
'/static/piles/images/icon.png'to refer tohttp://your.domain.name/static/piles/images/icon.png'/.static/piles/images/icon.png'to refer tohttp://your.domain.name/.static/piles/images/icon.png, etc.
BTW you can press Ctrl-Shift-I to see the browser console, select the Network tab and see, what URLs were success, and failed. You will find there the URL constructed from your reference by the browser.
See some learning matherials about relative URLs to understand details.