I have a latitude and longitude of some point. How to conver its to the OpenLayer 3 map coordinate system? My code is:
...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 = ...
Could you gave me an example for converting the var coords on JavaScript. You can see this example of code at link http://openlayers.org/en/v3.0.0/examples/geojson.html
If you have a coordinate [lon, lat]
(in that order) you can transform it using:
var newCoord = ol.proj.transform([lon, lat], 'EPSG:4326', 'EPSG:3857');