openlayers-3

Open Layers 3: How to create listener for a modify interaction

守給你的承諾、 提交于 2019-11-30 22:28:35
I have managed to set up a modify interaction. The docs for ol.interaction.Modify ( http://ol3js.org/en/master/apidoc/ol.interaction.Modify.html ) don't metion a single event that is fired when a feature is modified. Unlike for instance for ol.interaction.Draw ( http://ol3js.org/en/master/apidoc/ol.interaction.Draw.html ) which works nicely. I need to update the coordinates in the database when a feature has been modified. How can I set up a listener? I found a solution. The high-level-explanation is here: http://boundlessgeo.com/2014/06/openlayers-editing-wfs-t/ Basically you don't listen to

SecurityError: The operation is insecure in canvas.toDataURL

霸气de小男生 提交于 2019-11-30 19:53:02
问题 I've tried to resolve the next error but without success. I have the following jQuery and HTML5 code: <script language="javascript" type="text/javascript"> function doExportMap() { map.once('postcompose', function(event) { var canvas = event.context.canvas; var exportBMPElement = document.createElement('a'); exportBMPElement.download = 'Mapa.bmp'; exportBMPElement.href = canvas.toDataURL('image/bmp'); document.body.appendChild(exportBMPElement); exportBMPElement.click(); document.body

OpenLayers 3: simple LineString example

喜欢而已 提交于 2019-11-30 18:17:19
i'm new to OpenLayers and i am looking for some help drawing lines on a map, i've been trying various things from various different posts about drawing LineStrings but i can't get it to work! I just need to figure out how to draw a line between to coordinates. heres some code that i tried but didn't work: var points = [ new ol.geom.Point([78.65, -32.65]), new ol.geom.Point([-98.65, 12.65]) ]; var featureLine = new ol.Feature({ geometry: new ol.geom.LineString(points) }); var sourceLine = new ol.source.Vector({ features: [featureLine] }); var vectorLine = new ol.layer.Vector({ source:

Open Layers 3: How to create listener for a modify interaction

白昼怎懂夜的黑 提交于 2019-11-30 17:11:45
问题 I have managed to set up a modify interaction. The docs for ol.interaction.Modify (http://ol3js.org/en/master/apidoc/ol.interaction.Modify.html) don't metion a single event that is fired when a feature is modified. Unlike for instance for ol.interaction.Draw (http://ol3js.org/en/master/apidoc/ol.interaction.Draw.html) which works nicely. I need to update the coordinates in the database when a feature has been modified. How can I set up a listener? 回答1: I found a solution. The high-level

ZoomToExtent OpenLayers 3

拈花ヽ惹草 提交于 2019-11-30 11:02:14
OpenLayers 2 had a very useful map.zoomToExtent(extent) feature. Is there something similar in OpenLayers 3? I can get the extent of interest with source.getExtent() , but I can't figure out how to apply that extent as a "zoom level". Going off the function sfletche linked to: var extent = source.getExtent(); map.getView().fitExtent(extent, map.getSize()); EDIT July 23, 2013 Apparently fitExtent is deprecated. Should be ol.View.fit , so something linke this (untestesd): var extent = source.getExtent(); map.getView().fit(extent, map.getSize()); With OpenLayers 4.x this is still a valid solution

Openlayers 3 Circle radius in meters

会有一股神秘感。 提交于 2019-11-30 10:22:39
How to get Circle radius in meters May be this is existing question, but i am not getting proper result. I am trying to create Polygon in postgis with same radius & center getting from openlayers circle. To get radius in meters I followed this . Running example link . var radiusInMeters = circleRadius * ol.proj.METERS_PER_UNIT['m']; After getting center, radius (in meters) i am trying to generate Polygon(WKT) with postgis (server job) & drawing that feature in map like this . select st_astext(st_buffer('POINT(79.25887485937808 17.036647682474722 0)'::geography, 365.70644956827164)); But both

How can I use an SVG image as a map marker in OpenLayers-3?

为君一笑 提交于 2019-11-30 09:22:19
I am trying to create map "pin-drops" (ie. map markers) in OpenLayers-3 (OL3) using SVG images. Currently, I am using PNG images as the pindrops that reference the ol.style.Icon source (“src”) property attribute just fine. However, this fails using an SVG image. Is there some other way to use an SVG in the same manner? Maybe by using a reference besides ol.style.Icon even? There is already a lot of built-in SVG in Open Layers so this should be possible, but I haven't found a way to get this working in OL3. Is there some other way to do this in OL3 that I should consider? Please note: we

How to add a http header to openlayers3 requests?

孤者浪人 提交于 2019-11-30 05:52:06
问题 How can I inject a http header into every map layer request? In this case, I need to send an Authentication header for a given layer and source, but I may want to send other headers too. A search of the code and docs came up with no clues. 回答1: Answered on github. By default, image loading happens like this: img.src = 'http://example.com/tile.png'; - that is, we set the src attribute of an Image to the image url. In this case, you don't have an opportunity to set the headers for the request.

Restrict Pan outside WMS extent in OpenLayers3

独自空忆成欢 提交于 2019-11-30 04:55:46
I have rectangle WMS of small area and want to restrict panning outside WMS extends, so there aren't white or black area outside the map visible at all. Adding extent to View does not work for me and in documentation about this option is written The extent that constrains the center, in other words, center cannot be set outside this extent. But as I understand this if center is in the area of extent, but on the very corner, it will show white area outside this extent, but I don't want to see white area at all. Is it possible to achieve this with OL3? Here's my solution. I wrote it just now,

OpenLayers 3: simple LineString example

ⅰ亾dé卋堺 提交于 2019-11-30 01:50:19
问题 i'm new to OpenLayers and i am looking for some help drawing lines on a map, i've been trying various things from various different posts about drawing LineStrings but i can't get it to work! I just need to figure out how to draw a line between to coordinates. heres some code that i tried but didn't work: var points = [ new ol.geom.Point([78.65, -32.65]), new ol.geom.Point([-98.65, 12.65]) ]; var featureLine = new ol.Feature({ geometry: new ol.geom.LineString(points) }); var sourceLine = new