OpenLayers

I can't display the openlayer map properly until after a window resize

蓝咒 提交于 2021-01-29 16:00:33
问题 I set up the map like this: this.map = new Map({ target: 'map', layers: [new TileLayer({source: new OSM()}) ], view: new View({ center: [0, 0], zoom: 16, }) }); On opening the page I get this: before resizing So I open the console to make the page smaller and the map is loaded: after resizing Do you have any idea how to fix it? 回答1: A bit more than a year ago I answer a similar question. Take a look at the question Angular 6 - Rendering problems if BrowserAnimationsModule imported (Openlayers

Openlayers 6 - Show Geojson Label on line

China☆狼群 提交于 2021-01-29 14:00:57
问题 I am confused about how to put a label in GeoJSON file to show on the map. I've tried many of examples from openlayers.org but they won't work. I want to show the text from properties "name" in my GeoJSON file on top of the map and along the line, like street name. Now only the line is displayed. Here's my script. <script type="text/javascript"> var style = new ol.style.Style({ text: new ol.style.Text({ font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"', placement: 'line', fill:

Different result when providing a URL and features string

女生的网名这么多〃 提交于 2021-01-29 04:43:49
问题 I am using Openlayers 4.6 and typescript. When I create a simple vectorlayer to render plain, black dots on the map, I may provide it a url like: export interface Options { features: string; url: string; text: string; font: string; textBaseline: string; fillColor: string; } ... constructor(private options: Options) { const { features, url, text, font, textBaseline, fillColor } = this.options; const format = new ol.format.GeoJSON(); this._layer = new ol.layer.Vector({ source: new ol.source

Different result when providing a URL and features string

一曲冷凌霜 提交于 2021-01-29 04:40:11
问题 I am using Openlayers 4.6 and typescript. When I create a simple vectorlayer to render plain, black dots on the map, I may provide it a url like: export interface Options { features: string; url: string; text: string; font: string; textBaseline: string; fillColor: string; } ... constructor(private options: Options) { const { features, url, text, font, textBaseline, fillColor } = this.options; const format = new ol.format.GeoJSON(); this._layer = new ol.layer.Vector({ source: new ol.source

how to get which lineString is get clicked on click on any parallel line generated from Style geometry in Openlayer

99封情书 提交于 2021-01-28 18:57:48
问题 I have generated parallel lineString on map by using Style geometry options for Single Feature Object in openlayer v5.2 with different-different width stroke after modified the found reference link on http://jsfiddle.net/CPRam/egn1kmc8/. While using geometry with call function in style function I'm not getting the geometry on single click event for the Style. So for that, I removed call function and given fixed resolution with distance for parallel. So now on 'singleclick' event, I'm able to

Using angular 7 universal with Openlayers 5

蹲街弑〆低调 提交于 2021-01-28 13:48:06
问题 I've got an angular 7.2 app using open layers 5.3. I'm trying to set up angular universal for this app, but when I run the universal server ( node dist/server.js ), I got some errors due to client only variables not being defined, such as window . webpack:///./node_modules/ol/has.js?:54 var DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1; ^ ReferenceError: window is not defined I tried using domino to mock these variables, but it just fails with another error, because of a canvas element

Openlayers 4 - Make layer invisible on feature click

纵然是瞬间 提交于 2021-01-28 11:09:48
问题 I have a map with 2 layer 's containing features (markers). I have made it so that if the map is zoomed in far enough, 1 layer will become invisible and the other will become visible (and vise versa). Like this: this.map.getView().on('propertychange', (e: any) => { if (e.key == "resolution") { if (this.map.getView().getZoom() >= 17) { exampleLayer1.setVisible (false); exampleLayer2.setVisible (true); } else if(this.map.getView().getZoom() < 17) { exampleLayer2.setVisible (false);

How to fetch the URL of specific GeoServer layer by switching radio button?

我的未来我决定 提交于 2021-01-28 07:53:20
问题 I have multiple Geoserver layers, let 3 here (Rainfall, Maximum Temperature and Minimum Temperature) The name of layer and values assigned in the radio button to switch the layers is same. As I check the radio button, I am getting the value of that specific layer but when I pass this value, I am unable to fetch the URL of that layer how to make this layer value string work in GetFeatureInfo function of Openlayers 6, to get the URL of that specific layer which we select from sidebar? Any other

typescript type definitions for Open Layers 6

孤人 提交于 2021-01-28 02:32:09
问题 The @types/openlayers package (https://www.npmjs.com/package/@types/openlayers) only supplies type definitions for OpenLayers 4.6 . This is stated explicitly at the top comment in file index.d.ts . Are types for OpenLayers 6 available and, failing that, what should be the course of action for developing Typescript applications with OpenLayers 6 ? 回答1: Take a look at @types/ol: This package contains type definitions for ol (https://github.com/openlayers/openlayers). Version 6.4.2 回答2: If I

How to project two point line on the map into a curved line OpenLayers

人盡茶涼 提交于 2021-01-27 20:14:35
问题 As for my knowledge, there is no built-in feature in OpenLayers to project the straight line of two points into curved line following the curvature of the Earth. This was a problem when I got a route that was going straight through Madagascar: Is there any solution on the frontend for this problem, any feature that I missed in OpenLayers, or is there any third-party solution to calculate this. I know that this kind of calculation is hard on the frontend, and it also depends on the resolution