Home > Mobile >  Change the color of a marker openlayers map
Change the color of a marker openlayers map

Time:11-05

I am totally new to this, I'm trying to change the color of the marker on my map.

export const addMarkerLayer = (olMap, coordinate) => {

    const sourceMarker = new VectorSource({
      features: [new Feature(new Point(coordinate))], 

    })

    const vectorMarker = new VectorLayer({
      source: sourceMarker
    })
  
    olMap.addLayer(vectorMarker)

  return null 

Thank you for your help

I tried a lot of things but nothing worked..

Would it be possible for you to help me ? Thank you

CodePudding user response:

const vectorMarker = new VectorLayer({
      source: sourceMarker
      style: new ol.style.Style({
                fill: new ol.style.Fill({
                    color: 'rgba(255,255,0,0.5)'
                }),
                stroke: new ol.style.Stroke({
                    color: 'rgba(255,255,0,1)'
                    width: 5
                })
    })
  
    olMap.addLayer(vectorMarker)
  • Related