openlayers-5

Setting the map as a variable in angular6/openlayers

喜欢而已 提交于 2019-12-25 02:18:11
问题 I use angular 6 and openlayers 5.1.3. I did npm install ol --save successfully and then in my angular I did import OlMap from 'ol/map'; import OlXYZ from 'ol/source/xyz'; import OlTileLayer from 'ol/layer/tile'; import OlView from 'ol/View'; import * as OlProj from 'ol/proj'; import 'ol/ol.css'; export class myComponent { olmap: OlMap; source: OlXYZ; layer: OlTileLayer; view: OlView; //other, non-ol stuff loading: boolean = false; myname: String; ngOnInit() { this.source = new OlXYZ({ url:

Displaying georeferenced images using OpenLayers 5

主宰稳场 提交于 2019-12-24 21:25:45
问题 I'm trying to make an application where the user can georeference scanned maps. You can look at an example here: https://codesandbox.io/s/2o99jvrnyy There are two images: assets/test.png - without rotation assets/test_rotation.png - with rotation The first image is loaded correctly on the map but the one with rotation is not. I can't find information on whether OpenLayers 5 can handle images with transformation parameters stored in world file . Probably I'm missing something but can't figure

How to improve performance of getFeaturesAtPixel?

风格不统一 提交于 2019-12-24 03:49:14
问题 I use the "map.getFeaturesAtPixel" method to exactly get the first feature under on a mouse-click interaction. This works as expected even though the method does not return a single feature but all the features whose graphical representation hits the clicked point. This behaviour will be "acceptable" but it turns out that its performance decreases as soon as we zoom out and lots of features are condensed and displayed like a giant mass of features... I know this is not the ideal way to

OpenLayers modify feature style without overwritting interactions style

无人久伴 提交于 2019-12-13 21:15:34
问题 Is there any way to modify a single feature's style without modifying default style on select interaction? Here is a simple piece of code showing my problem and a jsfiddle Minimal html : <input type="button" id="switcher" value="Change style"></input> <div id="map" class="map"></div> And a simple script : let vectorLayer = new ol.layer.Vector({ source: new ol.source.Vector({wrapX: false}) }); let map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.OSM({wrapX:

Dynamically change point/marker on click Openlayers 5

我是研究僧i 提交于 2019-12-13 05:08:18
问题 I am having issues trying to implement a dynamic marker in my OpenLayer Map widget. I would like that a marker/point is placed on the map "onclick". Instead of placing a new marker/point each mouse click, I would like the marker to be be refreshed on the new position. I have been trying to find some documentation on the layers/vectors and having difficulties understanding how to refresh/replace the layer... Here is my current OL code for my map that updates two inputs with the latitude and

Using OpenLayers, how can I display different icons for different features on a single layer?

不羁岁月 提交于 2019-12-11 13:25:47
问题 firstly I'm new to Openlayers/JS as a whole and fairly inexperienced with programming in general so there might be other problems with my code that I'm not aware of. I am using the latest version of Openlayers (5.3.0). My program currently passes GeoJson formatted data via Ajax to be displayed on an Openlayers map. It creates the map, view and a layer for the features to be displayed on. When I press a "Go" button on the page, the features are loaded onto the map successfully. In my case the

How to draw linestring from consecutive points of array in openlayers

杀马特。学长 韩版系。学妹 提交于 2019-12-11 10:42:16
问题 I am trying to draw LineString in openlayers with consecutive Points to give it a feel of animation like it is drawing from start to end. I tried to achieve it by following this example. All references of OL2 are converted to OpenLayers 5, but still drawing should happen one point followed by next for entire array and not at once. Find my code with current output here - my code. [For reference] This is I am trying to achieve Snake animation for leaflet. 回答1: Using only the vertices of a

Click feature on marker of open layers version 5

核能气质少年 提交于 2019-12-11 07:46:43
问题 I am using open layers library version 5. I need an onClick event on marker to do some business logic. Anybody could help me with this out thankyou. I have tried every code and snippets. I am using this library to react js. import Feature from "ol/Feature"; import point from "ol/geom/Point" import Style from "ol/style/Style"; import Icon from "ol/style/Icon"; renderMap = (lat = 24.8856802, lng = 67.0830459) => { console.log(lat, lng); this.map = new Map({ target: 'map', layers: [ new

Limit Panning OpenLayers 5

旧时模样 提交于 2019-12-10 14:27:57
问题 I'm using OpenLayers 5 for my project and wasn't able to find anything on here for that. In the past, OpenLayers has had restrictExtent , but that seems to have disappeared. Is there a way to limit or restrict the user's ability to pan vertically so that they can't drag it off the screen? I've tried using the maxExtent on both the layer containing the map and the View, and I've been able to limit what's visible by doing so on the View. I haven't been able to limit the panning, however. Any

How to add many markers with custom text to openlayers 5

梦想与她 提交于 2019-12-08 05:02:50
问题 I'm using openlayers v5.3.0, and actually loading a map with many markers (in the snippet are a small subset, in my code there are thousands). What i want to do is to customized those markers, styling them with differents colors and text. How can i customize the text and the color of each marker added to the map? var baseMapLayer = new ol.layer.Tile({ source: new ol.source.OSM() }); var map = new ol.Map({ target: 'map-canvas', layers: [baseMapLayer], view: new ol.View() }); var markers = [];