Listing POIs - Single

This sample shows how to get detailed information about a POI.

Organizing your code

The Getting Started section details various SDK installation options depending on your requirements. The sample code below is based on a base use case of a plain html page and the ES6 module format.

Get POI Data

Update your code to request and log data for the Earthbar POI as soon as the SDK has loaded as shown below:

<!DOCTYPE html>
<html lang="en">

	<head>
		<script type="module">

			import LMInit from 'https://maps.locuslabs.com/sdk/LocusMapsSDK.js'

			const config = {
				venueId: 'lax',
				accountId: 'A11F4Y6SZRXH4X',
				headless: true
			}

			window.LMInit = LMInit
			LMInit.setLogging(true)
			LMInit.newMap(null, config)
				.then(m => { 
        		
					m.getPOIDetails(1007).then(poi => {
					
					var poiDesc = "Name: " +poi.name +"\nID: "+poi.poiId  +"\nDescription: " +poi.description +"\nCategory: " +poi.category +"\nLocation lat: " +String(poi.position.latitude) +"\nLocation lng: " +String(poi.position.longitude) +"\nLocation floorID: " +String(poi.position.floorId) +"\nLocation ordinal: " +String(poi.position.floorOrdinal) +"\nLocation building: " +String(poi.position.structureName) +"\nAfter security: " +poi.isAfterSecurity +"\nKeywords: ";
					for (var keyword of poi.keywords) {
						poiDesc += keyword.name +", ";
					}
					
					console.log(poiDesc);

					})
        		 })
				.catch(e => console.error('Error initializing map: ', e))

		</script>
	</head>
</html>

Try it out

See a live preview (inspect the logs) or visit the fiddle.

Below is an extract of the data that will be returned in the console If you run the code above:

Name: Earthbar
Description: Earthbar offers healthy snacks, smoothies, and grab & go food options.
ID: 1007
Category: eat

Keywords: Earthbar, eat, snacks, chips, beef jerky, healthy snacks, smoothies, juice, acai bowl, grab & go, salads, sandwiches, fruit cup, eat, category:eat

Location lat: 33.941172
Location lng: -118.402012
Location floorID: lax-south-departures
Location ordinal: 3
Location building: Terminals 4-8
After security: true

Other POI Data

In addition the fields highlighted above, the POI object contains many other fields like "links", "images", "phone" and more. Some fields may not be returned for all POIs. The screenshot below shows all fields returned for a typical POI:

2818