Griffi
Griffi

Reputation: 253

Is it possible to add GIF to open layers 3 map?

I have one question. In past we just used open layers 2 and it used svg and we had some GIF markups on map (fire animations etc). Now we have open layers 3 map which use canvas to render the map. Is it now possible to still add GIF markups to the new map?

Now when I add a GIF, I just get only one "slide" from the GIF - it doesn't have animations.

What is the best way to do it? Render some SVG in canvas (how) or "refresh" the GIF element?

Thanks!

Upvotes: 2

Views: 1101

Answers (1)

Griffi
Griffi

Reputation: 253

OK, I have completed this task :-) YES - it's possible to add a GIF with motion as icon to the point on map, but it requires some JS code.

I've done it with Overlays. And the hint is precompose event, which is fired on every time when something on map has been changed (very very often).

On this event we check which Feature has an icon with .gif extension (we can flag features before when we create Features).

If has, we check that overlay with this id exist:

  1. if YES - just only change position of this overlay (coordinates of feature)
  2. if NOT - create new overlay with parameters like coordinates, id of feature. Of course also create element on map

And remember to remove redundant overlays (when points are not visible in extent, or when we change the map or hide the layer).

Upvotes: 1

Related Questions