1

Working with Openlayer 6, my map is working fine for the 40 layers on initial load. Against search functionality, I am trying to add a new layer on the map using the following code.

const createMarkersLayer = (val)=>{ const coordinates = val.map(r=>this.getResultCentreCoordinates(r)) const coordinatesList = coordinates.flat() const markers = new VectorLayer({ source:new VectorSource(), opacity:1, visible:true, zIndex:100, minZoom:3, minResolution: 0, maxResolution: 100, style: new Style({ image:new Icon({ src: require('@/mapmanagement/static/images/layers/result-marker.png'), opacity: 1, size:[200, 200], anchor: [0.5, 0.5], anchorXUnits: 'fraction', anchorYUnits: 'fraction', scale:1 }) }) }) // this.map.getLayers().insertAt(2, markers) this.map.addLayer(markers) for (let i = 0; i < coordinatesList.length; i++) { const marker = new Feature({ geometry: new Point(coordinatesList[i]) }) markers.getSource().addFeature(marker) }} } 

Problem:

Markers are not visible on min resolution. This last added layer does become visible on max zoom level of the map.

1 Answer 1

0

Observed behavior is consequence of your vector source option

maxResolution: 100 

For standard Mercator projection EPSG:3857 resolution at zoom 10 is 152.8740565703525 and at zoom 11 it's 76.43702828517625. See for example https://www.maptiler.com/google-maps-coordinates-tile-bounds-projection/.

Zoom for resolution 100 is 10.61234359549527, and so only after zoom is greater than this value your markers will be displayed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.