### Get Overlay Options Source: https://lbs.amap.com/api/javascript-api-v2/documentation Retrieves all configuration options currently applied to the overlay. ```javascript options = overlay.getOptions(); ``` -------------------------------- ### Initialize and Search Truck Driving Route Source: https://lbs.amap.com/api/javascript-api-v2/documentation Examples demonstrating how to load the plugin, configure options, and initiate a route search between two coordinates. ```javascript var driving; mapObj.plugin(["AMap.TruckDriving"], function() { //加载驾车服务插件 var drivingOptions = { //驾车策略,包括 LEAST_TIME,LEAST_FEE, LEAST_DISTANCE,REAL_TRAFFIC policy: AMap.DrivingPolicy.LEAST_TIME }; driving = new AMap.TruckDriving(drivingOptions); AMap.Event.addListener(driving, "complete", driving_CallBack); //返回导航查询结果 //根据起终点坐标规划驾车路线 MDrive.search(new AMap.LngLat(116.379018, 39.865026), new AMap.LngLat(116.42732, 39.903752)); }); ``` ```javascript var TruckDriving; mapObj.plugin(["AMap.TruckDriving"], function() { //加载驾车服务插件 var TruckDrivingOptions = { //驾车策略,包括 LEAST_TIME,LEAST_FEE, LEAST_DISTANCE,REAL_TRAFFIC policy: AMap.TruckDrivingPolicy.LEAST_TIME }; TruckDriving = new AMap.TruckDriving(TruckDrivingOptions); AMap.Event.addListener(TruckDriving, "complete", TruckDriving_CallBack); //返回导航查询结果 //根据起终点坐标规划驾车路线 MDrive.search(new AMap.LngLat(116.379018, 39.865026), new AMap.LngLat(116.42732, 39.903752)); }); ``` -------------------------------- ### Handle Map Zoom Start Event Source: https://lbs.amap.com/api/javascript-api-v2/documentation Triggers a callback when the map zoom action begins. Requires map initialization. ```javascript // 初始化地图 const map = new AMap.Map('container',{}); map.on('zoomstart', () => { ``` -------------------------------- ### Start Marker Animation Source: https://lbs.amap.com/api/javascript-api-v2/documentation Call this method to begin the point marker's animation. This requires the AMap.MoveAnimation plugin to be loaded and a marker instance to be created. ```javascript animationMarker.startMove(); ``` -------------------------------- ### Handle Map Drag Start Event Source: https://lbs.amap.com/api/javascript-api-v2/documentation Use the 'dragstart' event to trigger actions when the user begins dragging the map. This can be used to prepare for map movement or disable other interactions. ```javascript const map = new AMap.Map('container', {}); map.on('dragstart', () => { console.log('触发开始拖拽地图时的事件'); }); ``` -------------------------------- ### Initialize AMap.ElasticMarker with Styles and Zoom Mapping Source: https://lbs.amap.com/api/javascript-api-v2/documentation Demonstrates how to initialize an AMap.ElasticMarker with custom styles and a zoom-level to style mapping. Ensure AMap.ElasticMarker plugin is loaded before instantiation. ```javascript // 样式列表 var stylesArr = [{ icon: { img: 'https://a.amap.com/jsapi_demos/static/resource/img/men3.png', size: [16, 16],//可见区域的大小 anchor: 'bottom-center',//锚点 fitZoom: 14,//最合适的级别 scaleFactor: 2,//地图放大一级的缩放比例系数 maxScale: 2,//最大放大比例 minScale: 1//最小放大比例 }, label: { content: '百花殿', position: 'BM', minZoom: 15 } }, { icon: { img: 'https://a.amap.com/jsapi_demos/static/resource/img/tingzi.png', size: [48, 63], anchor: 'bottom-center', fitZoom: 17.5, scaleFactor: 2, maxScale: 2, minScale: 0.125 }, label: { content: '万寿亭', position: 'BM', minZoom: 15 } }]; zoom 与样式的映射 var zoomStyleMapping1 = { 14: 0, // 14级使用样式 0 15: 0, 16: 0, 17: 0, 18: 1, 19: 1, 20: 1, }; // 加载灵活点标记的插件 AMap.plugin(['AMap.ElasticMarker'], function(){ var elasticMarker = new AMap.ElasticMarker({ position: [116.405562, 39.881166], // 指定样式列表 styles: stylesArray, // 指定 zoom 与样式的映射 zoomStyleMapping: zoomStyleMapping, }); map.add(elasticMarker); }); ``` -------------------------------- ### Get Driving Route Data by Coordinates Source: https://lbs.amap.com/api/javascript-api-v2/guide/services/navigation Fetch driving route details by specifying the start and end points using their longitude and latitude coordinates. The AMap.Driving plugin must be loaded beforehand. ```javascript AMap.plugin("AMap.Driving", function () { var driving = new AMap.Driving({ policy: 0, //驾车路线规划策略,0是速度优先的策略 }); var startLngLat = [116.379028, 39.865042]; //起始点坐标 var endLngLat = [116.427281, 39.903719]; //终点坐标 driving.search(startLngLat, endLngLat, function (status, result) { //status:complete 表示查询成功,no_data 为查询无结果,error 代表查询错误 //查询成功时,result 即为对应的驾车导航信息 }); }); ``` -------------------------------- ### Initialize and Configure AMap.HeatMap Source: https://lbs.amap.com/api/javascript-api-v2/documentation Demonstrates loading the HeatMap plugin, initializing the layer on a map, and setting the data points for visualization. ```javascript var heatmap; var points = [ {"lng":116.191031,"lat":39.988585,"count":10}, {"lng":116.389275,"lat":39.925818,"count":11}, {"lng":116.287444,"lat":39.810742,"count":12}, {"lng":116.481707,"lat":39.940089,"count":13}, {"lng":116.410588,"lat":39.880172,"count":14}, {"lng":116.394816,"lat":39.91181,"count":15}, {"lng":116.416002,"lat":39.952917,"count":16}, ]; // 加载热力图插件 map.plugin(["AMap.HeatMap"],function(){ // 在地图对象叠加热力图 heatmap = new AMap.Heatmap({map:map}); // 设置热力图数据集 heatmap.setDataSet({data:points,max:100}); }); ``` -------------------------------- ### Draw Bus Route Source: https://lbs.amap.com/api/javascript-api-v2/guide/services/bus This snippet demonstrates how to search for a bus route by its number and then draw its path, start, and end points on the map. It utilizes AMap.LineSearch to get route data and AMap.Marker/AMap.Polyline to visualize it. ```javascript AMap.plugin(["AMap.LineSearch"], function () { //实例化公交线路查询插件 var linesearch = new AMap.LineSearch({ city: "北京", //限定查询城市,可以是城市名(中文/中文全拼)、城市编码 extensions: "all", //是否返回公交线路详细信息,默认值为 "base" }); //执行公交路线关键字查询 linesearch.search("919", function (status, result) { //status:complete 表示查询成功,no_data 为查询无结果,error 代表查询错误 if (status === "complete" && result.info === "OK") { //查询成功时,result.lineInfo 即为公交线路详细信息 var lineArr = result.lineInfo; //循环遍历 lineArr 数组,lineArr 数组包含的是公交线路数据 for (var i = 0; i < lineArr.length; i++) { var pathArr = lineArr[i].path; //获取当前线路的路径坐标数据 var stops = lineArr[i].via_stops; //获取当前线路途径的站点数据 var startPot = stops[0].location; //获取当前线路的起始位置 var endPot = stops[stops.length - 1].location; //获取当前线路的终点位置 //作为示例,只绘制一条线路,如果当前是第一条线路(i == 0) if (i == 0) { //绘制起点,终点 new AMap.Marker({ map: map, //指定地图对象 position: startPot, //起点位置 icon: "https://webapi.amap.com/theme/v1.3/markers/n/start.png", zIndex: 10, //起点标记的 z-index 值,用于控制层次关系 anchor: "bottom-center", //起点标记的锚点位置 }); new AMap.Marker({ map: map, position: endPot, //终点位置 icon: "https://webapi.amap.com/theme/v1.3/markers/n/end.png", zIndex: 10, anchor: "bottom-center", }); //绘制乘车的路线 new AMap.Polyline({ map: map, path: pathArr, //路径坐标数据 strokeColor: "#09f", //线颜色 strokeOpacity: 0.8, //线透明度 isOutline: true, //显示轮廓线 outlineColor: "white", //轮廓线颜色 strokeWeight: 6, //线宽 }); } } //将覆盖物调整到合适视野 map.setFitView(); } }); }); ``` -------------------------------- ### Initialize and use AMap.CloudDataSearch Source: https://lbs.amap.com/api/javascript-api-v2/documentation Demonstrates loading the CloudDataSearch plugin, configuring search options, and performing a nearby search. ```javascript AMap.plugin('AMap.CloudDataSearch', function(){ var map = new AMap.Map("map", { resizeEnable: true, zoom: 12 //地图显示的缩放级别 }); var search, center = new AMap.LngLat(116.39946, 39.910829); var searchOptions = { map: map, panel: 'panel', keywords: '', pageSize: 5, orderBy: '_id:ASC' }; search = new AMap.CloudDataSearch('532b9b3ee4b08ebff7d535b4', searchOptions); search.searchNearBy(center, 1000); }); ``` -------------------------------- ### Start Text Marker Animation Source: https://lbs.amap.com/api/javascript-api-v2/documentation Starts the animation for a text marker after the AMap.MoveAnimation plugin is loaded. ```javascript animationText.startMove(); ``` -------------------------------- ### Constructor: new AMap.LabelMarker(opts) Source: https://lbs.amap.com/api/javascript-api-v2/documentation Initializes a new LabelMarker instance with the specified options. ```APIDOC ## new AMap.LabelMarker(opts) ### Description Creates a new label marker instance to be added to a LabelsLayer. ### Parameters #### Request Body - **name** (string) - Optional - Marker identifier. - **position** (Vector2 | LngLat) - Required - Marker location. - **zooms** (Vector2) - Optional - Zoom level range [2, 20]. - **opacity** (number) - Optional - Opacity, default 1. - **rank** (number) - Optional - Collision priority, default 1. - **zIndex** (number) - Optional - Display layer index, default 1. - **visible** (boolean) - Optional - Visibility, default true. - **extData** (any) - Optional - Custom user data. - **icon** (IconOptions) - Optional - Icon configuration. - **text** (TextOptions) - Optional - Text configuration. ``` -------------------------------- ### Start LabelMarker Animation Source: https://lbs.amap.com/api/javascript-api-v2/documentation Starts the animation of a LabelMarker. This method should be called after the animation has been set up using methods like moveTo or moveAlong. ```javascript animationLabel.startMove(); ``` -------------------------------- ### Initialize MarkerCluster Plugin Source: https://lbs.amap.com/api/javascript-api-v2/documentation Demonstrates how to define marker data with coordinates and weights, then initialize the cluster plugin on a map instance. ```javascript // 数据格式为一组含有经纬度信息的数组,如下所示。其中【经纬度】lnglat 为必填字段,【权重】weight 为可选字段。 var points = [ { weight: 8, lnglat: ["108.939621", "34.343147"] }, { weight: 1, lnglat: ["112.985037", "23.15046"] }, { weight: 1, lnglat: ["110.361899", "20.026695"] }, { weight: 1, lnglat: ["121.434529", "31.215641"] } ]; // 加载点聚合插件 map.plugin(["AMap.MarkerCluster"],function(){ var cluster = new AMap.MarkerCluster(map, points, { gridSize: 80 // 聚合网格像素大小 }); }); ``` -------------------------------- ### Perform GET request with AMap.WebService Source: https://lbs.amap.com/api/javascript-api-v2/documentation Use the get method to query Web Service APIs with specified parameters and a callback function. ```javascript AMap.WebService.get('https://restapi.amap.com/v3/place/text', { keywords : '首开广场', types : '写字楼', city : '010' },function (error, result) { console.log(error, result); } ); ``` -------------------------------- ### Install AMap JS API Loader Source: https://lbs.amap.com/api/javascript-api-v2/guide/abc/amap-vue Install the AMap JS API Loader package using npm. This is required for loading the AMap JS API asynchronously. ```shell npm i @amap/amap-jsapi-loader --save ``` -------------------------------- ### Initialize and Use AMap.Riding Source: https://lbs.amap.com/api/javascript-api-v2/documentation Demonstrates loading the cycling navigation plugin and performing a route search between two coordinates. ```javascript var mwalk; mapObj.plugin(["AMap.Riding"], function() { //加载步行导航插件 mwalk = new AMap.Riding (); //构造步行导航类 AMap.Event.addListener(mwalk, "complete", riding_CallBack); //返回导航查询结果 //根据起、终点坐标规划步行路线 mwalk.search(new AMap.LngLat(116.379018, 39.865026), new AMap.LngLat(116.42732, 39.903752)); }); ``` -------------------------------- ### Initialize and Search Administrative Districts Source: https://lbs.amap.com/api/javascript-api-v2/documentation Demonstrates how to load the DistrictSearch plugin, configure search parameters, and perform a search for administrative regions. ```javascript AMap.plugin('AMap.DistrictSearch', function () { var districtSearch = new AMap.DistrictSearch({ // 关键字对应的行政区级别,country表示国家 level: 'country', // 显示下级行政区级数,1表示返回下一级行政区 subdistrict: 1 }) // 搜索所有省/直辖市信息 districtSearch.search('中国', function(status, result) { // 查询成功时,result即为对应的行政区信息 }) }) // 除了获取所有省份/直辖市信息外,您可以通过修改level和subdistrict并配合search传入对应keyword查询对应信息。 ``` -------------------------------- ### Get Driving Route Data by Keyword Source: https://lbs.amap.com/api/javascript-api-v2/guide/services/navigation Use this snippet to get driving route information by providing origin and destination addresses as keywords. Ensure the AMap.Driving plugin is loaded. ```javascript AMap.plugin("AMap.Driving", function () { var driving = new AMap.Driving({ policy: 0, //驾车路线规划策略,0是速度优先的策略 }); var points = [ { keyword: "北京市地震局(公交站)", city: "北京" }, { keyword: "亦庄文化园(地铁站)", city: "北京" }, ]; driving.search(points, function (status, result) { //status:complete 表示查询成功,no_data 为查询无结果,error 代表查询错误 //查询成功时,result 即为对应的驾车导航信息 }); }); ``` -------------------------------- ### Create and open a ContextMenu Source: https://lbs.amap.com/api/javascript-api-v2/documentation Initializes a right-click context menu, adds a custom menu item with a callback function, and opens it at a specific location. ```javascript // 创建一个右键菜单实例 var contextMenu = new AMap.ContextMenu(); //右键放大 contextMenu.addItem("放大一级", function () { var zoom = map.getZoom(); map.setZoom(zoom++); }, 0); // 在地图上指定位置打开右键菜单 contextMenu.open(map, [116.397389,39.909466]); ``` -------------------------------- ### GET AMap.Weather.getLive Source: https://lbs.amap.com/api/javascript-api-v2/documentation Retrieves real-time weather information for a specified city. ```APIDOC ## GET AMap.Weather.getLive ### Description Queries real-time weather data including temperature, humidity, and wind conditions. ### Method GET ### Parameters #### Query Parameters - **city** (string) - Required - City name or area code. ### Response #### Success Response (200) - **LiveData** (Object) - Real-time weather data including weather description, temperature, wind, and humidity. ``` -------------------------------- ### Create and open an InfoWindow Source: https://lbs.amap.com/api/javascript-api-v2/documentation Initializes an information window with content and an anchor, then displays it at a specific geographic coordinate. ```javascript var infoWindow = new AMap.InfoWindow({ content: '信息窗体', anchor: 'bottom-center', }); // 在地图上打开信息窗体 infoWindow.open(map, [116.397389,39.909466]); ``` -------------------------------- ### Get Overlay Position Source: https://lbs.amap.com/api/javascript-api-v2/documentation Retrieves the current position of the overlay on the map. ```javascript position = overlay.getPosition(); ``` -------------------------------- ### Create and Animate LabelMarker with moveTo Source: https://lbs.amap.com/api/javascript-api-v2/documentation Demonstrates creating a LabelMarker and animating it to a new position using the moveTo method. Ensure the AMap.MoveAnimation plugin is loaded before use. ```javascript AMap.plugin('AMap.MoveAnimation', function(){ // 加载完 AMap.MoveAnimation 插件以后,创建一个 LabelMarker 实例 const animationLabel = new AMap.LabelMarker({ content: '标注', position: new AMap.LngLat(116.397389,39.909466), text: { content: '动画标注' } }); labelsLayer.add(animationLabel); // 调用 moveTo 方法 animationLabel.moveTo([116.397389, 39.909466], { duration: 1000, delay: 500, }); }); ``` -------------------------------- ### Text Marker Properties Source: https://lbs.amap.com/api/javascript-api-v2/documentation Methods for getting and setting properties of text markers. ```APIDOC ## Text Marker Properties ### setDraggable(draggable) Sets whether the text marker is draggable. - **draggable** (boolean) - Whether the marker is draggable. ### getTop() Gets whether the text marker is currently at the top. - **Returns**: (boolean) - True if the marker is at the top, false otherwise. ### setTop(isTop) Sets whether to bring the text marker to the top among multiple markers on the map. - **isTop** (boolean) - True to set the marker to the top, false otherwise. ### getCursor() Gets the cursor style when the mouse hovers over the text marker. - **Returns**: (string) - The cursor style. ### setCursor(cursor) Sets the cursor style when the mouse hovers over the text marker. - **cursor** (string) - The desired cursor style. ### getExtData() Gets the user-defined data associated with the text marker. - **Returns**: (any | undefined) - The user-defined data, or undefined if none is set. ### setExtData(extData) Sets user-defined data for the text marker. - **extData** (any) - The user-defined data to associate with the marker. ``` -------------------------------- ### Create a Map Instance Source: https://lbs.amap.com/api/javascript-api-v2/guide/amap-polygon/circle Initializes a 2D map with specified center, style, and zoom level. Ensure you have a valid API key. ```javascript //创建地图 var map = new AMap.Map("container", { center: [116.433322, 39.900256], //地图中心点 mapStyle: "amap://styles/whitesmoke", //地图的显示样式 viewMode: "2D", //地图模式 zoom: 14, //地图级别 }); ``` -------------------------------- ### Creating a Default InfoWindow Source: https://lbs.amap.com/api/javascript-api-v2/guide/overlays/info-window Demonstrates how to create and open a default InfoWindow with custom content. The default InfoWindow includes a close button. ```APIDOC ## Creating a Default InfoWindow ### Description This section shows how to create a default InfoWindow with customizable content and open it on the map. ### Method `AMap.InfoWindow` constructor and `open` method ### Endpoint N/A (Client-side JavaScript API) ### Parameters #### Request Body (InfoWindow Constructor) - **content** (string) - Required - The HTML content to display in the InfoWindow. - **anchor** (string) - Optional - The anchor position of the InfoWindow (e.g., 'top-left', 'center'). Defaults to 'bottom-center'. #### Request Body (open method) - **map** (AMap.Map) - Required - The map instance to open the InfoWindow on. - **position** (Array or AMap.LngLat) - Required - The geographical coordinates where the InfoWindow will be opened. ### Request Example ```javascript // InfoWindow content var content = [ "
高德软件有限公司", "电话 : 010-84107000 邮编 : 100102", "地址 : 北京市望京阜通东大街方恒国际中心A座16层
", ]; // Create an InfoWindow instance var infoWindow = new AMap.InfoWindow({ content: content.join("
"), // Concatenated DOM elements as a string anchor: "top-left", }); // Open the InfoWindow on the map infoWindow.open(map, map.getCenter()); // 'map' is the map instance, 'map.getCenter()' gets the map's center coordinates. ``` ### Response #### Success Response (200) InfoWindow is displayed on the map. #### Response Example (Visual display on the map, no direct JSON response for this action) ``` -------------------------------- ### Get Overlay Angle Source: https://lbs.amap.com/api/javascript-api-v2/documentation Retrieves the current rotation angle of the overlay in degrees. ```javascript angle = overlay.getAngle(); ``` -------------------------------- ### Get Overlay Offset Source: https://lbs.amap.com/api/javascript-api-v2/documentation Retrieves the pixel offset of the overlay from its anchor point. ```javascript offset = overlay.getOffset(); ``` -------------------------------- ### AMap.ElasticMarker Initialization Source: https://lbs.amap.com/api/javascript-api-v2/guide/amap-marker/elasticmarker This section describes how to initialize the ElasticMarker plugin, define styles, map them to zoom levels, and add the marker to the map instance. ```APIDOC ## AMap.ElasticMarker ### Description Creates a flexible point marker that changes its icon and label based on the map's zoom level. ### Parameters #### Request Body - **position** (Array/LngLat) - Required - The geographic coordinates of the marker. - **styles** (Array) - Required - An array of style objects defining icon and label properties. - **zoomStyleMapping** (Object) - Required - A mapping object where keys are zoom levels and values are indices of the styles array. ### Request Example { "position": [116.405562, 39.881166], "styles": [{ "icon": { "img": "url", "size": [16, 16], "anchor": "bottom-center", "fitZoom": 14, "scaleFactor": 2, "maxScale": 2, "minScale": 1 }, "label": { "content": "Label Text", "position": "BM", "minZoom": 15 } }], "zoomStyleMapping": { "14": 0 } } ``` -------------------------------- ### Map Container and Size Source: https://lbs.amap.com/api/javascript-api-v2/documentation Methods for getting the map container element and its size. ```APIDOC ## GET getContainer /api/map/container ### Description Gets the DOM element that contains the map. ### Method GET ### Endpoint /api/map/getContainer ### Parameters None ### Response #### Success Response (200) - **HTMLElement** - The DOM element of the map container. ### Response Example ```html
``` ## GET getSize /api/map/container ### Description Gets the dimensions (width and height) of the map container in pixels. ### Method GET ### Endpoint /api/map/getSize ### Parameters None ### Response #### Success Response (200) - **Size** (object) - An object containing the width and height of the map container. ### Response Example ```json { "size": {"width": 800, "height": 600} } ``` ``` -------------------------------- ### Initialize and Use MoveAnimation Source: https://lbs.amap.com/api/javascript-api-v2/documentation Load the AMap.MoveAnimation plugin and create a marker to animate along a custom path. Ensure the plugin is loaded before creating the marker. ```javascript const customData = [ { position: path[1], duration: 400 }, { position: path[2], duration: 600 }, { position: path[3], duration: 800 }, { position: path[4], duration: 1000 }, ]; AMap.plugin('AMap.MoveAnimation', function(){ const animationMarker = new AMap.Marker({ position: new AMap.LngLat(116.397389,39.909466), angle: 90, }); animationMarker.moveAlong(customData); }); ``` -------------------------------- ### Creating a Map Instance Source: https://lbs.amap.com/api/javascript-api-v2/guide/amap-marker/custom-marker Initializes a map instance with specified zoom level, center, map style, and view mode. ```APIDOC ## Creating a Map Instance ### Description Initializes a map instance with specified zoom level, center, map style, and view mode. ### Method ```javascript const map = new AMap.Map("container", { zoom: 10, // Map level center: [116.397428, 39.90923], // Center point of the map mapStyle: "amap://styles/whitesmoke", // Map display style viewMode: "2D", // Map mode }); ``` ``` -------------------------------- ### GET AMap.DistrictSearch.search Source: https://lbs.amap.com/api/javascript-api-v2/documentation Queries administrative region information such as city codes, boundaries, and sub-districts. ```APIDOC ## GET AMap.DistrictSearch.search ### Description Provides administrative region details including area codes, center points, and boundaries. ### Method GET ### Parameters #### Query Parameters - **keyword** (string) - Required - The name of the region, citycode, adcode, or business area. ### Request Example { "keyword": "中国" } ### Response #### Success Response (200) - **DistrictSearchResult** (Object) - Contains detailed administrative region information. ``` -------------------------------- ### AMap.Map Initialization Source: https://lbs.amap.com/api/javascript-api-v2/guide/map/englishmap Configuring the map instance with multi-language support and logo language settings. ```APIDOC ## AMap.Map Initialization ### Description Initializes the map with specific language settings for the map surface and the logo. ### Parameters #### Request Body - **languageCode** (String) - Optional - Map display language. Defaults to 'zh'. Supported: 'en', 'es', 'pt', 'fr', 'de', 'th', 'ja', 'ko', 'ar', 'tr', 'it', 'ru', 'ms', 'id', 'vi'. - **logoLanguage** (String) - Optional - Logo display language. Defaults to 'zh'. Supported: 'en'. - **viewMode** (String) - Optional - View mode, e.g., '3D' or '2D'. - **zoom** (Number) - Optional - Initial zoom level. ### Request Example { "viewMode": "3D", "zoom": 11, "languageCode": "en", "logoLanguage": "en" } ``` -------------------------------- ### Map State and Configuration Source: https://lbs.amap.com/api/javascript-api-v2/documentation Methods for getting and setting map status, cursor, and limits. ```APIDOC ## GET getStatus /api/map/status ### Description Gets the current status of the map, including whether it is draggable, zoomable, rotatable, etc. ### Method GET ### Endpoint /api/map/getStatus ### Parameters None ### Response #### Success Response (200) - **object** - An object containing the map's status information (e.g., `dragEnable`, `zoomEnable`, `rotateEnable`, `doubleClickZoom`). ### Response Example ```json { "status": { "dragEnable": true, "zoomEnable": true, "rotateEnable": false, "doubleClickZoom": true, "keyboardEnable": false } } ``` ## POST setStatus /api/map/status ### Description Sets the current status of the map, controlling features like dragging, zooming, and rotation. ### Method POST ### Endpoint /api/map/setStatus ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **status** (object) - Required - An object containing the map status values to set. ### Request Example ```json { "status": { "dragEnable": false, "zoomEnable": true, "rotateEnable": true } } ``` ### Response #### Success Response (200) No specific response body defined, typically indicates success. #### Response Example ```json { "status": "success" } ``` ## GET getDefaultCursor /api/map/cursor ### Description Gets the default mouse cursor style for the map. ### Method GET ### Endpoint /api/map/getDefaultCursor ### Parameters None ### Response #### Success Response (200) - **string** - The default mouse cursor style. ### Response Example ```json { "cursor": "default" } ``` ## POST setDefaultCursor /api/map/cursor ### Description Sets the default mouse cursor style for the map. ### Method POST ### Endpoint /api/map/setDefaultCursor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **cursor** (string) - Required - The CSS cursor style to set. Can be a standard CSS cursor value or a URL for a custom cursor. ### Request Example ```json { "cursor": "pointer" } ``` ### Response #### Success Response (200) No specific response body defined, typically indicates success. #### Response Example ```json { "status": "success" } ``` ## GET getLimitBounds /api/map/limits ### Description Gets the restricted bounding box for map panning. ### Method GET ### Endpoint /api/map/getLimitBounds ### Parameters None ### Response #### Success Response (200) - **Bounds** (object) - The bounding box that limits map panning. ### Response Example ```json { "bounds": {"northEast": {"lng": 120.0, "lat": 40.0}, "southWest": {"lng": 110.0, "lat": 30.0}} } ``` ## POST setLimitBounds /api/map/limits ### Description Sets a restricted bounding box for map panning. The map can only be panned within this area. ### Method POST ### Endpoint /api/map/setLimitBounds ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **bounds** (Bounds) - Required - The bounding box to set as the limit. ### Request Example ```json { "bounds": {"northEast": {"lng": 120.0, "lat": 40.0}, "southWest": {"lng": 110.0, "lat": 30.0}} } ``` ### Response #### Success Response (200) No specific response body defined, typically indicates success. #### Response Example ```json { "status": "success" } ``` ## POST clearLimitBounds /api/map/limits ### Description Clears the restricted bounding box for map panning, allowing the map to be panned freely. ### Method POST ### Endpoint /api/map/clearLimitBounds ### Parameters None ### Response #### Success Response (200) No specific response body defined, typically indicates success. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Get Overlay Bounds Source: https://lbs.amap.com/api/javascript-api-v2/documentation Retrieves the bounding box of the overlay, representing its geographical extent on the map. ```javascript bounds = overlay.getBounds(); ``` -------------------------------- ### Initialize AMap.DistrictLayer with default options Source: https://lbs.amap.com/api/javascript-api-v2/documentation Creates a new AMap.DistrictLayer with default settings. Use this for basic administrative boundary display. ```javascript new AMap.DistrictLayer() ``` -------------------------------- ### Get Overlay Size Source: https://lbs.amap.com/api/javascript-api-v2/documentation Retrieves the dimensions (width and height) of the overlay if a size has been explicitly set. ```javascript size = overlay.getSize(); ``` -------------------------------- ### 使用 AMapLoader.load 异步加载多个插件 Source: https://lbs.amap.com/api/javascript-api-v2/guide/abc/plugins 通过 ``` -------------------------------- ### Map View and Properties Source: https://lbs.amap.com/api/javascript-api-v2/documentation Methods for getting and setting map pitch, rotation, and zoom range. ```APIDOC ## GET getPitch /api/map/view ### Description Gets the current pitch angle of the map. ### Method GET ### Endpoint /api/map/getPitch ### Parameters None ### Response #### Success Response (200) - **Number** - The current pitch angle in degrees. ### Response Example ```json { "pitch": 45 } ``` ## POST setPitch /api/map/view ### Description Sets the pitch angle of the map. ### Method POST ### Endpoint /api/map/setPitch ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **Pitch** (Number) - Required - The desired pitch angle in degrees. - **immediately** (Boolean) - Optional - Defaults to `false`. Whether to transition immediately to the target pitch. - **duration** (Number?) - Optional - The duration of the animation in milliseconds if using animation transition. Defaults to an internally calculated dynamic value. ### Request Example ```json { "Pitch": 60, "immediately": true, "duration": 500 } ``` ### Response #### Success Response (200) No specific response body defined, typically indicates success. #### Response Example ```json { "status": "success" } ``` ## GET getRotation /api/map/view ### Description Gets the current clockwise rotation angle of the map. ### Method GET ### Endpoint /api/map/getRotation ### Parameters None ### Response #### Success Response (200) - **Number** - The current rotation angle in degrees (0 to 360). ### Response Example ```json { "rotation": 90 } ``` ## POST setRotation /api/map/view ### Description Sets the clockwise rotation angle of the map. ### Method POST ### Endpoint /api/map/setRotation ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **rotation** (Number) - Required - The desired rotation angle in degrees. - **immediately** (Boolean) - Optional - Defaults to `false`. Whether to transition immediately to the target rotation. - **duration** (Number?) - Optional - The duration of the animation in milliseconds if using animation transition. Defaults to an internally calculated dynamic value. ### Request Example ```json { "rotation": 180, "immediately": false, "duration": 400 } ``` ### Response #### Success Response (200) No specific response body defined, typically indicates success. #### Response Example ```json { "status": "success" } ``` ## GET getZooms /api/map/view ### Description Gets the range of allowed zoom levels for the map. ### Method GET ### Endpoint /api/map/getZooms ### Parameters None ### Response #### Success Response (200) - **[number, number]** - An array containing the minimum and maximum zoom levels. ### Response Example ```json { "zooms": [2, 20] } ``` ## POST setZooms /api/map/view ### Description Sets the range of allowed zoom levels for the map. ### Method POST ### Endpoint /api/map/setZooms ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **zooms** ([number, number]) - Required - An array containing the minimum and maximum zoom levels. ### Request Example ```json { "zooms": [3, 18] } ``` ### Response #### Success Response (200) No specific response body defined, typically indicates success. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Initialize AMap.DragRoute Source: https://lbs.amap.com/api/javascript-api-v2/documentation Demonstrates how to define an array of LngLat coordinates and initialize the DragRoute plugin to perform a search. ```javascript var arr = new Array();//经纬度坐标数组 arr.push(new AMap.LngLat("116.403322","39.920255")); //初始的导航起点 arr.push(new AMap.LngLat("116.420703","39.897555")); //初始的导航途经点 arr.push(new AMap.LngLat("116.430703","39.897555")); //初始的导航途经点 arr.push(new AMap.LngLat("116.410703","39.897555")); //初始的导航终点 AMap.plugin(['AMap.DragRoute'],function(){ dragRoute = new AMap.DragRoute(mapObj, arr, AMap.DrivingPolicy.LEAST_FEE); dragRoute.search(); //查询导航路径并开启拖拽导航 }); ``` -------------------------------- ### AMap.Walking Constructor Source: https://lbs.amap.com/api/javascript-api-v2/documentation Initializes the walking navigation service with configuration options. ```APIDOC ## Constructor: new AMap.Walking(opts) ### Description Creates an instance of the walking navigation service. ### Parameters #### Request Body - **map** (Map) - Optional - AMap.Map object to display results. - **panel** (string | HTMLElement) - Optional - HTML container ID or element for the result list. - **hideMarkers** (boolean) - Optional - Whether to hide start/end icons. Default: false. - **isOutline** (boolean) - Optional - Whether to show outline for the planned route. Default: true. - **outlineColor** (string) - Optional - Color of the route outline. Default: 'white'. - **autoFitView** (boolean) - Optional - Whether to automatically adjust map zoom to fit the route. ``` -------------------------------- ### AMap.RangingTool - Turn On Source: https://lbs.amap.com/api/javascript-api-v2/documentation Starts the distance measurement tool. This function activates the interactive measurement functionality on the map. ```javascript turnOn() ``` -------------------------------- ### Initialize and Use AMap.PlaceSearch Source: https://lbs.amap.com/api/javascript-api-v2/documentation Initializes the PlaceSearch plugin with specified options and performs a keyword search. Ensure the AMap.PlaceSearch plugin is loaded before use. ```javascript mapObj.plugin(['AMap.PlaceSearch'], function() { var PlaceSearchOptions = { //设置PlaceSearch属性 city: "北京", //城市 type: "", //数据类别 pageSize: 10, //每页结果数,默认10 pageIndex: 1, //请求页码,默认1 extensions: "base" //返回信息详略,默认为base(基本信息) }; var MSearch = new AMap.PlaceSearch(PlaceSearchOptions); //构造PlaceSearch类 AMap.event.addListener(MSearch, "complete", keywordSearch_CallBack); //返回结果 MSearch.search('方恒国际中心'); //关键字查询 }); ``` -------------------------------- ### AMap.WebService Source: https://lbs.amap.com/api/javascript-api-v2/documentation Provides methods to call AMap Web Service APIs using GET and POST requests. ```APIDOC ## WebService ### Description Used to call Web Service APIs, directly passing query conditions and return results. Provides GET and POST request methods. For specific interface details and return results, please refer to https://lbs.amap.com/api/webservice/summary/ ### Static Methods - **get(path: string, params: object, callback: WebServiceCallback, opts: Object? = {})**: Requests a specified Web Service API interface using the GET method. - **Parameters**: - **path** (string) - Required - The interface path of the Web Service API. - **params** (object) - Required - Query parameters for the Web Service API. - **callback** (WebServiceCallback) - Required - The callback function for the query. - **opts** (Object?) - Optional - HTTP request parameter configuration. - **Example Code**: ```javascript AMap.WebService.get('https://restapi.amap.com/v3/place/text', { keywords : '首开广场', types : '写字楼', city : '010' }, function (error, result) { console.log(error, result); } ); ``` - **post(path: string, params: any, callback: WebServiceCallback)**: Requests a specified Web Service API interface using the POST method. Currently, only the trajectory correction interface requires POST. - **Parameters**: - **path** (string) - Required - The interface path of the Web Service API. - **params** (any) - Required - Query parameters for the Web Service API. - **callback** (WebServiceCallback) - Required - The callback function for the query. - **Example Code**: ```javascript AMap.WebService.post('https://restapi.amap.com/v4/grasproad/driving', [ {"x":116.478928,"y":39.997761,"sp":19,"ag":0, "tm":1478031031}, {"x":116.478907,"y":39.998422,"sp":10,"ag":0, "tm":2}, {"x":116.479384,"y":39.998546,"sp":10,"ag":110,"tm":3}, {"x":116.481053,"y":39.998204,"sp":10,"ag":120,"tm":4}, {"x":116.481793,"y":39.997868,"sp":10,"ag":120,"tm":5} ], function (error, result) { console.log(error, result); } ); ``` ### WebServiceCallback Type Type: Function - **Parameters**: - **status** (string) - Required - The status result of the service query, 'complete' or 'error'. - **data** (any) - Required - The data returned by the Web Service API. ``` -------------------------------- ### Get Overlay Z-Index Source: https://lbs.amap.com/api/javascript-api-v2/documentation Retrieves the stacking order (z-index) of the overlay. Higher values are rendered on top. ```javascript zIndex = overlay.getzIndex(); ```