问题描述
我只需要在Google地图上显示一个国家/地区。我只需要显示一个国家和其他国家的部分不应该在那里..例如,如果我想显示英国,它应该只显示英国和周围的海,没有其他国家的部分应该是可见的。
是否有Google API调用或其他方法?我无法找到一个方法,而不是重写缩放并覆盖它们可以在区域中导航的方法(滚动事件)。
有没有人知道一种方法来做到这一点? / p>如果您禁用所有地图元素,然后添加新图层(单个国家/地区),则只能看到一个国家/地区。这是一个jsfiddle
函数初始化(){
var mapOptions = {
zoom:5,
center:myLatlng,
mapTypeId:google。 maps.MapTypeId.ROADMAP,
backgroundColor:'#FFF',
disableDefaultUI:true,
draggable:false,
scaleControl:false,
scrollwheel:false,
样式:[
{
featureType:water,
elementType:geometry,
stylers:[
{可见性:关闭}
]
},{
featureType:风景,
风格:[
{visibility:关闭}
]
},{
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}
]
}
]
};
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" }
]
}
]
};
这篇关于有没有办法在谷歌地图上显示一个国家?它应该只有一个国家,而不是来自其他国家的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!