I am trying to group POIs in a cluster. I am using the class ClusterHelper included int the script clustering.js, so I suppose I have to follow these steps:
1) Pass the markerList to "createClusteredPlaces" (a 2) Then I get an array of elements. Some of theses elements will be POIs and others will be clusters with more than one POI 3) Now that I have my POIs ordered, I have to show them in the screen, but I don't know where to do this.
Any help please?
This is how I am painting my POIs without clustering (in poiatlocation):
var World = { init: function initFn() { PoiRadar.show(); AR.context.onLocationChanged = World.onLocationChanged; }, onLocationChanged: function onLocationChangedFn(latitude, longitude, altitude, accuracy) { AR.context.onLocationChanged = null; }, createMarkerAtLocation: function createMarkerAtLocationFn(latitude, longitude, altitude, nameMarker, pathImageFile, indexPosition, distanceLabel) { if( !markerList.hasItem(indexPosition) ){ var poiData = { "latitude" : parseFloat(latitude), "longitude" : parseFloat(longitude), "altitude" : parseFloat(altitude), "name" : nameMarker, "indexPosition" : parseInt(indexPosition), "distance" : distanceLabel }; markerList.setItem(indexPosition, new Marker( poiData, new AR.ImageResource(pathImageFile)) ); } PoiRadar.show(); } }; World.init();
I will write a tutorial about how to do the clustering after finishing, but I need to know how to do this first.
Thank you very much in advance.
A
Andreas Fötschl
said
almost 10 years ago
Hi there!
Once you implemented your clustering algorithm (e.g. using the very basic implementation from this post), it is up to you how to display custered places.
You may:
calculate the average lat/lon and place a clustered-marker-asset (using e.g. AR.ImageDrawable) there and e.g. show a list of the stacked pois when user clicks on it
adjust the altitude of the placemarks, depending on the distance. Ensure to adjust location manager, so you ignore altitude in general by reporting always altitude 0 to the architectView
go a more advanced approach and implement an animation so clustered places appear somewhere relative to the average position, as descriped in first approach
You may even allow user to adjust the range and update clustering algo on distance/location updates
The topic is a quite complex one when markers are quite big and contain labels and thumbnails. In case markers are just of a size of your thumb's nail you can reduce the number of stacked sizes to a minimum.
Santiago González
1 person has this problem