在Google地图上仅显示美国国家/地区

时间:2017-06-15 05:56:27

标签: javascript google-maps

参考这个问题中Mika的答案;

Is there a way to display a single country in Google map? It should be only one country, not parts from other countries included 1

有没有办法可以在地图上只启用美国国家/地区点击,拖动,滚动?

我一直在尝试这样做。但是它显示了一个没有错误的空白图像,如下所示:

Blank Map

以下是我从上述答案中修改过的代码。

  var myLatlng = new google.maps.LatLng(41.850033, -87.6500523);

            var myOptions = {
                //zoom: 3,
                center: myLatlng,
                //mapTypeId: google.maps.MapTypeId.ROADMAP,
                zoom: 5,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP,

                styles: [
                    {
                        "featureType": "water",
                        "elementType": "geometry",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "landscape",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "road",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "administrative",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "poi",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "administrative",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "elementType": "labels",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }
                ]

            };

  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

我错过了什么?任何帮助将受到高度赞赏。

0 个答案:

没有答案