2

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>
2

Tyr to use Strategy.Cluster: see http://openlayers.org/dev/examples/strategy-cluster.html

Add option: threshold: 2 at Cluster creation, this allows you to view element that does not overlap, and set distance (in pixels) see http://openlayers.org/dev/examples/strategy-cluster-threshold.html

  • Thank you for your answer. I was able to successfully implement your solution for the case of multiple points in one KML, but now there is a small square instead of my marker. Is it possible to change the marker for the cluster? How can I adapt the solution for the similar problem with two KMLs with POIs with the same coordinates? – ischas Apr 4 '13 at 9:52
  • Okay, I solved the marker-problem with the help of this question: stackoverflow.com/questions/6641919/… , but still need help for the problem with the POIs of two layers sharing one coordinate. – ischas Apr 4 '13 at 15:47
  • The only thing I can think is to display it in a single layer oops! Want to highlight or select the features? – xamamano -jorix- Apr 4 '13 at 16:18
  • I want to select one point and display its description in a balloon. In the case of a cluster there should be a choice, which of the clustered points should be selected. – ischas Apr 5 '13 at 6:29
  • See this example: jorix.github.com/OL-FeaturePopups/examples/feature-popups.html uses a control written by me that you can help. – xamamano -jorix- Apr 5 '13 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.