openlayers-3

Ensuring all tiles are loaded in Open Layers 3 XYZ source

こ雲淡風輕ζ 提交于 2019-12-04 03:03:38
问题 We have some layers that make use of a ol.source.XYZ source. For the loading strategy we use ol.loadingstrategy.tile(new ol.tilegrid.createXYZ({})) . We need to ensure that all tiles have been completely loaded in the map view before proceeding with other operations. We have come across multiple articles regarding this and haven't found a 100% solution yet that will give us the solution we need. The logic returns true even when it's not the case. We've tried to make use of the tileloadstart,

Check if a point is inside polygon in OpenLayers 3

匆匆过客 提交于 2019-12-04 02:43:46
When I draw a polygon in an OpenLayers map, I want to know if the marker is inside the polygon or not. I searched in the OpenLayers API, but didn't find a solution. And you can see my full code in this link . I have the impression that I have to modify this function: function addInteraction() { var value = typeSelect.value; if (value !== 'None') { draw = new ol.interaction.Draw({ source: vectorSource, type: /** @type {ol.geom.GeometryType} */ (typeSelect.value) }); map.addInteraction(draw); draw.on('drawend',function(e){ //Here }); } } How can I do this? FatAl You have a method '

Display WFS layer in ol3

只愿长相守 提交于 2019-12-03 21:29:50
I'm working with geoserver and openlayers 3, i have a hosted layer in geoserver that i want display using ol3 as a wfs layer. it doesn't show any errors, but i dont get the map. it works with wms, but not wfs. I'm using wamp server to host my application. Please can anyone help me to fix that? This is my code : var v=new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.WFS({ version: '1.1.0', url: 'http://localhost:8080/geoserver/wfs', featurePrefix: 'opengeo', featureType: 'comgeo', featureNS: 'http://localhost:8080/opengeo', geometryName: 'geom' }) }) }); var map = new

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

冷暖自知 提交于 2019-12-03 19:28:49
问题 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

Performance test OpenLayers vs Leaflet

ⅰ亾dé卋堺 提交于 2019-12-03 17:39:21
问题 I would like to compare the performance between OpenLayers and Leaflet. I want to test things like which is the fastest to render vector files, basemaps, show a massive amount of markers etc. I can set up this examples myself, but I don't how to actually measure the difference in speed between them? Where can I see how long it actually takes to perform a task like loading the vector data into a map? I tried to use the 'Timeline' tab in Chrome under developper console but it's not that clear

Javascript editing WFS from GeoServer using OpenLayers

天大地大妈咪最大 提交于 2019-12-03 17:22:05
After reading a very good tutorial on how to edit WFS with OpenLayers , I've tried replicating it but with my own WFS layer from Geoserver. Need some Javascript help finding what's wrong with it. I managed to load the WFS and my basemap successfully and managed to get the buttons to show up. The buttons appear correctly like in the working example from that page but, for some reason the geometry data isn't being saved. Every time a user draws something, a new id is created on the table but its associated geometry column is left empty The bit for posting is: var formatWFS = new ol.format.WFS();

Openlayers 3: add text label to feature

时间秒杀一切 提交于 2019-12-03 14:14:53
I have the current set up here: fully functional fiddle example and whilst I have managed to zoom to each polygon feature I would also like to display a centralised text label on each... the field_title variable found within the get_fields method. I have no idea how to do this and all my googling has come up with this article: http://openlayers.org/en/v3.3.0/examples/vector-labels.html which I find totally confusing as I'm a little new to OL! To add a text to ol.Feature you will store the description in the feature and set a style that is a style function (that will get the description from

How to get a layer from a feature in Openlayers 3?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 11:58:54
I can't find a way to go from a feature in a selection event to a layer that it may be a part of without traversing all the features of all my map layers, or storing an artificial layer ID within every feature at creation. Is this just not possible yet? ol.js 3.7.0 ol.interaction.Selection -> click -> callback( event ){ event.selected[0] } In another part of my app, I would like to go from the feature to the layer to determine the style being used on the feature, specifically whether or not it's visible. ol.Feature.getStyle() || ol.Feature -> (layer?) -> getStyle() You could try with the

Convert point to lat lon

混江龙づ霸主 提交于 2019-12-03 09:01:09
问题 I wonder, how can I get map click event's coordinates as lat,lon? Here is my code: map.on('click', function(evt) { var element = popup.getElement(); var coordinate = evt.coordinate; var latLon = ol.proj.transform(coordinate, 'EPSG:3857', 'EPSG:4326'); $(element).popover('destroy'); popup.setPosition(coordinate); Normally, coordinate value gives me an array etc: [48654.02545, 3265468.45455] But I need lat lon etc:([39,54876,32,547821]) Abstract: I need to convert epsg:3857 coordinate to epsg

OpenLayers. How to refresh cluster?

China☆狼群 提交于 2019-12-02 23:28:27
问题 I dynamically add features to my cluster, however, as far as I can see clustering does not work. My layer is defined like so: var source = new ol.source.Vector({}); var cluster = new ol.source.Cluster({ distance: 10, source: source }); var style = new ol.style.Style({ fill: new ol.style.Fill({ color: "rgba(255,150,0,1)" }), stroke: new ol.style.Stroke({ color: "rgba(255,150,0,1)", width: 1 }), image: new ol.style.Circle({ radius: 1, fill: new ol.style.Fill({ color: "rgba(255,150,0,1)" }) }),