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

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

var map;var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var bounds = new google.maps.LatLngBounds();
function initialize() {
    map = Apperyio("googlemap_447").gmap;
    if (!map)
        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) {
      if (status == google.maps.DirectionsStatus.OK) {
      } else {
        alert("Directions query unsuccessful. Response status: " + status);
function setDelay()
    setTimeout(initialize, 50);
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?
1 person has
this question