[OpenLayers-Users] How to recenter the map when drawing

Stephen Woodbridge woodbri at swoodbridge.com
Tue Feb 16 11:30:03 EST 2010


smartini wrote:
> Hi.
> Just to define my business requirement first. When drawing on the map aka
> plotting a trail, I need to be able to recenter the map at the point at
> which a vertex is added.
> 
> Registering a click handler for the map to trigger a recenter only appears
> to work when not in sketch mode.
> The myriad of events available during drawing do not appear to provide me
> with what I need. Basically, there's the absence of a 'click' or a
> 'VertexAdded' event.
> 
> Just to reiterate, I can successfully register click events with the map and
> perform recentering based on the coordinates from these event arguments. I
> cannot, however, seem to be able to achieve this while in the process of
> plotting lines.
> 
> Regards,
> Steve 

Why don't you just call map.setCenter() after you add you point?

-Steve



More information about the Users mailing list