-1
I’m in the middle of a project I have to do clustering on a map. I found this algorithm which is in PHP. My doubt is in this foreach
:
foreach ($markers as $key => $target) {
$pixels = pixelDistance($marker['lat'], $marker['lon'],
$target['lat'], $target['lon'],
$zoom);
/* If two markers are closer than given distance remove */
/* target marker from array and add it to cluster. */
if ($distance > $pixels) {
printf("Distance between %s,%s and %s,%s is %d pixels.\n",
$marker['lat'], $marker['lon'],
$target['lat'], $target['lon'],
$pixels);
unset($markers[$key]);
$cluster[] = $target;
}
}
in which
$markers = array();
$markers[] = array('id' => 'marker_1',
'lat' => 59.441193, 'lon' => 24.729494);
$markers[] = array('id' => 'marker_2',
'lat' => 59.432365, 'lon' => 24.742992);
$markers[] = array('id' => 'marker_3',
'lat' => 59.431602, 'lon' => 24.757563);
$markers[] = array('id' => 'marker_4',
'lat' => 59.437843, 'lon' => 24.765759);
$markers[] = array('id' => 'marker_5',
'lat' => 59.439644, 'lon' => 24.779041);
$markers[] = array('id' => 'marker_6',
'lat' => 59.434776, 'lon' => 24.756681);
$clustered = cluster($markers, 20, 11);
How to "translate" to Javascript?
Do you prefer Java, Javascript, or whatever?
– Bacco
@bigown Can be javascript
– Karlz93
Google Maps only supports javascript. Please change your question to specify javascript and not to confuse it with Java
– Emerson Rocha
@Emersonrochaluiz my goal is not to apply the algorithm in a google maps map but to adapt to another type of map
– Karlz93