I'm using Clusters to manage a lot of POIs on my map with Nutiteq. I implemented that base on this guid. every thing is fine except I have some geoPoint with exact coordinate which they are related to different location entities! I need to show a popUp to inform my user about these points.
Now my question is how to show a popup when user clicked on a multi point marker?
Thank you so much for your attention and participation.
You detect Popup data for the points probably using some metadata which is attached to the points. Similar to this you should add metadata to the cluster points in your cluster builder. I'm using Nutiteq sample code from https://github.com/nutiteq/hellomap3d-android/blob/master/com.nutiteq.advancedmap3/src/com/nutiteq/advancedmap3/ClusteredGeoJsonActivity.java
make sure also ClusterElements have data about individual points. Here I just take all names and put to one long string. You may need something more specific, like list of ID-s
@Override
public VectorElement buildClusterElement(MapPos pos, VectorElementVector elements) {
// Cluster popup has just a number of cluster elements, and default style
// You can create here also Marker, Point etc. Point is suggested for big number of objects
// Note: pos has center of the cluster coordinates
Log.d(Const.LOG_TAG,"cluster from "+elements.size()+" elements");
// add all capital names to metadata of cluster element
StringBuilder capitals = new StringBuilder();
for (int i=0;i<elements.size();i++){
capitals.append(elements.get(i).getMetaDataElement("Capital"));
capitals.append(";");
}
BalloonPopup popup = new BalloonPopup(
pos,
balloonPopupStyle,
Long.toString(elements.size()), "");
popup.setMetaDataElement("ClickText", capitals.toString());
return popup;
}
Add MapEventListener to this sample, so you can see the popups for both clusters and individual capitals
protected void onCreate(Bundle savedInstanceState) {
// MapSampleBaseActivity creates and configures mapView
...
// listener with vectorlayer for popups
LocalVectorDataSource vectorDataSource = new LocalVectorDataSource(baseProjection);
mapView.setMapEventListener(new MyMapEventListener(mapView, vectorDataSource));
VectorLayer vectorLayer2 = new VectorLayer(vectorDataSource);
mapView.getLayers().add(vectorLayer2);
...
}
See sample result: