百度地图 osm地图 leaflet echarts webapck的组合使用时的踩坑记录

栏目: 数据库 · 发布时间: 5年前

内容简介:创建 script标签进行加载使用:需要

webpack+百度地图

创建 script标签进行加载

export function MP(ak){ 
    return new Promise(function (resolve, reject){   
        window.onload = function () {     
          resolve(BMap)   
        }   
        var script = document.createElement("script");    
        script.type = "text/javascript";   
        script.src = "http://api.map.baidu.com/api?v=2.0&ak="+ak+"&callback=init";   
        script.onerror = reject;   
        document.head.appendChild(script); 
    });
 }

使用:

import {MP} from './map.js'; 
MP("your ak").then(BMap => {
    // do something
})

webpack+百度地图+echart

需要

1 百度地图

2 echart

3 bmap.min.js 添加扩展,用于让百度地图支持echart https://github.com/apache/inc...

webpack+osm地图+leaflet

可能会遇见两个问题:

1 地图图片错位 忘记加载leaflet.css

2 webpack 中使用leaflet 的一个主要问题是默认图标的加载问题,详见

https://segmentfault.com/q/10...

另外也可以考虑使用动态创建<script>标签的方法,类似百度地图加载

webpack+百度地图+leaflet

因为leaflet本身支持的是WGS84的坐标系 ,而百度地图在中国使用的是百度坐标系,所以如果要在百度地图中使用leaflet的话,一是需要绘图数据变更为百度地图的BD09坐标系,二是需要对leaflet添加扩展,使其在进行经纬度坐标转化时使用百度地图的映射系统

解决方案: http://tiven.wang/articles/us...

以上问题的代码示例 https://gitlab.com/dahou/maps


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Art of Computer Programming, Volumes 1-3 Boxed Set

The Art of Computer Programming, Volumes 1-3 Boxed Set

Donald E. Knuth / Addison-Wesley Professional / 1998-10-15 / USD 199.99

This multivolume work is widely recognized as the definitive description of classical computer science. The first three volumes have for decades been an invaluable resource in programming theory and p......一起来看看 《The Art of Computer Programming, Volumes 1-3 Boxed Set》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器