Maps API for JavaScript Developer's Guide

Discovering Places

Maps API for JavaScript Places-related searches require:

  • a search term (a plain text word or phrase) or a category identifier (see also Categories)
  • a location or search geometry

The sections below demonstrate both types of searches.

Plain Text Searches

The following example searches for hotels in the Chinatown district in San Francisco.

The search follows the general pattern with the parameter object containing the plain text word "hotel" and the location given as a pair of geographic coordinates, 37.7942,-122.4070. To request is submitted, using the object H.places.Search. The code also shows rudimentary callback functions which.

        // Instantiate a platform object for authentication
var platform = new H.service.Platform({
  app_id: '{YOUR_APP_ID}',
  app_code: '{YOUR_APP_CODE}'

// Obtain an Explore object through which to submit search
// requests:
var search = new H.places.Search(platform.getPlacesService()),
  searchResult, error;

// Define search parameters:
var params = {
  // Plain text search for places with the word "hotel"
  // associated with them:
  'q': 'hotel',
  //  Search in the Chinatown district in San Francisco:
  'at': '37.7942,-122.4070'

// Define a callback function to handle data on success:
function onResult(data) {
  searchResult = data;

// Define a callback function to handle errors:
function onError(data) {
  error = data;

// Run a search request with parameters, headers (empty), and
// callback functions:
search.request(params, {}, onResult, onError);