<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<!--
ArcGIS API for JavaScript, https://js.arcgis.com
For more information about the webmap-basic sample, read the original sample description at developers.arcgis.com.
https://developers.arcgis.com/javascript/latest/webmap-basic/index.html
-->
<title>Load a basic WebMap - 4.7</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 99%;
width: 100%;
}
input {
height: 30px;
width: 100px;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/3.21/esri/css/esri.css">
<script src="https://js.arcgis.com/3.21/"></script>
<script src="js/MarkCluster.js"></script>
<script>
require([
"esri/map",
"esri/SpatialReference",
"esri/geometry/Point",
"esri/symbols/PictureMarkerSymbol",
"esri/symbols/SimpleMarkerSymbol",
"esri/renderers/ClassBreaksRenderer",
"esri/layers/GraphicsLayer",
"esri/graphic",
"dojo/domReady!"
], function (Map,SpatialReference,Point,PictureMarkerSymbol,SimpleMarkerSymbol,
ClassBreaksRenderer,GraphicsLayer,Graphic) {
var map = new Map("viewDiv",{
//basemap:"http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer"
basemap: "streets"
});
map.on("load", function(){
map.centerAt(new Point(113, 23, new esri.SpatialReference({wkid: 4326})));
map.setZoom(10);
//创建覆盖物图层
var layer = new GraphicsLayer();
map.addLayer(layer);
//先添加20个覆盖物,位置随机
var marks = [];
for(var i=0;i<20;i++){
var pt = new Point(112.5+Math.random(), 22.5+Math.random(), new esri.SpatialReference({wkid: 4326}));
map.centerAt(pt)
var symbol = new SimpleMarkerSymbol({
"color": [0,0,255,255],
"size": 25,
"style": "circle",
"outline": {
"color": [0,0,0,255],
"width": 1
}
});
var graphic = new Graphic(pt,symbol);
layer.add(graphic);
marks.push(graphic);
}
var cluster = new MarkCluster(map,marks,60);
cluster.autoCluster();
cluster.layerRefresh();
var btn = document.getElementById("addMark");
btn.addEventListener("click", function() {
var pt = new Point(112.5+Math.random(), 22.5+Math.random(), new esri.SpatialReference({wkid: 4326}));
var symbol = new SimpleMarkerSymbol({
"color": [0,0,255,255],
"size": 25,
"style": "circle",
"outline": {
"color": [0,0,0,255],
"width": 1
}
});
var graphic = new Graphic(pt,symbol);
layer.add(graphic);
marks.push(graphic);
cluster.layerRefresh();
});
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
<input id="addMark" type="button" value="添加覆盖物" />
</body>
</html>
arcgis api覆盖物动态聚合效果源码1
需积分: 24 166 浏览量
2018-06-17
01:07:04
上传
评论 3
收藏 13KB RAR 举报
_wings
- 粉丝: 10
- 资源: 1