web端正常,但小程序无法加载
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
<!-- Open Graph data -->
<!-- <meta property="og:title" content="Title Here" /> -->
<!-- <meta property="og:url" content="http://www.example.com/" /> -->
<!-- <meta property="og:image" content="http://example.com/image.jpg" /> -->
<!-- <meta property="og:description" content="Description Here" /> -->
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<script src="https://webapi.amap.com/maps?v=2.0&key=94801c389f3d7c73f36a2981f804190e&plugin=AMap.PolygonEditor"></script>
<script src="https://a.amap.com/jsapi_demos/static/demo-center/js/demoutils.js"></script>
</head>
<body>
<noscript>
<strong>Please enable JavaScript to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
地图
<template>
<view>
<view id="container" class="container"></view>
</view>
</template>
<script>
export default {
data() {
return {
map: {}
}
},
methods: {
init: function() {
this.map = new AMap.Map("container", {
center: [116.471354, 39.994257],
zoom: 16.8
});
var path1 = [
[116.475334, 39.997534],
[116.476627, 39.998315],
[116.478603, 39.99879],
[116.478529, 40.000296],
[116.475082, 40.000151],
[116.473421, 39.998717]
]
var path2 = [
[116.474595, 40.001321],
[116.473526, 39.999865],
[116.476284, 40.000917]
]
var polygon1 = new AMap.Polygon({
path: path1
})
var polygon2 = new AMap.Polygon({
path: path2
})
this.map.add([polygon1, polygon2]);
this.map.setFitView();
var polyEditor = new AMap.PolygonEditor(this.map);
polyEditor.addAdsorbPolygons([polygon1, polygon2]);
polyEditor.on('add', function(data) {
console.log(data);
var polygon = data.target;
polyEditor.addAdsorbPolygons(polygon);
polygon.on('dblclick', () => {
polyEditor.setTarget(polygon);
polyEditor.open();
})
})
polygon1.on('dblclick', () => {
polyEditor.setTarget(polygon1);
polyEditor.open();
})
polygon2.on('dblclick', () => {
polyEditor.setTarget(polygon2);
polyEditor.open();
})
function createPolygon() {
polyEditor.close();
polyEditor.setTarget();
polyEditor.open();
}
polyEditor.setTarget(polygon2);
polyEditor.open();
}
},
mounted() {
this.init()
}
}
</script>
<style>
.container {
width: 100%;
height: 100vh;
}
</style>
3 个回复
BoredApe - 有问题就会有答案。
是否使用webview集成,无法使用有什么报错吗
DCloud_heavensoft
很明显,高德的这个js api是for web的,不是for小程序的。
丁不懂
key暴露了~~