The latest version of the GIS plugin now has an API to generate static maps.
https://contrib.spip.net/GIS-4#API-de-cartes-statiques
You should use it, as it will store the images locally, in SPIP's cache.