Openlayers bbox strategy -
i have bbox strategy 1 source of data. code looks this:
bbox: function newbboxfeaturesource(url, typename) { return new ol.source.vector({ loader: function (extent) { let u = `${url}&typename=${typename}&bbox=${extent.join(",")}`; $.ajax(u).then((response) => { this.addfeatures( geojsonformat.readfeatures(response) ); }); }, strategy: ol.loadingstrategy.bbox }); },
i works fine but... when pan/move map loader calling again , add features fit new box. there lot of duplicates because of new features same old. wanted first clear features using this.clear()
before add new features when add command loader running time , have "infinitive loop". know why? how can disable loading new features after calling this.clear()
?
edit:
my response features looks this:
{ "type": "featurecollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:epsg::3857" } }, "features": [ { "type": "feature", "properties": { "ogc_fid": "2", "name": "al" }, "geometry": { "type": "multipolygon" , "coordinates": [ [ [ ... ] ] ] } }, { "type": "feature", "properties": { "ogc_fid": "3", "name": "b" }, "geometry": { "type": "multipolygon" , "coordinates": [ [ [ ...] ] ] } } ..... , on
i've removed coordinates because there many of them.
my features generated mapserver , configured in .map file looks this:
layer name "postcode_area_boundaries" metadata "wfs_title" "postcode area boundaries" "wfs_srs" "epsg:3857" "wfs_enable_request" "*" "wfs_getfeature_formatlist" "json" "wfs_geomtype" "multipolygon" "wfs_typename" "postcode_area_boundaries" "wms_context_fid" "id" "wfs_featureid" "id" "gml_featureid" "id" "gml_include_items" "id,postarea,wkb_geometry" "gml_postarea_alias" "name" "ows_featureid" "id" "tinyows_table" "postcode_area_boundaries" "tinyows_retrievable" "1" "tinyows_include_items" "id,postarea,wkb_geometry" end type polygon status on connectiontype postgis connection "..." data "wkb_geometry postcode_area_boundaries using unique id" dump true end
to summarize discussion , answer initial question:
the features sent server need attribute called id, must unique , same feature on every request.
{type: "feature", id: "some-wfs.1234", properties: { "ogc_fid": 2, ...
see this github issue original comment of ahocevar.
in geoserver can achieved if set identifier in layer. guess there similar set in mapserver.
Comments
Post a Comment