地图技术选型


image.png
image.png
image.png

一、地图效果与技术栈对比

效果 \ 技术栈leafletmapbox(Mapbox GL JS
三方地图支持高德(免费)
OSM(免费)
mapbox(Static Images API
mapbox
卫星图高德卫星(免费)
mapbox卫星(Static Images API
mapbox卫星
点聚合leaflet插件:Leaflet.markercluster(免费)layer:clusters
标注、折线、自定义图标leaflet组件(免费)marker
地址解析/逆地址解析leaflet插件:Leaflet GeoSearch
①OpenStreetMap Nominatim
(免费,国内无法访问)
Mapbox Geocoding API
Mapbox Geocoding API
mapbox-gl-geocoder
(插件)
地图全屏leaflet插件:leaflet.fullscreen(免费)FullscreenControl
国际化图层mapbox-gl-language
3D效果不支持支持:projection: ‘globe’

二、Mapbox收费情况

Mapbox收费情况Monthly requestsCost per 1,000
Static Images APIUp to 50,000Free
50,001 - 500,000$1.00
500,001 - 1,000,000$0.80
1,000,001+$0.60
Mapbox GL JSUp to 50,000Free
50,001 – 100,000$5.00
100,001 – 200,000$4.00
200,001+$3.00
Mapbox Geocoding APIUp to 100,000Free
100,001 - 500,000$0.75
500,001 - 1,000,000$0.60
1,000,001+$0.45

三、leaflet集成

①瓦片服务器

const mapboxLayer = L.tileLayer('https://api.mapbox.com/styles/v1/{username}/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
  maxZoom: 19,
  username: 'mapbox',
  id: 'streets-v12',
  accessToken: mapboxAccessToken,
  attribution: '© mapbox',
});
const mapboxSatelliteLayer = L.tileLayer('https://api.mapbox.com/styles/v1/{username}/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
  maxZoom: 19,
  username: 'mapbox',
  id: 'satellite-streets-v12',
  accessToken: mapboxAccessToken,
  attribution: '© mapbox',
});
const osmLayer = L.tileLayer("https://tile.openstreetmap.de/{z}/{x}/{y}.png", {
  attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
});
const osmLayer = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
  attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
});
const aMapLayer = L.tileLayer('http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}', {
  subdomains: ['1', '2', '3', '4'],
  minZoom: 1, // 最小放缩级别
  maxZoom: 19, // 最大放缩级别
});
const aMapSatelliteLayer = L.tileLayer('http://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}', {
  subdomains: ['1', '2', '3', '4'],
  minZoom: 1,
  maxZoom: 19,
});

②添加图层控件到leaflet

//基础图层
const baseLayers = {};
baseLayers['mapBox'] = mapboxLayer;
baseLayers['mapBox卫星'] = mapboxSatelliteLayer;
baseLayers['OSM'] = osmLayer.addTo(map); //默认osm
baseLayers['高德'] = aMapLayer;
baseLayers['高德卫星'] = aMapSatelliteLayer;

//添加图层控件到地图上
L.control.layers(baseLayers, null, {
  collapsed: false   //禁止鼠标滚轮缩放
}).addTo(map);
  • 29
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

李晨豪 Lch

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值