Add Google “My Maps” Layer to Google Maps Javascript API

I want to put a Google Maps map on our website.

I know that custom markers can be added to a map with Javascript, but I’d rather use Google’s MyMaps service instead, because then my co-workers could edit the map without any programming knowledge.

You can add a custom My Map to websites with an embedded iframe. I’m using the Javascript API instead though, so that I can take advantage of the controls the API delivers (such as zoom through custom controls or changing the position on the map without touching the map itself).

Can I insert the map created and saved with My Maps as a layer in my JS API map?

You can use GGeoXml to add My Maps content to your API map.

In your My Map there’s a “View in Google Earth” link, use the URL of that link as your GGeoXml URL.

The link generates an indirect “network link” reference to the data, so the map on your page will reflect the latest changes made to the My Map.

The downside is that there’s a limit to how many markers you can place on one page of a My Map, and the “View in Google Earth” link only returns data for the current My Maps page.

Another strategy is to use GeometryControls in your own API map.

That involves a lot more coding effort on your side. It gives the same look and feel to your co-workers, so they still need no programming skills. The advantage is that it bypasses the My Maps limit to the number of markers that can be displayed at once.

Read More:   document.getElementById('btnid').disabled is not working in firefox and chrome

Apparently you can embed the My Map you created in your website by using the Link To This Page functionality as described here.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts