Sunday, 15 March 2015

How can I remove a single overlay in Openlayers 3.3.0? -


I am creating the overlay in my mapping application so that I need to refresh every 5 seconds. I'm having difficulty deleting the barbed overlay from your map using the I map.removeOverlay method is not working properly Only after some iterations the overlay stacking is clearly clear.

Using map.getOVerlays (). Clear () removes the barrier overlay, however, it removes all the overlays that are not desired. Any help with this is appreciated.

  window.setInterval (function () {$ .ajaxSetup ({mimeType: "text / plain"}); $ .getJSON ('json / data.json', function (data) { $ .each (data.itm, function (key, val) {var storeName = this.name; var storeLocation = this.location; var storeLatitude = this.latitude; var storeLongitude = this.longitude; $ .each (val.tasks , Function (i, j) {var function name = this.name; var workstate = this.state; if (workspace == "Open") {var Task Gemetry = ol.proj.transform ([storeLongitude, StoreLatitude], 'EPSG : 4326 ',' EPSG: 3857 '); Crack overlay (position) {var elem = document.createElement (' div '); elem.setAttribute (' class', 'circleOut'); New Ol.Overlay back {Element: elem, status: position, status: 'cen ter-s Printers'});} Var Task overlay = Bnaaakrakot overlay (Task Zimetry); map.removeOverlay (taskOverlay); map.addOverlay (taskOverlay);}});});});}, 5000);  

var taskover = createkarchautomatore (task geometry); Map.removeOverlay (taskOverlay);

The problem is that you are trying to delete the old overlay, not the old one. You need to store a reference for the overlay so that the open layer can be removed from the map. Something like this:

  var current overlay = zero; Window.setInterval (function () {$ .ajaxSetup ({mimeType: "text / plain"} ... // if (currentOverlay === faucet) {map.removeOverlay (current overlay);} turnover = createCircleOutOverlay (task geometry ); Map.addOverlay (current overlay); // ...  

No comments:

Post a Comment