有没有办法在谷歌地图中显示一个国家?应该只有一个国家,不包括其他国家的部分 [英] Is there a way to display a single country in Google map? It should be only one country, not parts from other countries included

查看:45
本文介绍了有没有办法在谷歌地图中显示一个国家?应该只有一个国家,不包括其他国家的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要在谷歌地图中显示一个国家.我只需要显示一个国家,其他国家的部分不应该在那里..例如,如果我想显示英国,它应该只显示英国和周围的海域,其他国家的部分不应该可见.

是否有 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" }
    ]
    }
  ]
};

这篇关于有没有办法在谷歌地图中显示一个国家?应该只有一个国家,不包括其他国家的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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