1 Star 0 Fork 0

yzishan / webs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
amap.html 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
yangzishan 提交于 2023-11-23 18:59 . 02
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<style>
html,
body,
#container {
width: 100%;
height: 100%;
}
</style>
<title>多边形的绘制和编辑</title>
<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=1.4.15&key=您申请的key值&plugin=AMap.PolyEditor"></script>
<script src="https://a.amap.com/jsapi_demos/static/demo-center/js/demoutils.js"></script>
</head>
<body>
<div id="container"></div>
<div class="input-card" style="width: 120px">
<button class="btn" onclick="polyEditor.open()" style="margin-bottom: 5px">开始编辑</button>
<button class="btn" onclick="polyEditor.close()">结束编辑</button>
</div>
<script type="text/javascript">
var map = new AMap.Map("container", {
center: [116.400274, 39.905812],
zoom: 14
});
map.plugin(["AMap.MouseTool"],function(){
var mouseTool = new AMap.MouseTool(map);
//使用鼠标工具,在地图上画标记点
mouseTool.marker();
});
// var path = [
// [116.403322, 39.920255],
// [116.410703, 39.897555],
// [116.402292, 39.892353],
// [116.389846, 39.891365]
// ]
// var polygon = new AMap.Polygon({
// path: path,
// strokeColor: "#FF33FF",
// strokeWeight: 6,
// strokeOpacity: 0.2,
// fillOpacity: 0.4,
// fillColor: '#1791fc',
// zIndex: 50,
// })
// map.add(polygon)
// // 缩放地图到合适的视野级别
// map.setFitView([ polygon ])
// var polyEditor = new AMap.PolyEditor(map, polygon)
// polyEditor.on('addnode', function(event) {
// log.info('触发事件:addnode')
// })
// polyEditor.on('adjust', function(event) {
// log.info('触发事件:adjust')
// })
// polyEditor.on('removenode', function(event) {
// log.info('触发事件:removenode')
// })
// polyEditor.on('end', function(event) {
// log.info('触发事件: end')
// // event.target 即为编辑后的多边形对象
// })
</script>
</body>
</html>
1
https://gitee.com/yzishan/webs.git
git@gitee.com:yzishan/webs.git
yzishan
webs
webs
master

搜索帮助