Hot answers tagged

11 votes
Accepted

Splitting a polygon by multiple linestrings leaflet and turf.js

Solution below is not direct answer to the question, it's just improved version of answer to similar question Splitting A polygon into multiple polygon by multiple line strings in Leaflet and turf.js, ...
user avatar
  • 17.8k
5 votes
Accepted

How to specify custom CSS to an OpenLayers Zoom Control in Angular 6?

In Angular a style in @Component will only be applied to its own template (see https://angular.io/guide/component-styles#style-scope) You basically have two options: Overwrite the style in your ...
user avatar
  • 178
3 votes
Accepted

De-highlight highlighted features with button click in OpenLayers?

Your code will only de-highlight a feature if it is under the button when clicked. To de-highlight all features you would need btn.addEventListener("click", (event) => { event....
user avatar
  • 10.1k
3 votes
Accepted

Adding a PNG image to a WFS layer in an OpenLayers?

To display an image on a LineString you will need a style array, one style with geometry function which returns a Point geometry (e.g. the midpoint of the line) where the image is to be placed, and ...
user avatar
  • 10.1k
3 votes
Accepted

How to unset an event listener in OpenLayers 6?

To use un you must use a named function for on Without a named function you must save the event key eventKey = this.mapObj.on('singleclick', ... and use unByKey(eventKey); imported as import {...
user avatar
  • 10.1k
3 votes
Accepted

Map container is already initialized

Sounds like you want to read a file and create markers, and these markers should be in a layergroup so Leaflet handles them as one layer. Here is something similar to your code that I used. $....
user avatar
2 votes
Accepted

AssertionError 25 on getExtent, Openlayers?

The link doesn't work in version 5.3.3 so here is the 5.3.0 version https://openlayers.org/en/v5.3.0/doc/errors/#25 The data is loaded to the source asynchronously so you need to open the view at a ...
user avatar
  • 10.1k
2 votes
Accepted

Adding offset to feature of layer in OpenLayers 4.6?

As I wrote in my comment, I'm not familiar with Angular environment. Since you replied that any hint is welcome, here it is, with standard JS. The simplest way to create such markers is with ol....
user avatar
  • 17.8k
2 votes
Accepted

Update WMS layer OpenLayers + Angular?

You could simply update the params in the existing source this.layer.getSource().updateParams({LAYERS: this.newLayers()});
user avatar
  • 10.1k
2 votes
Accepted

Get the properties of highlighted features when de-highlighting one of them in OpenLayers?

To have list of selected features you can create additional vector source selectedFeatures where you add selected feature and remove it, when it's unselected. Relevant code could then look something ...
user avatar
  • 17.8k
2 votes
Accepted

How to get the co-ordinates of the clicked point using 'ol/Draw' in OpenLayers 6?

There will be no .getGeometry().on('change', ... event for a Point because it only requires a single click to draw it. But you can check for a point at the drawend event this.draw.on('drawend', (...
user avatar
  • 10.1k
2 votes
Accepted

Change popup content with JavaScript

For some reason, Angular wasn't detecting the show_hide() funtion, no matter where I tried putting it. But I was able to achieve what I wanted by embedding the code within the HTML onclick definition: ...
user avatar
2 votes

Change popup content with JavaScript

Define your show_hide() function on global level and then call it with text parameter you want to replace current text with. Code could then look something like this: function show_hide(element, txt) ...
user avatar
  • 17.8k
1 vote
Accepted

Leaflet geoJSON - function within setStyle()

Since style_new function returns style object, it must not be embedded in the object specifiers {} when you call it, so code should look like this: this.map_layer.eachLayer(function (layer: any) { ...
user avatar
  • 17.8k
1 vote
Accepted

Angular analysis in sDNA - sensitivity to small angular changes in road segments

sDNA considers both changes within polylines and changes at junctions between polylines, but they are handled differently. With a hybrid metric you can set thresholds for angular change for junctions ...
user avatar
  • 2,188
1 vote

Adding multiple Marker animation by route id in OpenLayers by angular

I think you can simply wrap the fetch block in a function, add some more buttons to the HTML, then you can call the function for each of your jsons, passing a different style and control button for ...
user avatar
  • 10.1k
1 vote
Accepted

QGIS2web Export open layers map as PDF, PNG or JPEG

You do not need to use imports, you can use the full build syntax in your code instead, where https://openlayers.org/en/latest/doc/quickstart.html is equivalent to https://openlayers.org/en/latest/...
user avatar
  • 10.1k
1 vote
Accepted

Google Earth Engine ee.data.authenticateViaPrivateKey in Angular app not working

If you look at the docs, the privateKey argument in ee.data.authenticateViaPrivateKey(privateKey, success, error, extraScopes) should be the "JSON content of private key". So, not the path of the JSON ...
user avatar
  • 9,745
1 vote
Accepted

Could not locate LayerGroup in catalog GeoServer + OpenLayers?

Any idea of what am I doing wrong here? I'm pretty stuck with this! Group layers are a WMS construct, you can't access them through a WFS request.
user avatar
  • 12.1k
1 vote

Smooth line animation on map

Your marker2 blinks (disappears) because you are removing it by source.removeFeature(marker2) and then adding again by source.addFeature(marker2). Since it's the same marker that just changes ...
user avatar
  • 17.8k
1 vote

How can I prevent a marker being dropped when the map is dragged in Leaflet?

This is all about managing your event handlers. I'm going to remove the HTML into onclick function and do it all in one place in the js: <div id="map"></div> What we'll do is add an ...
user avatar
1 vote
Accepted

Removing shapes on a mouse click - Angular 6

Something as simple as this would do it. It returns true after the first feature, so won't remove more than one if they overlap. You might want to add further checks. map.on('click', function(evt)...
user avatar
  • 10.1k
1 vote
Accepted

Converting GeoJSON to projected coordinates in Leaflet?

If you really want to have GeoJSON in projected coordinates, you can use Leaflet's L.CRS.EPSG3857.project method for that. Since result of drawing is not some complicated feature collection, you could ...
user avatar
  • 17.8k
1 vote

Get L.marker individual attributes

2 options, for a single marker: var lat = 43; var lng = -76; var marker = L.marker([lat,lng]).bindPopup(lat.toString()+", "+lng.toString()).addTo(map); marker.addTo(map); For multiple markers use ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible