我正在尝试在openlayers中使用正方形多边形获取边界框。我需要从该框中获取南、北、西、东四个值。目前,我的做法如下:
var topleft = vectors.features[0].geometry.getVertices()[0];
获取左上角的顶点。但它返回的值类似于:
POINT(-13393350.718762 4024321.5982824)
我怎样从返回的点中获取纬度和经度数值?
我正在尝试在openlayers中使用正方形多边形获取边界框。我需要从该框中获取南、北、西、东四个值。目前,我的做法如下:
var topleft = vectors.features[0].geometry.getVertices()[0];
获取左上角的顶点。但它返回的值类似于:
POINT(-13393350.718762 4024321.5982824)
我怎样从返回的点中获取纬度和经度数值?
var myPoint = new OpenLayers.Geometry.Point(vectors.features[0].geometry.getVertices()[0].x,
vectors.features[0].geometry.getVertices()[0].y )
var myLatLonPoint = myPoint.transform( map.getProjectionObject(),
new OpenLayers.Projection("EPSG:4326"));
那么您应该能够从这些点中获取经度和纬度。
另一个选项,可能更可取的是将边界转换后提取单独的顶点。
var myLatLonSquare = vectors.features[0].geometry.transform( map.getProjectionObject(),
new OpenLayers.Projection("EPSG:4326"));
然后使用以下方法提取顶点的纬度和经度信息:
myLatLonSquare.getVertices()[0].x myLatLonSquare.getVertices()[0].y