
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
@amap/amap-jsapi-loader
Advanced tools
amap-jsapi-loader 是高德开放平台官网提供的地图 JSAPI 的加载器,可帮助开发者快速定位、有效避免加载引用地图 JSAPI 各种错误用法。
该加载器具有以下特性:
AMapLoader.load({
"key": "", // 申请好的Web端开发者Key,首次调用 load 时必填
"version": "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
"plugins": [] // 需要使用的的插件列表,如比例尺'AMap.Scale'等
"AMapUI": { // 是否加载 AMapUI,缺省不加载
"version": '1.1', // AMapUI 缺省 1.1
"plugins":[], // 需要加载的 AMapUI ui插件
},
"Loca":{ // 是否加载 Loca, 缺省不加载
"version": '1.3.2' // Loca 版本,缺省 1.3.2
},
}).then(()=>{
window.AMap.xx;
window.AMapUI.xx;
window.Loca.xx
});
AMapUI 用法和官网有一点点区别。通过 AMapUI.xx 来获取组件
AMapLoader.load({
key: '',//首次load必填
version: '2.0',
AMapUI: {
version: '1.1',
plugins: ['overlay/SimpleMarker'],
}
}).then((AMap) => {
map = new AMap.Map('container');
// !!! 通过 AMap.SimpleMarker 获取组件
new AMapUI.SimpleMarker({
//前景文字
iconLabel: 'A',
//图标主题
iconTheme: 'default',
//背景图标样式
iconStyle: 'red',
map: map,
position: map.getCenter()
});
}).catch((e) => {
console.error(e);
});
尚未发布在线Loader,可将 dist/index.js 复制到项目下
<script src="../dist/index.js"></script>
<script>
AMapLoader.load({
key:'',//首次load必填
version:'2.0',
plugins:['AMap.Scale']
}).then((AMap)=>{
map = new AMap.Map('container');
map.addControl(new AMap.Scale())
}).catch((e)=>{
console.error(e);
});
</script>
安装
tnpm i @alife/amap-jsapi-loader --save-dev
使用
import AMapLoader from '@alife/amap-jsapi-loader';
AMapLoader.load().then((AMap)=>{
map = new AMap.Map('container');
}).catch(e=>{
console.log(e);
})
FAQs
高德官网提供的地图JSAPI加载器,可以避免多种异步加载API的错误用法
The npm package @amap/amap-jsapi-loader receives a total of 33,758 weekly downloads. As such, @amap/amap-jsapi-loader popularity was classified as popular.
We found that @amap/amap-jsapi-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.