Hi, sorry for my English.
I need to show different layers in maps distributed by my project.
I followed the tutorial "Building an app with Google Maps & geolocation"
I managed to show on the map I want. The problem is that it only works on a single map.
I create Javascript "Google_MapsJS" whit this code for map called "googlemap_447":
[quote:]var map;var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var bounds = new google.maps.LatLngBounds();
function initialize() {
console.log('Initializing...');
Code: Select all
map = Apperyio("googlemap_447").gmap;
if (!map)
{
setDelay();
}
else
{
directionsDisplay = new google.maps.DirectionsRenderer();
}
}
function displayDirections(sourceAddress, destinationAddress, map) {
var request = {
origin: sourceAddress,
destination: destinationAddress,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
directionsDisplay.setMap(map);
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
alert("Directions query unsuccessful. Response status: " + status);
}
});
}
function setDelay()
{
setTimeout(initialize, 50);
}[/quote]This is events on click buttom:
The code works fine and if I change "googlemap_447" with "googlemap_450" in the code: the map "googlemap_450" working properly.
How can I write javascript code to run layers on different maps?