[Users] Re-center map via an "outside"-link
Ian Turton
ijturton at gmail.com
Tue Aug 17 17:36:37 CEST 2010
On Tue, Aug 17, 2010 at 11:04 AM, Stefan Schwarzer
<stefan.schwarzer at unepgrid.ch> wrote:
> Hi there,
>
> I am trying to make available some "shortcuts" to the user, meaning that at the right side of the Mappanel, there are some names on which the user can click to zoom directly to these regions/towns.
>
> However, I don't get how this could be implemented. I searched quite some while on the Net, but couldn't really find an answer. I guess that it's not too difficult to implement; I am just not too familiar with Javascript. What I came up so far is something like:
>
> <a href="#" onclick="mapdiv = document.getElementById('map'); mapdiv.setCenter(6, 45); mapdiv.zoomTo(10);">.....</a>
>
I've been experimenting with this just now - here is what I came up with:
var clicker = (function(data) {
return function (){
var lon = data.longitude;
var lat = data.latitude;
// alert(lon+','+lat);
map.setCenter( new
OpenLayers.LonLat(lon,lat),8,false,true);
};
})(d);
Ext.get("div"+i).on('click',clicker);
Where div0, div1 etc are div's that surround the place names in my list.
Hope this helps
Ian
--
Ian Turton
More information about the Users
mailing list