name: tianditu-skill description: Comprehensive guide and tools for developing with Tianditu (Sky Map) API. Use this skill when the user wants to integrate maps, geocoding, path planning, or other GIS features using Tianditu services.
Tianditu Skill
Overview
This skill provides documentation, code patterns, and templates for building applications with the Tianditu (天地图) JavaScript API v4.0. It covers map initialization, overlays, event handling, and web services like geocoding and driving directions.
When to Use
Use this skill when the user asks to:
- "Show a map" using Tianditu.
- "Get coordinates for an address" (Geocoding).
- "Plan a route" (Driving/Walking).
- "Show a 3D map" or "Add 3D markers".
- "Add markers or polygons" to a map.
- "Switch between Vector and Satellite maps".
- "Convert coordinates" between GCJ02/BD09 and Tianditu.
Workflow
- Setup: Ensure the user has an API Key (tk). Refer to Guide.
- Implementation:
- For basic map display, use the template in
assets/map_template.html. - For 3D map display, use the template in
assets/map_3d_template.html. - For adding markers/shapes, see API Reference.
- For search/routing, see Services.
- For basic map display, use the template in
Resources
Documentation
- Developer Guide: Quick start, API Key, Basic Map.
- API Reference: Core Classes (
T.Map,T.Marker,T.LocalSearch, Traffic). - 3D API Reference: 3D Map Classes (
T.Map3d,T.Marker3d). - Services Reference: Geocoding, Driving Route.
- Server-Side Examples: Node.js/Python integration.
- Testing Guide: Strategies for Unit and Integration testing.
Assets & Tools
- Map Template: A complete HTML5 starter file.
- 3D Map Template: Starter for 3D globe.
- TypeScript Definitions: Type definitions for
Tnamespace. - Coordinate Utils: Conversion between WGS84, GCJ02, BD09.
Quick Snippets
Initialize Map
var map = new T.Map("mapDiv");
map.centerAndZoom(new T.Lnglat(116.40969, 39.89945), 12);
Add Marker
var marker = new T.Marker(new T.Lnglat(116.40969, 39.89945));
map.addOverLay(marker);
Geocoding
var geocoder = new T.Geocoder();
geocoder.getLocation(lnglat, function(result){ ... });