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

Map Field: Fall back to Leaflet.js when no Google API key is provided #1137

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

bjoluc
Copy link
Contributor

@bjoluc bjoluc commented Dec 19, 2022

I finally found some time to contribute an implementation for #613 🎉 Instead of adding an explicit set_provider method to the Map_Field class, I ended up implementing the free mapping service as a fallback when no Google API key is provided, so the map field works out of the box for new users without an API key.

The proposed implementation is backwards compatible and uses the wonderful Leaflet.js, as well as OpenStreetMap's Nominatim service for geocoding. According to my manual tests, Google Maps and Leaflet.js are interoperable with respect to positions and zoom levels. Hence, users can easily switch implementations by setting or removing the API key returned by the carbon_fields_map_field_api_key filter.

Here's a composer.json snippet to quickly try out the PR:

  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/bjoluc/carbon-fields.git",
      "branch": "feat/leaflet-map-build"
    }
  ],
  "require": {
    "htmlburger/carbon-fields": "dev-feat/leaflet-map-build"
  },

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

Successfully merging this pull request may close these issues.

None yet

1 participant