I want to display some markers on Openlayers map mobile version. I know that standard way of adding markers on Openlayers does not work with Openlayers mobile library. The example of Openlayers site didn't help me add a marker dynamically. Can somebody show me the correct way of implementation?

1 Answer 1


I was reading and it seems that there are no makers in Open Layers mobile. So the solutions is to make a feature with a point inside. Here is an example of how I did it.

/** function that is used to join a point to the map*/
function agregarPunto(long, lat, ZoomLevel){
    var proyeccion = new OpenLayers.Projection("EPSG:4326");
    var lonLat = new OpenLayers.LonLat(longitud, latitud)
    .transform(proyeccion , // transform from WGS 1984
      map.getProjectionObject() // to Spherical Mercator Projection
    var punto = new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat);
    vector.addFeatures([new OpenLayers.Feature.Vector(punto,{},styleCross)]);
    map.setCenter(lonLat, ZoomLevel, false, false);

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.