I would like to know what is the fastest marker clustering algorithm in PHP?
The only thing I need from the cluster function is the exit with the obj cluster, which has the properties: lat, lng and size.
and then markers that were not grouped, of course, but I canβt find the PHP code for this, and there must be some?
I am looking for code that can lead to this result? (Or maybe itβs better to work). http://maps.forum.nu/server_side_clusterer/
So far I have tried:
function ClusterMarkers($markers,$ZOOM) { $this->load->library('firephp'); $singleMarkers = array(); $clusterMarkers = array(); // Minimum distance between markers to be included in a cluster, at diff. zoom levels $DISTANCE = (10000000 >> $ZOOM); // Loop until all markers have been compared. while (count($markers)) { $marker = array_pop($markers); $cluster = array(); // Compare against all markers which are left. foreach ($markers as $key => $target) { $pixels = abs($marker['lat']-$target['lat']) + abs($marker['lng']-$target['lng']); $this->firephp->log('pix :'.$pixels); if ($pixels < $DISTANCE) { unset($markers[$key]); $cluster[] = $target; } } // If a marker has been added to cluster, add also the one we were comparing to. if (count($cluster) > 0) { $cluster[] = $marker; $clusterMarkers[] = $cluster; } else { $singleMarkers[] = $marker; } } return array('singlemarkers' => $singleMarkers, 'clustermarkers' => $clusterMarkers); }
My data is then jsonized, but the clustermarkers array contains all the marker data, and I wonder how I would just set lat, lng and size without having to recount it in resourcedemanding every time a new marker is added.
Jakob source share