google maps api 3 - 仅显示特定大陆

时间:2013-05-20 20:21:08

标签: javascript google-maps google-maps-api-3

请协助。我用Google搜索并经历了堆栈溢出但无法在任何地方找到此信息。有没有办法只显示一个特定的大陆,在我的情况下非洲和谷歌地图中隐藏所有其他不需要的大陆。这些地图根本不应该显示。我发现了这篇文章 - > Can i hide land masses with Google Maps API

但没有具体的例子。

我正在使用Google Maps API 3。

目前我有:

<script type="text/javascript"
                src="https://maps.googleapis.com/maps/api/js?key=mykey&sensor=true">
        </script>
        <script type="text/javascript">
            function initialize() {

                //Implement map styling
                var styles = [
                    {
                        "stylers": [
                            {"visibility": "simplified"}
                        ]
                    }
                ];


                var styledMap = new google.maps.StyledMapType(styles, {name: "MyMap"});

                var mapOptions = {
                    center: new google.maps.LatLng(0.972198, 23.994141),
                    zoom: 3,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    panControl: false,
                    zoomControl: false,
                    streetViewControl: false,
                    mapTypeControl: false,
                    mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style'],
                    draggable: false,
                    scrollwheel: false,
                    panControl: false

                };


                var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

                //Load kml of africa
                var kmlMap = new google.maps.KmlLayer('http://myOverLay.kmz',
                        {
                            //suppressInfoWindows: false,
                            //map: map,
                            preserveViewport: true
                        });
                kmlMap.setMap(map);

                //map.mapTypes.set();

                //Associate the styled map with the MapTypeId and set it to display.
                map.mapTypes.set('map_style', styledMap);
                map.setMapTypeId('map_style');

            }


            google.maps.event.addDomListener(window, 'load', initialize);
        </script> 

2 个答案:

答案 0 :(得分:0)

一个选项:

  1. 覆盖整个世界,除了你选择的大陆上的一个洞。 example of concept (US state of Virginia)
  2. 限制缩放和边界以防止地图远离显示该大陆。 description of how to limit the viewable area

答案 1 :(得分:0)

似乎不可能。结束使用图像映射器