高德地图JS API代码备份
来源:互联网 发布:读单词软件 编辑:程序博客网 时间:2024/05/21 18:45
根据地理位置获取经纬度并标记
单个城市
var map = new AMap.Map('container', { resizeEnable: true, zoom: 5});var places = "杭州";AMap.service('AMap.Geocoder', function () { var geocoder = new AMap.Geocoder(); infoWindow = new AMap.InfoWindow({ offset: new AMap.Pixel(0, -30) }); geocoder.getLocation(places, function (status, result) { if (status == 'complete' && result.geocodes.length) { marker = new AMap.Marker({ position: result.geocodes[0].location, map: map }) marker.content = "站点名: " + places; map.setCenter(result.geocodes[0].location); marker.on('click', markerClick); } }) function markerClick(e) { infoWindow.setContent(e.target.content); infoWindow.open(map, e.target.getPosition()); } map.setFitView();});
多个城市
var map = new AMap.Map('mapfield', { resizeEnable: true, zoom: 5});$.ajax({ url: "/home/get_cities_aqi", type: "GET", dataType: "json", timeout: 2000, success: function (data) { var index = 0; AMap.service('AMap.Geocoder', function () { var geocoder = new AMap.Geocoder(); infoWindow = new AMap.InfoWindow({ offset: new AMap.Pixel(0, -30) }); function amapGeo() { var city = data[index]; geoSearch(city); index++; } amapGeo(); function geoSearch(city) { if (index < cities.length) { setTimeout(window.amapGeo, 400); } geocoder.getLocation(city, function (status, result) { if (status == 'complete' && result.geocodes.length) { marker = new AMap.Marker({ position: result.geocodes[0].location, map: map }); marker.content = "站点名: " + city; index++; marker.on('click', markerClick); } }); } function markerClick(e) { infoWindow.setContent(e.target.content); infoWindow.open(map, e.target.getPosition()); } map.setFitView(); }); }});
0 0
- 高德地图JS API代码备份
- 高德地图 js api
- 高德地图Js API的使用
- 高德地图API
- 高德地图API
- 高德地图API
- 高德地图api
- 高德地图API
- 高德地图JS API —— 多边形搜索
- 高德地图API】从零开始学高德JS API(一)地图展现
- 初识高德地图API
- 高德地图API练习
- 高德地图API调用
- 调用高德地图Api显示地图
- 地图控件-高德地图API
- 高德地图API之定位API
- 【高德地图API】从零开始学高德JS API(六)——坐标转换
- 【高德地图API】从零开始学高德JS API(七)——定位方式大揭秘
- [CSS3] 边框 Border
- java heap out of memory分析
- Day 26: TogetherJS —— 让我们一起来编程!
- js 延时执行
- 降维中的特征选择
- 高德地图JS API代码备份
- 使用CocoaPods时提示the command path could not be resolved问题
- 精品源码,面试题,不容错过的干货!
- 【Java并发编程实战】—–“J.U.C”:CAS操作
- Android EventBus开源项目
- 应试教育堵死了孩子们犯错的道路
- android点击按钮 使alertDialong 对话框 不消失
- centos mysql 安装及配置
- 分享一个语音增强的链接