@posterno/google-maps-html-marker
Version:
A tiny javascript helper library to create html markers with Google maps.
47 lines (32 loc) • 1.13 kB
Markdown
with Google maps.
```shell
npm install @posterno/google-maps-html-marker
```
or
```shell
yarn add @posterno/google-maps-html-marker
```
Load the helper library in your javascript file:
```js
const createHTMLMapMarker = require( 'google-maps-html-marker' );
const latLng = new google.maps.LatLng(16.7666, -3.0026);
const mapOptions = {
zoom: 11,
center: latLng
};
const map = new google.maps.Map(document.getElementById("map"), mapOptions);
let marker = createHTMLMapMarker({
latlng: latLng,
map: map,
html: `<img id="parrot" src="https://cultofthepartyparrot.com/parrots/hd/parrot.gif">`
});
marker.addListener("click", () => {
alert("Partyin Partyin Yeah!");
});
```
This library was originally created by Dan Ward and published as [a tutorial here](https://levelup.gitconnected.com/how-to-create-custom-html-markers-on-google-maps-9ff21be90e4b).
I've simply converted it to an ES5 javascript module and published it on the npmjs registry so that it's easier to re-use for my projects.
A tiny javascript helper library to create html markers