How to display data on a map
We provide a list of all locations matching search parameters at /v2/locations. Within the item array in the response are objects such as the following:
{ "geo": { "type": "GeoCoordinates", "latitude": 51.497063, "longitude": -0.221201 }, "name": "Brook Green Tennis Club", "type": "Place", "address": { "type": "PostalAddress", "postalCode": "W6 7BD", "addressRegion": "Middlesex", "streetAddress": "Brook Green", "addressCountry": "GB", "addressLocality": "LONDON" }, "identifier": "f1cd4dcf-dae1-430f-bc5c-4c26aa8759a3", "amenityFeature": [], "potentialAction": [ { "type": "TravelAction", "distance": { "type": "QuantitativeValue", "value": 1.508, "unitCode": "KMT" } } ], "imin:event": { "type": "Collection", "id": "https://search.imin.co/v2/sessions?location.geo[radial]=51.497063,-0.221201,0&subEvent.startDate[lte]=2018-09-17T10:45:59Z&sort=location.geo,nearest", "totalItems": 3 }}Breakdown of fields
-
geo: this object contains the coordinates for placing a pin on the map -
imin:event: this Collection identifies all sessions available at the location- id: a URL returning all available sessions at the location- totalItems: the number of available sessions at the location -
potentialAction: a TravelAction provides information on the distance in kilometres from the search coordinates to the location
Ways to attach a URL to a pin
The URL for returning all sessions at a location is accessible at [imin:event].id and can be used in different ways according to your UI preferences. Two suggestions are:
- use the URL as a link so that clicking the pin opens a new window displaying your search page with the relevant results
- send an AJAX request to the URL when the user hovers over/clicks on the pin in order to populate a popover with results, making sure to send this via your server in order to protect your API key
Similarly the number of total sessions could be displayed in a popover by drawing the number from [imin:event].totalItems.