SuperAPI AI Directory

baidu-map-android-sdk

Coding & development

View repository

Updated 10-15 17:24

About this skill

Baidu Maps Android SDK

Goals and Boundaries

  • Goals: Correctly integrate the Baidu Maps SDK in an Android project, and provide an implementation solution that complies with privacy, AK, and coordinate system specifications.
  • Responsible for: Map display, MapView lifecycle, overlays, POI/route/geocoding search, walking and cycling navigation, etc.; refer to the references within the skill.
  • Not responsible for: Server-side logic, non-Baidu SDKs, UI visual design.

When to Use

Enable this skill when any one of the following is met:

  • Keywords: Baidu Maps Android, MapView, BaiduMap, AK, route planning, POI search, walking and cycling navigation, BD09, coordinate type
  • Requirement types: map display, positioning, markers and overlays, POI/place search, route planning and drawing lines, walking/cycling real-time navigation, geocoding

Load on demand: First, based on the requirement, select a document from reference.md , then reference the corresponding references content; if the requirement is vague, first clarify with the userbefore giving a solution。

Rules that must be followed

  1. Privacy and initialization (v7.5.0+)

    • Before calling any SDK interface, the privacy compliance interface must be called first, andmust be SDKInitializer.initialize beforecalled. See overview.md the privacy compliance subsection.
    • In Application:SDKInitializer.initialize(this); available since 4.3.0 SDKInitializer.setCoordType(CoordType.BD09LL) or CoordType.GCJ02。
  2. AK and configuration

    • Before use, apply for an Android SDK key (AK) in the console, select "Android SDK" as the application type, and fill in the package name and SHA1. Configure the AK in AndroidManifest or SDKInitializer.setApiKey; the package name and signature must match those applied for. See overview.md。
  3. MapView lifecycle

    • The Activity's onResume/onPause/onDestroy must respectively call mMapView.onResume()、mMapView.onPause()、mMapView.onDestroy(). See mapview.md。
  4. Coordinate system

    • Domestically defaults to BD09LL; can be unified with GCJ02 via SDKInitializer.setCoordType . When mixed with positioning, keep consistent with the positioning SDK coordinate type; for conversion see coordinate.md。
  5. Search and routing

    • Listener before request: first setOnGetPoiSearchResultListener then searchNearby , etc.; first setOnGetRoutePlanResultListener then drivingSearch , etc., otherwise callbacks may not be received. After use, destroy() release the instance.
  6. Versions and APIs are based on the project

    • When the user has already integrated the SDK, base it on the actual device/project version. If a certain class or methoddoes not exist(compile error or no such symbol in dependencies),prompt the user to update the corresponding dependency to a compatible versionand then retry; do not force writing non-existent APIs.
  7. Walking and cycling: distinguish by requirement

    • Route planning (route calculation + line drawing): RoutePlanSearch (driving/walking/cycling/transit); after obtaining the route, draw the polyline yourself or use an open-source Overlay. See route.md。
    • Walking/cycling real-time navigation: Walking/cycling navigation engine, guidance, TTS, off-route correction, etc. For classes, see overview.md and class-reference.md。
    • The two aredifferent services: if you only need to draw lines, use route; if you need real-time guidance/TTS, use walking/cycling navigation. Before giving a solution, first choose the correct document according to the developer's needs.

Output specifications (evaluable)

  • Actionable: includes specific class names, methods, call order, and necessary configuration (AndroidManifest, Application, AK, privacy).
  • Verifiable: privacy and AK are explicit; retrieval/route listening order is correct; if positioning/authentication failure is involved, the solution can point to the troubleshooting items of location.md or project-config.md .
  • Composable: according to reference.md , choose documents and common combinations. When there are no special requirements, the UI and interaction follow ui-standards.md。

Solution structure: requirements → corresponding documents → configuration and dependencies → key APIs → example snippets → notes.

Reference index

  • Choose documents and common combinations by requirement:reference.md
  • Gradle integration (dependencies, conflicts, NDK, environment and domestic mirrors):gradle.md
  • AndroidManifest, themes, obfuscation, integration experience and common issues:project-config.md
  • Integration, AK, privacy, lifecycle, core classes:overview.md
  • Map container, types, levels, method interaction:mapview.md
  • Display location, location mode, custom icons:location.md
  • Point markers, Marker attributes and events:marker.md
  • Polylines, polygons, Polyline attributes:overlays.md
  • POI, geocoding, reverse geocoding:search.md
  • Route planning and Overlay:route.md
  • Coordinate conversion and coordinate systems:coordinate.md
  • Distance/area, point and shape relationships, launching maps, short address sharing:tools.md
  • Error codes:errorcode.md
  • Class and package quick reference:class-reference.md
  • UI and interaction conventions for retrieval/routes/point selection/pop-ups/Logo, etc.:ui-standards.md