function queryfunc(){
map.graphics.clear();
if(clusterLayer!=undefined){
map.removeLayer(clusterLayer);
}
$.ajax({
url:'gis/tt',
data:{month:$('#search_date').val(),city:$('#cityName').combobox('getValue')},
success : function(data) {
obj= $.parseJSON(data);
if(obj.length<1){
alert("当前条件下未查询到数据");
return false;
}
require([
"dojo/_base/array",
"esri/Color",
"esri/map",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/request",
"esri/graphic",
"esri/geometry/Extent",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/PictureMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/renderers/ClassBreaksRenderer",
"esri/layers/GraphicsLayer",
"esri/SpatialReference",
"esri/geometry/Point",
"esri/geometry/webMercatorUtils",
"ClusterLayer",
"dojo/domReady!"
], function (arrayUtils,
Color,
Map,
ArcGISTiledMapServiceLayer,
esriRequest,
Graphic,
Extent,
SimpleMarkerSymbol,
PictureMarkerSymbol,
SimpleLineSymbol,
SimpleFillSymbol,
ClassBreaksRenderer,
GraphicsLayer,
SpatialReference,
Point,
webMercatorUtils,
ClusterLayer){
var countyInfo = {};
var multipoint = new esri.geometry.Multipoint();
var resultUnionExtent;
countyInfo.data = arrayUtils.map(obj, function(item) {
var latlng = new Point(item.LONGITUDE, item.LATITUDE, map.spatialReference);
multipoint.addPoint(new Point(item.LONGITUDE, item.LATITUDE));
var webMercator = webMercatorUtils.geographicToWebMercator(latlng);
var attributes = {
/* "小区名称": item.cell_name, */
"经度": item.LONGITUDE,
"纬度": item.LATITUDE,
};
return {
"x": webMercator.x,
"y": webMercator.y,
"attributes": attributes
};
});
clusterLayer = new ClusterLayer({
"data": countyInfo.data,
"distance": 100,
"labelColor": "#fff",
"labelOffset": 10,
"resolution": map.extent.getWidth() / map.width,
"singleColor": "#888"
});
var defaultSym = new SimpleMarkerSymbol().setSize(4);
var renderer = new ClassBreaksRenderer(defaultSym, "clusterCount");
var picBaseUrl = "${basePath}app/templates/manage/wyproblemcell/images/";
var marker = new PictureMarkerSymbol("${basePath}app/templates/manage/arcgis319/img/marker.png",44,33);
var blue = new PictureMarkerSymbol(picBaseUrl + "BluePin1LargeB.png", 32, 32).setOffset(0, 15);
var green = new PictureMarkerSymbol(picBaseUrl + "GreenPin1LargeB.png", 64, 64).setOffset(0, 15);
var red = new PictureMarkerSymbol(picBaseUrl + "RedPin1LargeB.png", 72, 72).setOffset(0, 15);
renderer.addBreak(0, 2, marker);
renderer.addBreak(2, 500, green);
renderer.addBreak(500, 20001, red);
clusterLayer.setRenderer(renderer);
map.addLayer(clusterLayer);
if(multipoint.points.length > 0){
if(resultUnionExtent == null){
resultUnionExtent = multipoint.getExtent();
}else{
resultUnionExtent = resultUnionExtent.union(multipoint.getExtent());
}
}
map.setExtent(resultUnionExtent.expand(1.2));
});
}
});
}
ArcGIS实现聚合点效果
最新推荐文章于 2024-09-19 10:33:45 发布