erdem / django-map-widgets

Highly customizable, intuitive, and user-friendly map widgets for GeoDjango applications.
MIT License
447 stars 119 forks source link

Add MapboxPointFieldWidget #126

Closed janbaykara closed 2 years ago

janbaykara commented 2 years ago

This PR adds MapPointFieldWidget. We've done a simple translation from the GooglePointFieldWidget for use in a small academic project.

I'd be happy to do some tidying up and so on so we can this merged in, but I don't anticipate having the capacity any time too soon to add the other widgets required to reach parity with the Google suite of widgets.

Screenshot 2021-11-01 at 16 46 47
janbaykara commented 2 years ago

Ended up reimplementing a lot of the javascript using https://github.com/hotwired/stimulus at https://github.com/commonknowledge/django-map-widgets/compare/mapbox..master so I probably won't do too much more work on this PR, but I hope it's useful for anyone who wants to take it further!

erdem commented 2 years ago

@janbaykara I am very glad to see your PR, the frontend side of the project needed to be updated but I couldn't spare time to do it.

However, I am on holiday at the moment I will review your changes in the following weeks.

Thanks!

erdem commented 2 years ago

@janbaykara Sorry for my super delayed response. I have tested your Mapbox widget, static files loaded fine but it seems you didn't add api-key parameter for JS source.

I have merged your changes to main branch but I haven't published the changes yet. Would be great if you can fix the API key issue with a new PR otherwise, I will fix it at some point.

Many thanks again your contribution.

Screenshot 2022-01-26 at 23 29 07

janbaykara commented 2 years ago

Oh, nice one! Glad that's working for you.

Here is the config I used to make it work:

MAP_WIDGETS = {
    "MapboxPointFieldWidget": (
        ("access_token", MAPBOX_API_PUBLIC_TOKEN),
    ),
    "MAPBOX_API_KEY": MAPBOX_API_PUBLIC_TOKEN
}
erdem commented 2 years ago

@janbaykara I have updated MapBox widget implementation since merge your PR to master.

it's all documented here; https://django-map-widgets.readthedocs.io/en/mapbox_widget_fixes/widgets/mapbox_point_field_map_widgets.html

Feel free to test or contribute to the new release.

erdem commented 2 years ago

https://github.com/erdem/django-map-widgets/pull/131

janbaykara commented 2 years ago

So glad to hear! Thank you for maintaining this package - I hope this encourages other substantial contributions!