Hello OpenLayers,
I am aware on how to set the bounds of my map and I also know how to get the
maximum bounds of my map. I have tried getMaxExtent, getExtent, etc and I
keep getting the same thing. I want to get the bounds that correspond to my
map's center. In other words I set the longitude and latitude of the map
and on load the map is on that longitude and latitude. Now I want to get
the bounds of that location and I am breaking my head figuring it out :(
Thanks,
elshae
Code below:
var options = {
controls: [new
OpenLayers.Control.Navigation()], //Needed to use GeoExt
controls such as the zoomslider
maxExtent: new OpenLayers.Bounds(-20037508.34,
-20037508.34,
20037508.34, 20037508.34),
units: 'm',
allOverlays: false
}
this.map = new OpenLayers.Map(options);
var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{type: google.maps.MapTypeId.HYBRID,
numZoomLevels: 20}
);
var gmap = new OpenLayers.Layer.Google(
"Google Streets", // the default
{type: google.maps.MapTypeId.ROADMAP,
numZoomLevels: 20}
);
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: google.maps.MapTypeId.TERRAIN,
numZoomLevels: 20}
// used to be {type: G_PHYSICAL_MAP}
);
var osm = new OpenLayers.Layer.OSM();
map.addLayers([osm, gphy, gmap, ghyb]);
var mapPanel = new GeoExt.MapPanel({
title: "Map",
map: this.map,
center: new OpenLayers.LonLat(93.9,
29.53).transform(new
OpenLayers.Projection("EPSG:4326"), new
OpenLayers.Projection("EPSG:900913")),
zoom: 4,
region: "center"
});
//Obtain Bbox coords
var proj = new OpenLayers.Projection("EPSG:900913");
var ext = mapPanel.map.getMaxExtent();.transform(
mapPanel.map.getProjectionObject(), proj);
alert(ext); //returns
left-bottom=(-20037508.3392,-20037508.3392)
right-top=(20037508.3392,20037508.3392)
//I need these variables to represent the bbox of my map's center :(
var minx = ext.left;
var miny = ext.bottom;
var maxx = ext.right;
var maxy = ext.top;
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Get-Bounds-of-Longitude-and-Latittude-tp5640152p5640152.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users