我正在使用链接到 ArcGISArcGIS
的地图Esri
来在地图上显示一些点。到目前为止,我已经删除了具有相同坐标的点,并且只绘制了不重复的坐标。然后在这些点之间是连接它们的线。Android SDK
removeDupes
OnClick 我可以看到关于 1 点的信息。
现在,我需要在集群中显示相同的点,而不是删除重复项。基本上一个更大的圆圈会显示有多少点在相同的坐标上,然后当点击集群时,它会显示所有实际存在的点。
以下是有关如何将点添加到地图的代码:
private void plotRoute(List<DeliveryPoint> deliveryPoints) {
Logger.d("Plotting " + deliveryPoints.size() + " coordinates.");
pointsOfInterest = removeDupes(deliveryPoints);
SpatialReference SPATIAL_REFERENCE = SpatialReferences.getWgs84();
// create a red (0xFFFF0000) circle simple marker symbol
SimpleMarkerSymbol redCircleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFFFF0000, 10);
SimpleMarkerSymbol bigOrange = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFFFF8000, 20);
SimpleMarkerSymbol bigBlue = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFF0000FF, 20);
ArrayList<Graphic> poiMarkers = new ArrayList<>();
ArrayList<Graphic> labels = new ArrayList<>();
// create a new point collection for polyline
PointCollection points = new PointCollection(SPATIAL_REFERENCE);
graphicDeliveryPointCoordinatesHashMap.clear();
int ordinal = 0;
int length = pointsOfInterest.size();
for (DeliveryPoint poi: deliveryPoints) {
Point point = new Point(poi.longitude, poi.latitude, SPATIAL_REFERENCE);
points.add(point);
TextSymbol label = new TextSymbol(12, "" + ++ordinal, 0xFFFF0000, TextSymbol.HorizontalAlignment.CENTER, TextSymbol.VerticalAlignment.MIDDLE);
Graphic labelGraphic= new Graphic(point, label);
label.setOffsetY(10);
label.setOffsetX(10);
Graphic graphic = new Graphic(point, redCircleSymbol);
if(ordinal == 1) {
graphic = new Graphic(point, bigOrange);
} else if (ordinal == length) {
graphic = new Graphic(point, bigBlue);
}
poiMarkers.add(graphic);
labels.add(labelGraphic);
graphicDeliveryPointCoordinatesHashMap.put(graphic, poi);
}
textOverlay.getGraphics().addAll(labels);
poiOverlay.getGraphics().addAll(poiMarkers);
// create a polyline from the point collection
Polyline polyline = new Polyline(points);
//define a line symbol
SimpleLineSymbol lineSymbol =
new SimpleLineSymbol(
SimpleLineSymbol.Style.SOLID,
Color.argb(255, 255, 128, 0), 1.0f);
// create the graphic with polyline and symbol
Graphic lines = new Graphic(polyline, lineSymbol);
// add graphic to the graphics overlay
poiOverlay.getGraphics().add(lines);
mapView.setOnTouchListener(new PoiTouchListener(this, mapView, poiOverlay));
}
JavaScript
我在Link to JS clustering中找到了有关如何执行此操作的文档,但这对我没有帮助,因为似乎没有对Android
Clustering 的官方支持。
有没有办法解决这个问题?