Maps API for JavaScript Developer's Guide


Searching for and exploring places in a location-aware manner are common features of location-based applications. With the Maps API for JavaScript, you can search for places using plain text or pre-defined categories and a location. The search results may include information such as place names, addresses, contact details, location maps, ratings, reviews, and related premium content. Search requests can specify that only results within specific areas be included in responses.

To support searching for and exploring places, load the Places module (mapsjs-places.js).

When you combine this module with Maps API for JavaScript maps and markers, you can create powerful applications that help users find places of interest to them. The examples below cover the following basic scenarios:
  • searching for a place in a specific location based on associations with a plain text word
  • searching for places matching a category in a specific location, with information on how to limit the search to a specific area
  • paginating the information in the response to make the information more usable in the application
  • getting additional details about a specific place
  • restricting the search results included in the response to the map area displayed on the user screen
  • using the user location to search for places matching a category
  • listing the categories available for a given location

Searching for and Exploring – General Implementation Pattern

To implementn requests for places-related information:

  1. Load the Places module (mapsjs-places.js).
  2. Create a Platform object for authentication (if you have not done so earlier) – note that the examples below use a demonstration credentials and access the customer integration testing (CIT) environment, rather than the production environment.
  3. Create the appropriate Places object through which you can submit requests.
  4. Create an object that defines the search parameters – the names of the parameters match the names of the parameters used in the HERE Places API
  5. Submit a search request – requests are asynchronous, therefore callbacks are needed to act on both success and error responses.
  6. Handle the response data – define callback functions that receive and process both the data received on success and when an error occurs.