openlayers-3

Identifying if a map moveend event was user initiated

一个人想着一个人 提交于 2019-12-11 09:42:32
问题 I registered a 'moveend' event listener on my ol.Map. It's firing when the map is moved around by user input, but also when I call ol.View.setCenter and ol.View.setResolution. Is it possible to check the 'moveend' ol.MapEvent to determine if the event was triggered by user input or from manually changing the map view's properties? 回答1: I ended up doing the following. map.on('moveend', function(event) { var mapView = map.getView(), moveInitiatedProgrammatically = mapView.get(

Trying to display a GeoJSON on Openlayers 3

 ̄綄美尐妖づ 提交于 2019-12-11 08:46:07
问题 I am trying to display a geojson file on an openlayers map. The openlayers map is already working, however I cannot figure out how to display the features from the geojson file. The example on their website is unfortunately not very helpful, as it is simply the geojson object being written directly into the file and then accessed later. I wish to take the features from a separate geojson file and display them on the map. This is what I have so far, copied directly from the example: var

Openlayers3: tile grid incorrect with pixelratio=3 using Geoserver/Geowebcache as backend

China☆狼群 提交于 2019-12-11 08:35:27
问题 I'm developing a small webmap using Openlayers3 and geoserver/geowebcache as backend. My goal is to support browsers/displays with pixelratio=1, pixelratio=2 and pixelratio=3. For that I defined in geoserver backend 3 gridsets with tiles sizes 256x256, 512x512 and 768x768. I assume that: pixelratio=1 requires a gridset with tiles sizes 256x256 pixelratio=2 requires a gridset with tiles sizes 512x512 pixelratio=3 requires a gridset with tiles sizes 768x768 Now, my code is working only for

Webstorm doesn't see API

一个人想着一个人 提交于 2019-12-11 07:44:59
问题 I am using JetBrain's WebStorm to do my JavaScript coding. Honestly, I have tried other programs and truly think this may be the best coding environment for JavaScript. Unfortunately, for some reason it does not see the OpenLayers 3 class structure whatsoever. Usually, the IntelliSense in WebStorm doesn't have any trouble, but everything in this case is labelled error red because it cannot find the structure. This structure is located at: http://ol3js.org/en/master/build/ol.js. I have copied

OpenLayers - lock rotation of box or rectangle geometry while modifying

有些话、适合烂在心里 提交于 2019-12-11 07:29:52
问题 Openlayers provides useful functions for drawing boxes and rectangles and also has ol.geom.Geometry.prototype.rotate(angle, anchor) for rotating a geometry around a certain anchor. Is it possible to lock the rotation of a box/rectangle while modifying it? Using the OpenLayers example located here to draw a box with a certain rotation to illustrate the point: I would like the box/rectangle to maintain its rotation while still being able to drag the sides longer and shorter. Is there a simple

Is it possible to get pixel values from ol.source.raster on mouse over

天大地大妈咪最大 提交于 2019-12-11 05:56:42
问题 Based on the sea height eample from ol3 and mapbox global terrain we made a similar setup putting elevation values into tiles and setting up with ol.source.raster var elevation = new ol.source.TileImage({ url: penetrationUrls[this.designator.toLowerCase()], projection: newProj,// "EPSG:27700", crossOrigin: 'anonymous', tileGrid: tilegrid }); var raster = new ol.source.Raster({ sources: [elevation], operation: penetrates }); now - 1) is there any smart way to when having mouse over to query

How to get the coordinates of a polygon in OpenLayers3 on draw end

半世苍凉 提交于 2019-12-11 05:17:17
问题 I have tried to add a click handler to the map, but am not sure how to tell when the polygon has finished drawing. Is there a simple function to get the polygon coordinates on draw end ? 回答1: You can probably adapt https://stackoverflow.com/a/24835176/228885 for your purposes. As mentioned in another answer feature.once('change', ...) might be another way to go. I expect in that case you would pick the last element from the feature passed to the handler. Then you would extract the coordinates

Changing cursor on drag in openlayers 3

烈酒焚心 提交于 2019-12-11 05:03:58
问题 What are the proper way of changing the cursor when user is dragging the map. Below example is not that good as it only triggers when pointerdrag starts the drag and then change it back after no events for 125ms. Is there any other way? var timer = null; this.map().on("pointerdrag",() => { this.map().getViewport().style.cursor = "-webkit-grabbing"; clearTimeout(timer); timer = setTimeout(() => this.map().getViewport().style.cursor = "-webkit-grab", 125); }); 回答1: What about listening to

OpenLayers 3 hasFeatureAtPixel filter for layer

佐手、 提交于 2019-12-11 04:22:23
问题 I am attempting to create a mouse hover event using the following method taken from the official OL3 examples page: http://openlayers.org/en/latest/examples/earthquake-clusters.html I need to trigger the action only when hovering over a particular layer. Having consulted the official documentation I discovered that you can use a layer filter function with hasFeatureAtPixel, but it doesn't appear to be working. map.on('pointermove', function(evt) { if (evt.dragging) { return; } var pixel = map

Openlayers3: Abort the Draw Interaction

天大地大妈咪最大 提交于 2019-12-11 03:49:45
问题 i am using for my html a draw interaction for drawing routes manually // manual route creation event $('#createRoute').click(function() { // remove previous interactions map.removeInteraction(draw); // create linestring interaction draw = new ol.interaction.Draw({ source: routeSource, type: ('LineString'), }) // add interaction to map map.addInteraction(draw); draw.on('drawstart', function(event) { console.log("Map Interaction(Route): activated"); }); draw.on('drawend', function(event) {