Questions tagged [openlayers]
Use when the version you are using of the OpenLayers JavaScript client toolkit is 3 or later
3,383
questions
1
vote
0
answers
17
views
Display all labels without collisions in OpenLayers
OpenLayers 6, Mapserver 7
As a beginner, I display polygons like this :
const presc = new ol.source.Vector({
format: new ol.format.GeoJSON(),
loader: function(extent, resolution, projection, ...
0
votes
0
answers
15
views
How to get extent of drawn rectangle feature in OpenLayers 6
My code:
var geometryFunction, maxPoints;
const value = 'Circle';
geometryFunction = createBox();
const source = new VectorSource({wrapX: false});
const vector = new VectorLayer({
...
0
votes
0
answers
10
views
How to add custom style with dragZoom in OpenLayers 6?
I want to add custom style with open layer while using the dragZoom()
my code:
let box_selection =
new DragZoom({
condition: (e) => {
return true
},
out:...
0
votes
0
answers
28
views
Hybrid Satellite Base with Openlayers does not work
Use openstreetmap base with openlayers but would also like a satellite base.
Thought of Bing, MapBox, however, are not working. Can anyone help?
This is the code for the Bing satellite base, which ...
1
vote
0
answers
26
views
GeoTIFF COG Mosaic, Custom Projection, OpenLayers
TL;DR
I have a collection of 50 COGs in NZTM projection. The COGs are aligned in a seamless grid. I'd like to use these COGs in a similar method to mosaicJSON on like a VRT online, wherein, I can ...
1
vote
1
answer
20
views
Maptiler and OpenLayers marks don't work well together
I am trying to use Maptiler together with OpenLayers. I followed the instructions in MapTiler site and cannot make the markers to show properly over the map. What happens is that the map features (...
1
vote
0
answers
26
views
Get rid of duplicate polygons using OpenLayers
OpenLayers 6, Mapserver 7
I have defined a vector source like this :
const presc = new ol.source.Vector({
format: new ol.format.GeoJSON(),
loader: function(extent, resolution, projection, success,...
0
votes
0
answers
17
views
How to set Control.Bar position in OpenLayers
I have a control.Bar in OpenLayers and I would like to set the position, but it doesn't work. Any idea?
var control_bar_measure = new ol.control.Bar({group: true});
var measureActive = false;
...
0
votes
0
answers
34
views
Zoom to and highlight search result in OpenLayers
I have a function to search from layer. I got the desired results, so I want to zoom-in and highlight the results I found. How can I do that?
This is my code:
var sothuaMap = document.getElementById('...
0
votes
0
answers
23
views
Why does getCoordinates return long coordinates?
After click on the map I got long coordinates values as:
[5364981.75481758, 7224346.2294111]
Code line is:
const geom = (
this.editFeaturePointClone.getGeometry() as any
).getCoordinates();
...
0
votes
0
answers
32
views
Why does getFeaturesAtPixel return empty array?
I draw the geojson on the map:
const geoJSONFormat = new GeoJSONOl();
const source = new VectorSource({
format: new GeoJSONOl(),
features: geoJSONFormat.readFeatures(geojsonObject),
...
0
votes
1
answer
13
views
Why OpenLayers does not render the features collection?
I use this code:
const source = new VectorSource({
format: new GeoJSONOl(),
strategy: bboxStrategy,
});
source.addFeatures(features);
const layer = new VectorLayer({
...
-1
votes
0
answers
38
views
Plus Codes doesn't work with OpenLayers
I'm trying to use the Plus Codes example with Openlayers (VECTOR) https://grid.plus.codes/
however, I got no result. Does not show the layer (grid).
// Create the map with a vector layer.
var ...
0
votes
0
answers
33
views
Get the style of a vector layer (OpenLayers) [closed]
I would like to get the style of a layer and save it in my database, to use it once the user is connected again.
I know that it's possible to get the style of a feature, but it's not what I'm looking ...
1
vote
1
answer
53
views
Search multiple GeoJSON feature properties in OpenLayers?
I have a code to do the search function, i got the results from var props = results[0].properties; but for if not work, I don't know why.
How can I fixed and zoom to result?
This is my code:
var ...
0
votes
0
answers
27
views
How to change Zoom button in PopupFeature with Openlayers?
I'm using the code https://viglino.github.io/ol-ext/examples/popup/map.popup.feature.html to create the Popup, to show the features information.
As can be seen in Figure 1, we have a magnifying glass ...
2
votes
0
answers
38
views
Extent of a proj4 string
I have a custom proj4 string in which my data is represented in Cartesian local coordinates. The example proj4 is below.
+proj=tmerc +lat_0=44.155877943 +lon_0=141.655514872997 +k_0=1.000004976 +a=...
-1
votes
0
answers
20
views
Remove an item from a legend OpenLayers (ol-ext)
I would like to remove an item from a legend by his title,
I found just how to remove all the items from a legend
legend.getItems().clear()
But it's not what I'm looking for,
It's possible to delete ...
-2
votes
1
answer
28
views
Why setStyle does not work for point geometry from cluster? [closed]
I use this code to chnage style (just color icon) of point element from cluster:
if (ft.getGeometry().getType() == 'Point') {
ft.setStyle(
new Style({
image: new Icon({
...
0
votes
0
answers
9
views
Why the Layer Sources are disappeared after change TileLayer?
I have a drawn features in specific VectorSource. Also there are two base tiles as TileLayer.
Why when I change the base layer the features are dissapered?
changeTile(tile: TileLayer<any>) {
...
1
vote
1
answer
14
views
Point styling in web-map in openlayers library
I want to style points (vector data) in openlayers. So far console does not show any errors, but points are not displayed as well. My code:
let urlLayer = new ol.layer.Vector({
source: urlSource,
...
0
votes
0
answers
43
views
Store created features to PostGIS table via GeoServer does not work: ERROR: Refused to set unsafe header "User-Agent"
I'am trying to develop a crowdmapping application for setting points via an OpenLayers Client. These have to be stored via GeoServer to a PostgreSQL database with PostGIS extension. When I try to save ...
0
votes
0
answers
14
views
Why zindex does not work for some layers OpenLayers?
I have a function that creates a new layer and display the features. I can call this function some times to create a new layers with own features. Problem is that the features are not visible if I ...
0
votes
0
answers
25
views
Why setStyle does not work for point?
I have a feature. The feature has geometry: Point. I try to change a style:
const selectPointStyle = new Style({
image: new Circle({
radius: 45,
fill: new Fill({ color: '#...
0
votes
0
answers
13
views
how to fix 'Access to XMLHttpRequest has been blocked by CORS policy' [duplicate]
i want to add Attribute Query functionality in my Web Mapping Application so i add this code in my js file , when i execute it didn't work and it's give me the following error :
index.html:1 Access to ...
1
vote
2
answers
23
views
Why do the co-ordinates change to lat lon when making WFS-T request instead of lon lat
This is my code to make a a WFS-T insert transaction
let feature_to_send = new ol.Feature({geom: commentSelector.getFeatures().item(0).getGeometry().clone().transform('EPSG:3857', 'EPSG:4326')})
...
0
votes
2
answers
98
views
Zoom to feature in WMS layer - openlayer 6
I know there are many similar questions but I can't find the answer to my problem. I want zoom to feature in my layer when click but I don't know why my code not working.
This my layer:
var view = new ...
0
votes
0
answers
38
views
Access Map Data generated by Maperative with Leaflet or OpenLayers
I am still quite new to mapping, and am trying to implement an offline-solution with either leaflet or OpenLayers (I managed to implement an online example which works). I am trying this using vue.
...
1
vote
0
answers
30
views
Why anchor does not applied to the point?
I have a feature as point. I add it into a new layer:
this.sourceLayerEdit = new VectorSource();
this.vectorLayerEdit = new VectorLayer({
source: this.sourceLayerEdit,
zIndex: 9000,
...
1
vote
0
answers
30
views
Callbacks not getting fired for simple interactions in OpenLayers
We're trying to listen for the PinchZoom interaction but we're not getting nothing in the callback.
Creating the map
this.map = new Map({
target: 'map',
layers: [
new TileLayer({
...
0
votes
1
answer
56
views
Anchoring popup position to the left of the screen in OpenLayers 6?
I have a popup when click to layer on map and popup displayed at selected position. I want to show popup to left screen. How can I do that?
This is my example to show feature in popup
var container = ...
0
votes
1
answer
26
views
Can't get OpenLayers vector layer to display (loaded by AJAX)
I can't get the vector layer (loaded by AJAX to display). Spot my error?
I confirmed the GeoJSON returned by the server is correct.
var vectorLayer;
function showMap() {
var fill = new ol.style....
1
vote
1
answer
29
views
OpenLayers - how to create 2 different colors from one color?
So I am using asArray() to create rgba color from color provided as a string. I noticed a very strange behaviour when I create two colors from same orginal string. It seems like they both reference ...
0
votes
1
answer
14
views
OL-Cesium Uncaught (in promise) SyntaxError
Trying to implement OL-Cesium as an ES6 library following instructions here: https://openlayers.org/ol-cesium/apidoc/#as-an-es6-library-recommended-method
Running locally for now and getting the ...
0
votes
0
answers
27
views
How to change scale unit with ol.control.CanvasScaleLine(), in Openlayers
I have a scale control var scaleLineControl = new ol.control.ScaleLine({}); and I can change the scale unit.
However, I would like to know if it is possible to change the unit with com var ...
0
votes
0
answers
24
views
Display raster from geoserver through openlayers using "xyz"
I'm trying to display some raster images hosted from geoserver using Openlayers. Following this example from openlayers website, it seems I could achieve it by consume the data through "xyz" ...
1
vote
0
answers
25
views
How to set click whole area of point icon?
I use cluster for points:
const clusterSource = new Cluster({
distance: this.configService.config.distanceCluster || 100,
source,
});
const clusterVector = new VectorLayer({
source: ...
0
votes
0
answers
17
views
Fit to extent but with maxResolution
I am using Open Layers 6 and are trying to fit the map to an extent with a smooth animation.
This works fine:
view.fit(extent, {
easing: easeOut,
minResolution: 1,
duration: ...
0
votes
0
answers
30
views
Layer switcher control and WMS layer control: How to set in which control you want to show the WMS layers in OpenLayers
I'm using the example http://viglino.github.io/ol-ext/examples/layer/map.wmscapabilities.html?lon=2.349572&lat=48.853266&z=16&url=http%3A%2F%2Fgeoservices.brgm.fr%2Fgeologie%3Flanguage%...
1
vote
0
answers
21
views
How to move whole icon OpenLayers
I use the style icon:
const styleIcon = {
anchorXUnits: "fraction",
anchorYUnits: "pixels",
crossOrigin: "anonymous",
anchor: [0.5, 145],
scale: 0.5,
color: &...
1
vote
1
answer
22
views
Zoom to layer after CQL in WFS format
I'm using a dropdownlist to CQL each WFS layer. How to zoom extend to the selected CQL layer?
$("#district").change(function() {
var statekod=document.getElementById("...
1
vote
0
answers
24
views
How to add a hole into passed polygon?
I use the common source and vector layer to draw polygon and cutouts inside polygons:
public features: any[] = [];
addHole(type = "Polygon", feature: Feature) {
const modify = new ...
1
vote
0
answers
19
views
How to rewrite pointer after click OpenLayers?
I have a feature as point (icon). I try to modify it and recreate a point on the map with a new coordinates position by click.
this.modify = new Modify({
hitDetection: this.vector,
features: new ...
1
vote
1
answer
46
views
Show result of only one CQL filter in OpenLayers?
I am using with OL3. I can dynamically change URL CQL WFS layer from my GeoServer but I want to know how to use map.removelayer before adding another CQL and zoom extend to selected CQL feature.
Below ...
0
votes
0
answers
26
views
How to modify pointer in OpenLayers
I get feature as point geometry:
Then I try to modify this geometry (move point):
this.modify = new Modify({
features: new Collection([feature])
});
this.mapService.map.addInteraction(this.modify);
...
0
votes
0
answers
40
views
How to unlisten an event in OpenLayers 6?
This question is similar to mine but it's not working for me.
This is an on-click function for the identifier button. This function will trigger a popup design function when the user clicks on some ...
1
vote
1
answer
18
views
Not all line strings from same coordinates rendered in OpenLayers
I am trying to make two vector lines, one is a FlowLine from ol-ext, the other is a simple LineString
function generate_line(points: number[][]){
//Copy points into new array
let array = points
...
0
votes
0
answers
30
views
How to drag icon by image not by point modify?
I use Modify object and Translate object for moving point layer:
this.source = new VectorSource();
this.vector = new VectorLayer({
source: this.source,
zIndex: 900,
style: new ...
1
vote
1
answer
29
views
Adding nominatim control from sidebar in OpenLayers?
I'm using the example
http://viglino.github.io/ol-ext/examples/search/map.control.searchnominatim.html to search with Nominatim.
I have a sidebar and I would like when I click the button in the ...
0
votes
0
answers
28
views
How to close polygon using OpenLayers
I use this code to draw polygon and measure the square. I need to close polygon after each click and continues to draw using Draw();
How can I do that?
<!DOCTYPE html>
<html>
<...