Lagi

Beberapa fitur WFS di Openlayers


Saya ingin mendapatkan beberapa fitur WFS dan mengedit

Kode saya

this.wfs = new OpenLayers.Layer.Vector("WFS-T" , { strategi: [new OpenLayers.Strategy.BBOX(), this.saveStrategy], proyeksi: new OpenLayers.Projection("EPSG:3857"), protokol : new OpenLayers.Protocol.WFS({ versi: "1.1.0", srsName: "EPSG:3857", url: "http://localhost:8080/geoserver/wfs", featureNS: "http://localhost: 8080/geoserver/mall", extractAttributes: true, featureType: ['stores' , 'store_point'], geometriName: 'geom' }) });

Tapi saya tidak bisa mengedit fitur

Pesan eror :

Jenis fitur 'toko, toko_point' tidak tersedia: 

Anda harus mengaktifkan jsonp di Geoserver Anda untuk dapat memposting kode

Untuk mengedit Anda memerlukan kode berikut:

var formatWFS = new ol.format.WFS(); var formatGML = new ol.format.GML({ featureNS: 'yourfeatureNS', featureType: 'stores', srsName: 'EPSG:3857' }); var s = XMLSerializer baru(); var sourceWFS = new ol.source.Vector({ loader: function (extent) { $.ajax('http://localhost:8080/geoserver/wfs', { ketik: 'GET', data: { service: 'WFS ', versi: '1.1.0', request: 'GetFeature', typename: 'stores', srsname: 'EPSG:3857', bbox: extent.join(',') + ',EPSG:3857' } }) .done(fungsi (respons) { sourceWFS.addFeatures(formatWFS.readFeatures(respons)); }); }, strategi: ol.loadingstrategy.bbox, proyeksi: 'EPSG:3857' }); var layerWFS = new ol.layer.Vector({ source: sourceWFS }); var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.OSM({ url: 'https://cartodb-basemaps-{ad}} .global.ssl.fastly.net/light_nolabels/{z}/{x}/{y}.png">BagikanTingkatkan jawaban inimenjawab 8 Juni '16 pukul 16:10LuffyLuffy2,0203 lencana emas13 lencana perak27 lencana perunggu


Tonton videonya: Simple WebGIS application development using Openlayers 6 and Geoserver - part1 (Oktober 2021).