Request: Populate group from external file

Another request! I have a feeling I know what the response will be because it would potentially open the system up to vulnerabilities - but I thought I’d ask anyway. :slight_smile:

It would be cool if a certain group (or whole map) could be updated automatically when it’s loaded, with the source file being something saved externally. What I’m thinking of is some kind of export tool from a database which would generate the appropriate GEOJSON file, and for the map to automatically read this file in to display the up-to-date data without having to manually import this file into the map (and then delete the old group) every time something needs to be updated.

Certainly the import function in MapHub makes things pretty easy, but a live link to something so there isn’t a need to continually export/import the data would be amazing!

Hi Ross,

What you are asking for is possible (or will be possible) with the MapHub API. Have a look here:
https://docs.maphub.net/api/

You can write a very simply Python script for example, which creates the GeoJSON from your database and uploads it every 5 minutes or something similar!

Zsolt

Hi Zsolt,

That’s great news, thanks! I’m not overly familiar with Python, but I’ll have a look and see what I can do with it.

I’m in the process of building a PHP/MySQL system that will hold a lot of other information about certain things and it will be great to be able to do a GeoJSON export from this and have the map pick it up automatically.

Hi Ross,

You absolutely won’t need Python for it if you are using PHP. Here is a page about how to make POST request from PHP:

Zsolt

Fantastic, thanks for that. I’m probably a few weeks away from this stage, but I’ll hopefully get on alright.

One question which I don’t think is covered by the API documentation: is it possible for a group to be inserted from an external source and for a current group to be deleted (i.e. the external data replacing the current data)? Or is it only possible to add new data and old data would have to be removed manually?

No, that’s not possible now, but I’ll add support for replace_map, which will replace the whole map’s data with whatever you give it.