Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question

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, - 1);
// Tell OpenLayers to update the popup's location on the map.

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

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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