Questions tagged [openlayers-5]

v5 specific questions on the OpenLayers mapping library

OpenLayers v5 is the latest release of the OpenLayers mapping library.

From https://openlayers.org/:

OpenLayers makes it easy to put a dynamic map in any web page. It can display map tiles, vector data and markers loaded from any source. OpenLayers has been developed to further the use of geographic information of all kinds. It is completely free, Open Source JavaScript, released under the 2-clause BSD License (also known as the FreeBSD).

v5 reworked the library as a set of ES Modules, and improved compatibility with mainstream module bundlers.

317 questions
0
votes
1 answer

How to detect which layer was clicked?

Based upon this sample https://openstreetmap.be/en/projects/howto/openlayers.html I created a script showing layer and when clicking on it should show a popup with extra information The code shown below is what I wrote so far but I can't figure out…
Corobori
  • 303
  • 3
  • 13
0
votes
1 answer

Continue zooming in when smaller clusters are tapped

I am using openlayers 5.3. I want to continue zooming in when smaller clusters are tapped or clicked. I have used some code to achieve such requirement but it doesn't work. getStyleForCluster = (size: number): ol.style.Style => { let…
user10496245
  • 217
  • 3
  • 17
0
votes
1 answer

Drawn polygon does not show in openlayers

I have to draw a polygon on openlayers Map. This is my code: draw = new Draw({ source: this.vectorSource, type: 'Polygon' }) draw.on('drawend', e => { // sol 1, result is not as required let…
Ali Khalil
  • 41
  • 6
0
votes
0 answers

The 2nd layer doesn't come up

Based upon sample https://openlayers.org/en/latest/examples/popup.html I want to add another layer to show more information. The 1st layer appears fine but the 2nd doesn't come up I tried adjusting the code to add that layer var attribution = new…
Corobori
  • 303
  • 3
  • 13
0
votes
1 answer

auto hide text on zoom in

I have piece of code in openlayers. I need to auto hide some text after zooming in. nothing worked so far. This is what I have now: this.addMarker = function(lon, lat) { var mar = new ol.Feature({ geometry: new…
Issac Saji
  • 106
  • 6
0
votes
1 answer

How to go to extent programmatically?

I am new to Openlayers 5 and I want to move the map to a specific extent programmatically. I tried var bbox = [485319.36436093575, 5749497.169086075, 498451.8156390643, 5758869.310913925]; map.getView().fit(bbox, {size: map.getSize()}); but…
user11498311
0
votes
1 answer

How to style a layer

I am trying to put image icons on my nodes in an openlayers 5 layer, but can't seem to get it right. I load an osm file and everything is ok, but i get a small circle instead of the icon. I've searched online and all i can find is how to change a…
0
votes
1 answer

Using raster operations on OSM source in OpenLayers 5

var osmSource = new ol.source.OSM({ transition: 0 }); var rasterSource = new ol.source.Raster({ sources: [osmSource], operation: function(pixels,data) { var pixel = pixels[0]; …
ortegren
  • 11
  • 1
  • 3
0
votes
0 answers

How to generate features from GeoXML MapServer response in OpenLayers?

Could anyone explain to me the good way to initialize a vector layer using a response from a MapServer? Here is the way i do: new ol.layer.Vector({ title: name, source: new ol.source.Vector({ wrapX: false, url: function…
PopHip
  • 700
  • 6
  • 23
0
votes
1 answer

OpenLayers - Return values of getCoordinateFromPixel stay the same after calling setZoom() on map view

I have a use case where I want to determine if certain coordinates lay within the section of the view visible in the viewport. Our approach is to start by getting the coordinates of some pixels with our map's getCoordinateFromPixel method. This…
0
votes
1 answer

OpenLayers 5 not displaying vector layer with feature when adding style

I've been trying to place a simple marker (modeled as an ol.geom.Point) on a map in OpenLayers 5 and style it. I create a feature wrapping this ol.geom.Point, than create a VectorSource that uses it, and than instantiate a VectorLayer with that…
Joshua Schroijen
  • 376
  • 6
  • 23
0
votes
1 answer

Adding image along with animated linestring

I am trying to add an image/icon style along the lineString which is animating,but image/icon style is not getting added. Here is my style for line var lineStyle = new ol.style.Style({ image: new ol.style.Icon(({ opacity: 1, …
CKool
  • 3
  • 4
0
votes
1 answer

Openlayers 5 Typescript - interactively draw a shape

How can I do this in Openlayers 5 / Typescript? Is there a way (also) to identify the drawn rectangular? There may be other features on the vector layer. SOLUTION: import {Draw} from 'ol/interaction'; import {createBox} from…
tm1701
  • 7,307
  • 17
  • 79
  • 168
0
votes
1 answer

OpenLayers: Can't add a linestring of coordinates to a map

I am having trouble showing a linestring based on an existing coordinate list and would appreciate some help. Below is my code, which shows an OpenLayers5 map, but no linestring overlaid. I've read a bunch of different of different threads…
Paul
  • 83
  • 10
0
votes
0 answers

How to cache WMS-image layers

I preloaded images having urls containing a GetMap request (like below) into an IMG tag having width/height of 0px and set display to 'none'. The difference between the url of each image is only the "TIME" part (e.g.…
user1939338
  • 117
  • 9