问题描述
我只需要在谷歌地图中显示一个国家.我只需要显示一个国家,其他国家的部分不应该在那里..例如,如果我想显示英国,它应该只显示英国和周围的海域,其他国家的部分不应该可见.
是否有 Google API 调用或任何其他方法?除了覆盖缩放和覆盖它们可以在区域上导航的方法(滚动事件)之外,我找不到其他方法.
有人知道这样做的方法吗?
如果禁用所有地图元素,然后添加新图层(单个国家/地区),则只有一个国家/地区可见.这是一个 jsfiddle
I need to display only a single country in google map. I need to display only one country and the parts of other countries should not be there.. for example if I want to display U.K. it should display only UK and sea around, no parts from other countries should be visible.
Is there a Google API call or any other method? I couldn't find a method than overriding zoom and overriding the methods they can navigate over the region (scrolling events).
Does anyone know a method to do this?
If you disable all map elements and then a add new layer (a single country), then only one country is visible. Here is a jsfiddle https://jsfiddle.net/gvvy5vxz/2/
function initialize() {
var mapOptions = {
zoom: 5,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
backgroundColor: '#FFF',
disableDefaultUI: true,
draggable: false,
scaleControl: false,
scrollwheel: false,
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" }
]
}
]
};
这篇关于有没有办法在谷歌地图中显示一个国家?应该只有一个国家,不包括其他国家的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!