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.
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!
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!
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.
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?
Fatal error : Uncaught Exception: POST request failed: file_get_contents(https://maphub.net/api/1/map/append): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
Is there something I’m missing or doing wrong here? Forgive me, I’ve not had much experience with APIs, so any help would be appreciated. It’s definitely picking the file up properly as I’ve tried echoing $filecontents.
Just an update on this - I think we’re going to go for a manual upload of a generated GeoJSON file for now because it’s only 1 group that needs replaced anyway, not the whole map. So I might not actually need this.
Might be worth adding a standard PHP solution to the API documentation in the future though - I’m sure it would be useful to some people.