openlayers-3

zooming in to vector layer when i click a URL

孤街醉人 提交于 2019-12-13 03:36:20
问题 I have a WFS layer in my map. I have buildings in the layer with building_id as an attribute along with other many attributes. I have coordinates too in my layer. I have a URL: http://localhost:8080/geoserver/wfs?service=wfs&version=1.0.0&request=getfeature&typename=topp:buildings&CQL_FILTER=id='bb21' How can I use this URL to zoom my map to that building? Any ideas? AJ ================updated here =============== $.ajax({ url: 'http://localhost:8080/geoserver/wfs?service=wfs&version=1.0.0

openlayers 3 annoying flash on vector.getSource().clear()

旧巷老猫 提交于 2019-12-13 03:31:48
问题 Limiting the amount of vector features displayed is important in OpenLayers, but this can lead to some features not being displayed. When moving or zooming in, it's necessary to "refresh" the features with an XHR call. In OpenLayers 2, this could be achieved by calling bboxstrategy.update({ force: true }) on a map's 'zoomend' event. In OL2 with the SVG renderer, the repaint was very smooth, hardly noticeable. In OL3, it appears necessary to call: vector.getSource().clear(); on a map's

Open Layers 3 - get vector type (line, polygon, point) from dropped in vector data

房东的猫 提交于 2019-12-13 02:22:34
问题 OpenLayers 3 has a great drag and drop feature. The example is given here: http://openlayers.org/en/master/examples/drag-and-drop.html Within the event handler for the drag and drop you can access the vector layer that has been dragged in (vectorSource) in this case: dragAndDropInteraction.on('addfeatures', function(event) { var vectorSource = new ol.source.Vector({ features: event.features }); map.addLayer(new ol.layer.Vector({ source: vectorSource, style: styleFunction })); map.getView()

Images along on a line

柔情痞子 提交于 2019-12-13 02:16:15
问题 I am wondering how to place images on a line. For example, instead of a dotted or dashed line, I could include a symbol of a ship or a character (e.g. | ) repeated along the line. My current code: line = new ol.geom.LineString([[0, 0], [100, 100]]); lineStyle = new ol.style.Style({ stroke: new ol.style.Stroke({ color: 'black', width: 5, lineDash: [10, 10] }), }); lineFeature = new ol.Feature({ geometry: line, }); lineFeature.setStyle(lineStyle); . . . map = new ol.Map({ layers: [ new ol.layer

Open Layers 3 center the map based on extent on vector layer?

China☆狼群 提交于 2019-12-12 19:17:05
问题 I want to position the center and zoom level of my map depending on the vector layer features (points). I have a geojson file which is populating my map: var vectorSource = new ol.source.Vector({ url: 'assets/js/data.geojson', format: new ol.format.GeoJSON(), projection: 'ESPG:3857' }); I now try to get the extent of the vector layer: vectorSource.once('change', function (e) { if (vectorSource.getState() === 'ready') { if (vectorLayer.getSource().getFeatures().length > 0) { map.getView().fit

How do I access a nested tag in a kml in openlayers?

ぃ、小莉子 提交于 2019-12-12 17:34:08
问题 I am trying to modify the earthquake cluster map to display some of my own data. I am running into problems when using an attribute from my KML to style it. This is a sample feature from my KML: <Placemark> <name>REIERSTAD 2 ORION DW 16-2-7-6</name> <ExtendedData><SchemaData schemaUrl="#alberta_wells"> <SimpleData name="UWI">F2/16-02-007-06W4/0</SimpleData> <SimpleData name="KeyList">0074060216F20</SimpleData> <SimpleData name="Field">0998</SimpleData> <SimpleData name="Pool">0158098<

How to style layers with SLD in OL3

穿精又带淫゛_ 提交于 2019-12-12 14:18:02
问题 It seems like not long ago in OL2 there was a nice way to style layers with SLD and it seems like now it is not possible to do the similar thing in OL3 . At least, I could not find any example on the web and in official OL3 documentation I could not find even a single reference to SLD . So, why is that and how people in real world applications store/save styles if SLD format is not supported any more? 回答1: SLD is not yet supported by OpenLayers 3. I am currently working on OpenLayers 3

How to make Stroke opacity work in OpenLayers 3

放肆的年华 提交于 2019-12-12 13:45:35
问题 I cannot get Stroke opacity working in OpenLayers 3 no matter what I try. What I try to achieve is to draw a line to OSM tile map with 0.5 opacity. Here is sample code: var lineString = new ol.geom.LineString([ [4.9020, 52.3667], [4.9030, 52.3667], [4.9040, 52.3667], [4.9050, 52.3667] ]); lineString.transform('EPSG:4326', 'EPSG:3857'); var lineLayer = new ol.layer.Vector({ source: new ol.source.Vector({ features: [new ol.Feature({ geometry: lineString, name: 'Line' })] }), style: new ol.style

How to get the extent of a GeoJSON vector source?

扶醉桌前 提交于 2019-12-12 10:41:59
问题 I have this GeoJSON file (polygon.geojson)... { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [73, 15], [83.0, 15], [83, 5], [73, 5], [73, 15] ] ] }, "properties": { "name": "Foo" } } ...and use it as vector source: var vectorSource = new ol.source.Vector({ url: 'polygon.geojson', format: new ol.format.GeoJSON(), projection : 'EPSG:4326', }); Now I want to get the extent with: var extent = vectorSource.getExtent(); The value of extent , however, is: Array [ Infinity,