Web components for embedding and interacting with Google Maps.
- Display an interactive Google Map (
google-map) - Add draggable and customizable markers (
google-map-marker) - Add markers based on Google's Advanced Markers (
google-map-advanced-marker) - Draw polygons, polylines, and rectangles on the map (
google-map-poly) - Define geographic points for use with poly elements (
google-map-point) - Support for marker clustering
- Touch-and-hold gesture to simulate right-click on mobile
npm install @flowingcode/google-map
Then import the components you need like:
import '@flowingcode/google-map/google-map.js';
import '@flowingcode/google-map/google-map-marker.js';
import '@flowingcode/google-map/google-map-advanced-marker.js';<google-map api-key="YOUR_API_KEY" fit-to-markers>
<google-map-marker latitude="37.78" longitude="-122.4" draggable="true"></google-map-marker>
</google-map>- git clone repository
- npm install
- npm start
The demo will open automatically at http://localhost:8000/demo/. A valid Google Maps API key is required — pass it as a query parameter:
http://localhost:8000/demo/?api-key=YOUR_API_KEY
For polys:
http://localhost:8000/demo/polys.html?api-key=YOUR_API_KEY
For advanced markers:
http://localhost:8000/demo/advanced-markers.html?api-key=YOUR_API_KEY
http://localhost:8000/demo/advanced-markers-clustering.html?api-key=YOUR_API_KEY
For markers clustering (optional map-id and custom-renderer=1 query parameters):
http://localhost:8000/demo/markers-clustering.html?api-key=YOUR_API_KEY
See here
The issues for this add-on are tracked on its github.com page. All bug reports and feature requests are appreciated.
Contributions are welcome. There are two primary ways you can contribute: by reporting issues or by submitting code changes through pull requests. To ensure a smooth and effective process for everyone, please follow the guidelines below for the type of contribution you are making.
Creating an issue is a highly valuable contribution. If you've found a bug or have an idea for a new feature, this is the place to start.
- Before creating an issue, please check the existing issues to see if your topic is already being discussed.
- If not, create a new issue. Try to keep the scope minimal but as detailed as possible.
A Note on Bug Reports
While all details are important, a minimal, reproducible example is the most critical part of your report. It's essential because it removes ambiguity and allows our team to observe the problem firsthand, exactly as you are experiencing it.
As a first step, please refer to our Development Conventions page to find information about Conventional Commits & Code Style requirements.
Then, follow these steps for creating a contribution:
- Fork this project.
- Create an issue to this project about the contribution (bug or feature) if there is no such issue about it already. Try to keep the scope minimal.
- Develop and test the fix or functionality carefully. Only include minimum amount of code needed to fix the issue.
- For commit message, use Conventional Commits to describe your change.
- Send a pull request for the original project.
- Comment on the original issue that you have implemented a fix for it.
<google-map api-key="YOUR_API_KEY" latitude="37.78" longitude="-122.4" zoom="12">
<google-map-marker latitude="37.78" longitude="-122.4" title="My location"></google-map-marker>
</google-map>You need a valid Google Maps API key to use these components.
google.maps.Marker, used by google-map-marker, is deprecated in favor of AdvancedMarkerElement. Use google-map-advanced-marker to use Advanced Markers instead. Both elements can be used on the same map.
Advanced Markers require a Map ID (DEMO_MAP_ID can be used for testing). Note that when a Map ID is set, the styles property of google-map is not applied: the map is styled from the Google Cloud console instead.
<google-map api-key="YOUR_API_KEY" map-id="YOUR_MAP_ID" fit-to-markers>
<google-map-advanced-marker slot="markers" latitude="37.78" longitude="-122.4" title="My location"
pin-background="#FBBC04" draggable="true"></google-map-advanced-marker>
</google-map>