by David Crowther
MapThat v6 onwards introduces the use of APIs to enhance how decorated URLs work within MapThat. The MapThat APIs combine the same parameters used by decorated URLS and also add the option to make SQL selections on the layers being called.
MapThat APIs are controlled using the config table MT_API.
The table consists of individual records that can be used to call a MapThat API, with the MT_API_GUID being the unique value for each record.
The other fields allow you to define the usual decorated URL parameters e.g. Project, Role, Tree_ID, Zoom Level, whether to filter records and zoom to extents etc…
Examples:
1 - Use a MapThat API to use parameters from the MT_API table to show the Liverpool Schools Layer and set the Zoom to 15.
The MapThat API URL, is made up of the following:
The MapThat Instance and User –
https://try.dynamicmaps.co.uk/mapthat/login.html?user=guest
And then the API ID to determine which API to use -
&mtapi=488d877d-5245-4e84-9226-8bdf51b8fae6
MapThat is then opened using the Parameters as defined in the MT_API table for that GUID:
- MT_API_GUIID - 488d877d-5245-4e84-9226-8bdf51b8fae6
- MTUSER - guest
- MTROLE - ReadOnly
- MTPROJECT – LCC
- TREEID - 14782
- UNIQUEID - NULL
- ZOOMLEVEL - 15
- Projection OS - true
- Longitude - NULL
- Latitude - NULL
- Zoom Extents - N
- Filter Records - N
- Node SQL - NULL
Changing the Parameters in the MT_API table allows you to easily configure which Layer(s) to show, the zoom level, if you wish to zoom to the extents of unique features etc… It is essentially an easier way to create a decorated URL, without having to expose all the values in the URL.
2 - Use a MapThat API to use parameters from the MT_API table to make a SQL selection from the Liverpool Schools Layer – where Status = Closed
https://try.dynamicmaps.co.uk/mapthat/login.html?user=guest&mtapi=488d877d-5245-4e84-9226-8bdf51b8fae5
In this example we are using the new parameter – Node_SQL – to filter the layer using a SQL Selection, instead of having to list the unique IDs of the features you wish to show.
- MT_API_GUIID - 488d877d-5245-4e84-9226-8bdf51b8fae5
- MTUSER - guest
- MTROLE - ReadOnly
- MTPROJECT – LCC
- TREEID - 14782
- UNIQUEID - NULL
- ZOOMLEVEL - 15
- Projection OS - true
- Longitude - NULL
- Latitude - NULL
- Zoom Extents -Y
- Filter - N
- Node SQL - select * from edubase where status = 'closed'
This time the MT API, uses the Node SQL select statement to show only the Schools where the STATUS field = ‘Closed’.
3 - Use a MapThat API to use parameters from the MT_API table to make a SQL selection from the Liverpool Schools Layer – where Status = Closed and Names begins with ‘T’
We can make the Node SQL as complex as required e.g. let’s update it to select the Schools that are closed and begin with the letter ‘T’.
- Leave the other parameters the same
- Zoom Extents -Y
- Node SQL - select * from edubase where status = 'closed' and establishment_name like 'T%'
Note – because in the MT API Table the record has a value of Y for ZoomExtents, not only does the layer filter to show the schools we selected via the Node SQL, but it also auto zooms to the extents of those features.
MapThat APIs now allow you to create your maps with more complexity. They also provide greater integration with other web applications, as the MT API records Node_SQL can be updated on the fly depending on what you wish to show in your embedded maps… e.g. show only those Land Parcels where the Interest ID = 100.
Comments (0 comments)