我对 Leaflet Map API 非常感兴趣.
但是,我需要能够使用 Google Satellite Layer。我无法找到有关如何将 Google 卫星图层添加到 Leaflet 的示例。我知道我仍然需要加载 Google Maps API 才能执行此操作(OpenLayers 有一个示例)。
最佳答案
您不需要插件或 Google API,您可以将其添加为 XYZ 图 block 图层。
街道
googleStreets = L.tileLayer('http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',{
maxZoom: 20,
subdomains:['mt0','mt1','mt2','mt3']
});
混合:
googleHybrid = L.tileLayer('http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}',{
maxZoom: 20,
subdomains:['mt0','mt1','mt2','mt3']
});
卫星:
googleSat = L.tileLayer('http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',{
maxZoom: 20,
subdomains:['mt0','mt1','mt2','mt3']
});
地形
googleTerrain = L.tileLayer('http://{s}.google.com/vt/lyrs=p&x={x}&y={y}&z={z}',{
maxZoom: 20,
subdomains:['mt0','mt1','mt2','mt3']
});
请注意 URL 中“lyrs”参数的差异:
Hybrid: s,h;
Satellite: s;
Streets: m;
Terrain: p;
关于google-maps-api-3 - 带有 Google 卫星图层的 Leaflet Map API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9394190/