I've got a KML, where several points have the same coordinate, similar to following code:
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>test.kml</name>
<visibility>0</visibility>
<open>1</open>
<Placemark>
<name>Place 1</name>
<Point>
<coordinates>7.0901548880586,50.723973666434,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Place 2</name>
<Point>
<coordinates>7.0901548880586,50.723973666434,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
If I click on the POI in an OpenLayers-map, only the last point can be selected. Google Maps' solution to the problem are next
– and previous
-buttons, in Google Earth the placemark "splits" into two (or more) placemarks so you can select one of the placemarks.
Is it possible to create a similar behaviour in OpenLayers?
There is an analog problem if there are two KMLs with placemarks with the same coordinate. I need a solution for this problem, too.
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>test1.kml</name>
<visibility>0</visibility>
<open>1</open>
<Placemark>
<name>Place 1</name>
<Point>
<coordinates>7.0901548880586,50.723973666434,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>test2.kml</name>
<visibility>0</visibility>
<open>1</open>
<Placemark>
<name>Place 2</name>
<Point>
<coordinates>7.0901548880586,50.723973666434,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
Best Answer
Tyr to use
Strategy.Cluster
: see http://openlayers.org/dev/examples/strategy-cluster.htmlAdd option:
threshold: 2
at Cluster creation, this allows you to view element that does not overlap, and setdistance
(in pixels) see http://openlayers.org/dev/examples/strategy-cluster-threshold.html