简体   繁体   English

是否可以叠加两张Google地图?

[英]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. 我的目标是使在Google地图中比较两个地铁系统成为可能,但我不确定如何。 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. 不知道灰色的“背景”是否会成为覆盖它的问题-甚至是否有可能覆盖两个Google地图。 Can't find anything on the maps api help pages. 在maps api帮助页面上找不到任何内容。

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 非常感谢您的帮助,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);

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. 有关最多包含三层的地图,请参见http://maps.webfoot.com/demos/election2008/

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. 您将必须弄清楚如何使两个图层均可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM