Skip to content
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

Modify marker icon, color or size #9

Open
saraivajp opened this issue Dec 14, 2023 · 1 comment
Open

Modify marker icon, color or size #9

saraivajp opened this issue Dec 14, 2023 · 1 comment

Comments

@saraivajp
Copy link

saraivajp commented Dec 14, 2023

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!

@nnseva
Copy link
Owner

nnseva commented Dec 15, 2023

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 to http://your.domain.name/static/piles/images/icon.png
  • '/.static/piles/images/icon.png' to refer to http://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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants