谷歌地图api 3 - 只显示特定的大陆 [英] google maps api 3 - show specific continent only

查看:392
本文介绍了谷歌地图api 3 - 只显示特定的大陆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请协助。我搜索并经历了堆栈溢出,但无法在任何地方找到这些信息。有没有办法只显示一个特定的大陆,在我的情况下是非洲,并在谷歌地图中隐藏所有其他不需要的大陆。这些地图不应该显示。我遇到过这篇文章 - > 我可以用Google隐藏大陆吗? 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>
函数initialize(){

//实现地图样式
var styles = [
{
stylers:[
{可见性:简化}
]
}
];


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,
滚动:false,
panControl:false

};


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

//载入非洲的kml
var kmlMap = new google.maps.KmlLayer('http://myOverLay.kmz',
{
// suppressInfoWindows :false,
// map:map,
preserveViewport:true
});
kmlMap.setMap(map);

//map.mapTypes.set();

//将样式化地图与MapTypeId关联并将其设置为显示。
map.mapTypes.set('map_style',styledMap);
map.setMapTypeId('map_style');



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


解决方案

似乎不可能。结束使用图像mapster


Please assist. Ive googled and gone through stack overflow but am unable to find this information anywhere. Is there a way to show only a specific continent, in my case Africa and hide all other unwanted continents in google maps. These maps shouldn't show at all. I came across this article -> Can i hide land masses with Google Maps API

But there is no specific example.

I am using Google Maps API 3.

Currently I have:

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

解决方案

Doesnt seem possible. Ended up using image mapster

这篇关于谷歌地图api 3 - 只显示特定的大陆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆