SHDY
SHDY

Reputation: 33

Is it possible to overlay two google maps?

My goal is to make it possible to compare two metro systems in/with google maps, but I'm not sure how. Ideally it would be great if it would be possible to overlay the two public transit systems as maps.

So far (code below) I turned off everything except the transit lines and the stations. Not sure if the grey "background" would be an issue with overlaying it - and if it's even possible to overlay two google maps. Can't find anything on the maps api help pages.

If it is not possible, - what else would you recommend?

Another thing I need to find out is if it's possible to color these transit lines into one color per map, but of that I guess I should open a new question?

Thanks a lot for your help, SHDY

var map;
      function initialize() {
        var mapOptions = {
          zoom: 11,
          center: new google.maps.LatLng(40.734077,-73.977699),  
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          styles: [
  {
    "featureType": "administrative",
    "stylers": [
      { "visibility": "off" }
    ]
  },{
    "featureType": "landscape",
    "stylers": [
      { "visibility": "off" }
    ]
  },{
    "featureType": "water",
    "stylers": [
      { "visibility": "off" }
    ]
  },{
    "featureType": "road",
    "stylers": [
      { "visibility": "off" }
    ]
  },{
    "featureType": "poi",
    "stylers": [
      { "visibility": "off" }
    ]
  },{
    "featureType": "transit",
    "elementType": "geometry",
    "stylers": [
      { "color": "#000d0c" },
      { "visibility": "off" }
    ]
  }
]
        };
        map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
        var transitLayer = new google.maps.TransitLayer();
        transitLayer.setMap(map);
      }

      google.maps.event.addDomListener(window, 'load', initialize);

Upvotes: 1

Views: 4733

Answers (1)

Kaitlin Duck Sherwood
Kaitlin Duck Sherwood

Reputation: 627

It is possible to overlay two (or more) maps; I have done so with two different custom tile layers. See http://maps.webfoot.com/demos/election2008/ for a map with up to three layers.

The hard part is figuring out how to overlay them such that people can see both. Maybe you make most of the pixels clear in one of them. Maybe you make the top layer transparent. Maybe you punch a window in the top layer so you can see the bottom layer underneath. You will have to figure out how you want to keep both layers visible.

Upvotes: 1

Related Questions