Importing myMaps data into Google Maps
I am developing a web / mobile application that handles routes in order to deliver added value to existing mapping applications. I am wondering if there is a way to import data from google myMaps (points A, B, C, etc. and also routes ... or just the points are minimal). If so, how?
0
source to share
1 answer
One option is to export the KML from Google myMaps (either as a network link or directly) and then display that using the Google Maps v3 KmlLayer Javascript API
snippet of code:
var map;
function initialize() {
var map = new google.maps.Map(
document.getElementById("map_canvas"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var kmlLayer = new google.maps.KmlLayer({
url: "http://www.google.com/maps/d/kml?forcekml=1&mid=zNPjLbo835mE.k3TvWfqGG-AU",
map: map
});
google.maps.event.addListener(kmlLayer, 'status_changed', function() {
document.getElementById('status').innerHTML = kmlLayer.getStatus();
});
}
google.maps.event.addDomListener(window, "load", initialize);
function showLocation(locate) {
for (var i = 0; i < parseInt(locate.length); i++) {
var address = locate[i];
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
address: address
}, addAddressToMap);
}
}
var disp_title = '.$array1.';
var gj = 0;
function addAddressToMap(response) {
place = response.Placemark[0];
point = new google.maps.LatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
map.setCenter(point, 7);
var marker1 = createMarker(point, disp_title[gj], response.name);
map.addOverlay(marker1);
gj++;
}
function createMarker(point) {
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: name
});
google.maps.event.addListener(marker, "click", function() {
infoWindow.setContent(html);
infoWindow.open(html + "<br />Location: " + place_name);
});
}
html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="status"></div>
<div id="map_canvas" style="border: 2px solid #3872ac;"></div>
0
source to share