Skip to content

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

Open
bjoluc wants to merge 1 commit intohtmlburger:developmentfrom
bjoluc:feat/leaflet-map
Open

Map Field: Fall back to Leaflet.js when no Google API key is provided#1137
bjoluc wants to merge 1 commit intohtmlburger:developmentfrom
bjoluc:feat/leaflet-map

Conversation

@bjoluc
Copy link
Copy Markdown
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.

1 participant