目录

Place Details Display

Use Cases

This section describes how to integrate the place details display control. This control provides you with a convenient implementation solution for displaying place details, eliminating the need to develop the map page yourself. This control also allows users to start navigation by tapping Directions or initiate a ride request by tapping the ride hailing icon next to Directions.

Figure 1 Place details

Constraints

To use this function, the following condition must be met:

API Description

Functions of this control are mainly provided by the queryLocation method in the sceneMap namespace. For more information about the APIs, please refer to API Reference.

API Description
LocationQueryOptions Parameters for querying place details.
queryLocation(context: common.UIAbilityContext, options: LocationQueryOptions): Promise<void> Queries place details.

Development Procedure

  1. Import required modules.

    import { sceneMap } from '@kit.MapKit';
    import { BusinessError } from '@kit.BasicServicesKit';
    import { common } from '@kit.AbilityKit';
  2. Create parameters for querying place details and call the queryLocation method to display the place details page.

    // Method 1: Pass siteId.
    let queryLocationOptions: sceneMap.LocationQueryOptions = {
      siteId: "922207154068557824"
    };
    // Display the place details page.
    sceneMap.queryLocation(this.getUIContext().getHostContext() as common.UIAbilityContext, queryLocationOptions)
      .then(() => {
        console.info("QueryLocation", "Succeeded in querying location.");
      })
      .catch((err: BusinessError) => {
        console.error("QueryLocation", `Failed to query Location, code: ${err.code}, message: ${err.message}`);
      });
    
    // Method 2: Pass location and name.
    let queryLocationOptions: sceneMap.LocationQueryOptions = {
      location: {
        latitude: 39.9175,
        longitude: 116.3972
      },
      name: 'The Palace Museum'
    };
    // Display the place details page.
    sceneMap.queryLocation(this.getUIContext().getHostContext() as common.UIAbilityContext, queryLocationOptions)
      .then(() => {
        console.info("QueryLocation", "Succeeded in querying location.");
      })
      .catch((err: BusinessError) => {
        console.error("QueryLocation", `Failed to query Location, code: ${err.code}, message: ${err.message}`);
      });