Dmi*_*kin 4 map coordinates coordinate-systems openlayers-3
我有一点经纬度.如何将其转换为OpenLayer 3地图坐标系?我的代码是:
...requiries...
var coord = [55.7522200, 37.61556005];
//coord = ol.proj.transform(coord,'EPSG:4326', 'EPSG:3857');
var vectorSource = new ol.source.GeoJSON(
({
object: {
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {
'name': 'EPSG:3857'
}
},
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': coord
}
}
]
}
}));
...
var map = ...
Run Code Online (Sandbox Code Playgroud)
你能给我一个关于在JavaScript上转换var coords的例子吗?您可以在链接http://openlayers.org/en/v3.0.0/examples/geojson.html上看到此代码示例
eri*_*lem 10
如果您有一个坐标[lon, lat](按此顺序),您可以使用以下方法对其进行转换:
var newCoord = ol.proj.transform([lon, lat], 'EPSG:4326', 'EPSG:3857');
Run Code Online (Sandbox Code Playgroud)