Page 1 of 1

(Google Maps API) show differents layers in various maps in the same proyect

Posted: Thu Jul 30, 2015 10:43 pm
by Luis Miguel Gutierrez Carril

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.

Image

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:
Image

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?


(Google Maps API) show differents layers in various maps in the same proyect

Posted: Fri Jul 31, 2015 12:24 pm
by Alena Prykhodko

Hello,

Do you mean both maps should work simultaneously?


(Google Maps API) show differents layers in various maps in the same proyect

Posted: Fri Jul 31, 2015 1:33 pm
by Luis Miguel Gutierrez Carril

Yes. I need six maps should work simultaneously in the same page to display an exclusive layer in each of the maps..

I can show a map using event action "visible - true" property and the other five maps run property "visible - false"


(Google Maps API) show differents layers in various maps in the same proyect

Posted: Fri Jul 31, 2015 10:29 pm
by Luis Miguel Gutierrez Carril

I got it!!!!

It has been easy.

Just javascript clone for each map renaming the comand function initialize2() and then event run javascript event initialize2();

map 1 function initialize()
map 2 function initialize2()
map 3 function initialize3()
....... on for each map you need

Very thanks!