I'm working in a Geocoder tool that can put new features in a vector layer directly just pressing a button. When press the button all the features of the layer disappear in the map. The features still exists because I can get the length increased by one using after that:


I did the following function as button click handler

function addPoint(lng,lat)
  var pp = new ol.geom.Point( [
    ol.proj.transform([lng,lat], 'EPSG:4326', 'EPSG:3857'),
var featurething = new ol.Feature({
   geometry: pp

1 Answer 1


ol.proj.transform returns Array. so it means,

var pp = new ol.geom.Point([[lng,lat]]);

there's useless square brackets. remove them, then it works.

var pp = new ol.geom.Point(
    ol.proj.transform([lng,lat], 'EPSG:4326', 'EPSG:3857')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.