自定义谷歌地图平铺服务器网址

Meh*_*avi 5 google-maps

我使用此网址从谷歌服务器获取地图图块

http://mts0.google.com/vt/lyrs=m@189000000&hl=en&src=app&x=41189&y=25680&z=16&s=Gal
Run Code Online (Sandbox Code Playgroud)

我想知道是否有办法自定义这个网址,通过添加一些额外的参数来获取瓷砖,而不需要任何街道标签或额外的信息或叠加.就像在地图api v3中自定义地图一样.任何建议都会受到欢迎.

Dr.*_*lle 14

我没有找到有关它的文档,但有一个参数 apistyle

要隐藏街道标签的值(必须是urlencoded)

s.t:3|s.e:l|p.v:off
Run Code Online (Sandbox Code Playgroud)

由于缺少文档,以下是猜测:

  • s.t定义了特征类型,值3似乎是 道路
  • s.e 定义元素,例如labels或geometry
  • p定义风格,v代表v可行性,价值off应该清晰.结果:

    https://mts0.google.com/vt/lyrs=m@289000001&hl=en&src=app&x=41189&y=25680&z=16&s=Gal&apistyle=s.t%3A3|s.e%3Al|p.v%3Aoff
    
    Run Code Online (Sandbox Code Playgroud)

您必须使用参数来获得所需的结果.在过去,有可能获得样式,例如在使用样式化地图向导时使用开发人员工具检查tile-URL ,但是他们已经修改了javascript-API使用的tile-URLs,现在参数将是以某种方式编码.

参数和值列表:

FeatureTypes:s.t

  • 所有 0
  • 行政的 1
  • administrative.country 17
  • administrative.land_parcel 21
  • administrative.locality 19
  • administrative.neighborhood 20
  • administrative.province 18
  • 景观 5
  • landscape.man_made 81
  • landscape.natural 82
  • POI 2
  • poi.attraction 37
  • poi.business 33
  • poi.government 34
  • poi.medical 36
  • poi.park 40
  • poi.place_of_worship 38
  • poi.school 35
  • poi.sports_complex 39
  • 3
  • road.arterial 50
  • road.highway 49
  • road.local 51
  • 过境 4
  • transit.line 65
  • transit.station 66
  • 6

的ElementType: s.e

  • 几何 g
  • geometry.fill g.f
  • geometry.stroke g.s
  • 标签 l
  • labels.icon l.i
  • labels.text l.t
  • labels.text.fill l.t.f
  • labels.text.stroke l.t.s

斯泰勒:

  • 颜色 p.c
    RGBA十六进制值#aarrggbb
  • 伽玛 p.g
    漂浮在0.01和之间10
  • 色调 p.h
    RGB十六进制值#rrggbb
  • invert_lightness p.il
    true/false
  • 轻盈 p.l
    漂浮在-100和之间100
  • 之间的饱和 p.s
    浮动-100100
  • 能见度 p.v
    on/ simplified/off
  • p.w
    重整数> =0

  • 它对我来说很好用,但是你知道选项组合的语法是什么吗?例如,我想在同一个 url 中拥有: apistyle=st%3A0|se%3Al|pv%3Aoff AND apistyle=st%3A6|se%3Ag|pc%3A%23ffb3d1ff。 (2认同)
  • @Kalitine 你用“,”字符分隔每组 (2认同)

Man*_*tto 5

Molle 博士发现的实施:

function getEncodedStyles(styles){
var ret = "";
var styleparse_types = {"all":"0","administrative":"1","administrative.country":"17","administrative.land_parcel":"21","administrative.locality":"19","administrative.neighborhood":"20","administrative.province":"18","landscape":"5","landscape.man_made":"81","landscape.natural":"82","poi":"2","poi.attraction":"37","poi.business":"33","poi.government":"34","poi.medical":"36","poi.park":"40","poi.place_of_worship":"38","poi.school":"35","poi.sports_complex":"39","road":"3","road.arterial":"50","road.highway":"49","road.local":"51","transit":"4","transit.line":"65","transit.station":"66","water":"6"};
var styleparse_elements = {"all":"a","geometry":"g","geometry.fill":"g.f","geometry.stroke":"g.s","labels":"l","labels.icon":"l.i","labels.text":"l.t","labels.text.fill":"l.t.f","labels.text.stroke":"l.t.s"};
var styleparse_stylers = {"color":"p.c","gamma":"p.g","hue":"p.h","invert_lightness":"p.il","lightness":"p.l","saturation":"p.s","visibility":"p.v","weight":"p.w"};
for(i=0;i<styles.length;i++){
    if(styles[i].featureType){
        ret += "s.t:"+styleparse_types[styles[i].featureType]+"|";
    }
    if(styles[i].elementType){
        if(!styleparse_elements[styles[i].elementType])
            console.log("style element transcription unkown:"+styles[i].elementType);
        ret += "s.e:"+styleparse_elements[styles[i].elementType]+"|";
    }
    if(styles[i].stylers){
        for(u=0;u<styles[i].stylers.length;u++){
            var keys = [];
            var cstyler = styles[i].stylers[u]
            for(var k in cstyler){
                if(k=="color"){
                    if(cstyler[k].length==7)
                        cstyler[k] = "#ff"+cstyler[k].slice(1);
                    else if(cstyler[k].length!=9)
                        console.log("malformed color:"+cstyler[k]);
                }
                ret += styleparse_stylers[k]+":"+cstyler[k]+"|";
            }
        }
    }
    ret = ret.slice(0,ret.length-1);
    ret += ","
}
return encodeURIComponent(ret.slice(0,ret.length-1));
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,输入是一个常规的谷歌地图样式数组 - 一个很好的向导是Snazzy Maps

不管怎样,感谢 Molle 博士节省了时间!