Leaflet.PixiOverlay icon indicating copy to clipboard operation
Leaflet.PixiOverlay copied to clipboard

Example for adding markers dynamically

Open hokiepokedad2 opened this issue 4 years ago • 2 comments

Hello there. Is there an example in the docs on how to add or remove markers dynamically after the map and layers have been rendered? For instance, after a specified interval, I'd like to check a datasource for any changes. If a new element is added in the source, I'd like to add that as a marker to the map. Same for the inverse.

I tried looking in the docs, googling and examples but couldn't find anything. Any tips?

hokiepokedad2 avatar Feb 16 '21 03:02 hokiepokedad2

Hi @hokiepokedad2, did you succeed? I'm in the same case I don't understand how to remove the old markers.

kamilcglr avatar Feb 25 '21 17:02 kamilcglr

@hokiepokedad2

  1. create sprinte var marker = new PIXI.Sprite(markerTexture);
  2. add to Container pixiContainer.addChild(marker);
  3. to remove/hide, just set sprinte to visible=false, or visible=true opposite
  4. don't forget to call renderer.render(pixiContainer);

azzahrah avatar Mar 16 '21 02:03 azzahrah