I am new with OpenLayers, my problem seemed easy, but I have troubles with that. I am trying to make some markers when the map loads up, I need 3 of them lets say and also I have some callback from menu to actually disable them, but if needed I would then also like to add them back. I have this functions, but I am not even able to make them before. This function is made to work when you click on some point it will make there waypoint, but even when giving the specific GPS coordinates it will not make it.

    function removeMarker(obj) {

function marker(obj) {
  var coord4326 = ol.proj.transform(obj.coordinate, 'EPSG:3857', 'EPSG:4326'),
      template = 'Coordinate is ({x} | {y})',
      iconStyle = new ol.style.Style({
        image: new ol.style.Icon({ scale: .6, src: 'images/pin_drop.png' }),
        text: new ol.style.Text({
          offsetY: 25,
          text: ol.coordinate.format(coord4326, template, 2),
          font: '15px Open Sans,sans-serif',
          fill: new ol.style.Fill({ color: '#111' }),
          stroke: new ol.style.Stroke({ color: '#eee', width: 2 })
      feature = new ol.Feature({
        type: 'removable',
        geometry: new ol.geom.Point(obj.coordinate)


Solved ! SOLUTION = https://wiki.openstreetmap.org/wiki/Openlayers_POI_layer_example

  • Your function works jsfiddle.net/g4p3zvem/1 so there must be a problem with how you are calling it. It expects EPSG:3857 coordinates but what projection are you GPS coordinates? – Mike May 10 at 14:00
  • Hi, thanks for fast reply I would like to implement that into this , jsfiddle.net/2gem4dhj/ , but I would like to have 3 points on start as bike a b c, and then if i want in the menu just turn them off, but if i change my mind just show them, and I would like to do it through some variables, because it will be needed to be connected to database . thanks – Adam Felner May 10 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.