[OpenLayers-Dev] coodinates to use in LonLat

Gajera Tejas tejas.gajera at gmail.com
Mon Jul 26 18:20:25 EDT 2010


Leonardo,

If I understood your question correctly, let say you want to zoom at
the position where you double click and make that as center of your
map.

I would do something like this:

// register double click event to map
map.events.register("dblclick", map, function(e) { onMapDoubleClick(e) });

// in onMapDoubleClick function get the lon and lat of the point where
you double clicked and next zoom level
function onMapDoubleClick(e)
{
	zoomLevel = zoomLevel + 1;
	var lonlat = map.getLonLatFromViewPortPx(e.xy);
	
	if(zoomLevel > mapMaxZoom)
	{
		gCurrentZoomLevel = mapMaxZoom;
		return;
	}
	else
	{
		map.setCenter(new OpenLayers.LonLat(lonlat.lon, lonlat.lat), zoomLevel);
	}
}

hope it will help you.

Regards,
Tejas Gajera
Research Assistant, Division of Hematology/Oncology
Beth Israel Deaconess Medical Center
SL-409
330 Brookline Avenue
Boston, MA  02215
Phone: (617) 667 - 0678
E-mail: tgajera at bidmc.harvard.edu



On Mon, Jul 26, 2010 at 6:02 PM, Leonardo Gaona <leogaona at gmail.com> wrote:
> ¿how to get the coordinates LonLat to center the map at a specific position
> with setCenter ()?
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
>



More information about the Dev mailing list