New answers tagged

0

I achieve the same result with this workaround. I assign a bogus loader function which does nothing and call my custom loader directly from the strategy method, returning the extent to the bogus loader assigned to the vector source. const source = new ol.source.Vector({ loader: () => {}, strategy: function(extent, resolution) { extent = [ol.proj....


0

I've gotten it work, I had to create an empty source object, set it as the source of the grid layer, and then populate the source with features afterwards. I have no idea why this fixes it, if anyone has any idea please explain, it would be very appreciated! var source = new ol.source.Vector(); var featuresList = [] //populated in whatever way var grid = new ...


2

You can't draw a polygon on a WMS layer and get all the attribute information from a WMS layer under the polygon, because A WMS does not expose data in that way. You can only get attribute information at a point location (a pixel coordinate) in the returned map image using a GetFeatureInfo request.


1

ol.coordinate.toStringHDMS is not an object, but just function/method for formatting geographic coordinates, so you don't have to use new qualifier when calling/envoking it (see docs at https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html), It should simply be: const hdms = ol.coordinate.toStringHDMS(ol.proj.toLonLat(coordinate));


1

Seems like the optimal solution would be to create layer group only once and then upon change set layers of this group with the .setLayers method. Since this method expects ol.Collection as input, layer collection has to be created from layer array. This in no way affects performance, since as docs say that collection is just "an expanded version of ...


1

There seems to be no option or method to set point opacity in ol.layer.Heatmap layer to 1, regardless of weight. One possible solution would be to use ol.layer.Raster layer to manipulate pixels of ol.layer.Heatmap layer. Problem is that raster layer requires image layer as input, which ol.layer.Heatmap layer is not. So one possible solution that works is to ...


2

You can reproduce the OL heatmap example. An important setting which is not detailed there is the weight setting. If not set, it defaults to 1, which basically means to display every point in red, the default max-value color. If you want 10 or more stacked points to be in red, put a weight of 0.1, doing so will allow coloring points being near 1 to 9 other ...


1

For anyone who is looking for an answer to this type of question, I found a method using OpenLayers v6.5.0. Their is an example for Draw and Modify Features, which can maintain the topology of lines and polygons. I will post two examples here. This one is for LineStrings This one is for Polygons Hope this helps some one :)


4

Made my comment an answer Solution 1: reproject coordinates to client side and ingest them as is in server side You need to reproject your coordinates from your frontend to backend. Your backend expects EPSG:4326. Your frontend use EPSG:3857. You need to transform the coordinates to EPSG:4326 before sending them So format.writeGeometry(plot.geometry....


2

You are creating multiple overlapping Polygon features from the coordinates of each ring. For a single polygon with holes use new Feature({ geometry: new Polygon(polygonWkbGeometryFromPostGis.coordinates) }) Or you could readFeatures from the WKT string in the same way as you readFeatures from the GeoJSON https://codesandbox.io/s/sleepy-williams-wv3gh


1

It's installed but it's not the right way to do it In C:\Users\Owner, you will find a directory node_modules with a child directory named ol. Normally, what you do is create a directory with a meaningfull name for your project, cd into it run npm init and answer to the questions. It will create a file named package.json. do npm install ol and now it's fine ...


0

You can now rotate a polygon with OpenLayers. Rotation unit is in radians and you also need to set a point to made rotation as seen in the API (link to parent class ol/geom/geometry that ol​/geom/Polygon inherits from) You can see a demo I made. Below, in my sample (only JS mentioned), I use the center of the bounding box of the polygon. To really center ...


Top 50 recent answers are included