5

I want to create a balloon for a KML file that dynamically moves.

The example that I am working on is sundials.html.

Let's say that the KML is moving. How we would get the balloon to move as well?

TIA.

4

I'm not really sure what you mean by "let's say that the KML is moving", but if you want to change the location of a popup after it has been created, here's how you do it:

// Set the new lonlat location.
popup.lonlat = new OpenLayers.LonLat(popup.lonlat.lon - 1, popup.lonlat.lat - 1);
// Tell OpenLayers to update the popup's location on the map.
popup.updateSize()

If you have a vector, such as a sundial, and it's lonlat changes, and you want the popup to move to the new center, you can do this:

// Set the popup's location equal to the vector's center
popup.lonlat = feature.geometry.getBounds().getCenterLonLat();
// Tell OpenLayers to update the popup's location on the map
popup.updateSize();

You can paste the first example into firebug on the sundials example and it should work straight away.

The OpenLayers API doesn't mention that the updateSize function updates the center, so it's possible that this behavior will disappear at some point.

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.