高德地图amap.marker amap.map destory怎么用

用户名:艾贺
文章数:49
访问量:31076
注册日期:
阅读量:1297
阅读量:3317
阅读量:582351
阅读量:467021
51CTO推荐博文
&一、图层类var&layerName&=&new&AMap.TileLayer.类名layerName.setMap(map);&类名&&&&&说明TileLayer&&&&&切片图层类TileLayer.Satellite&&卫星图层类,继承自TileLayer.RoadNet&&路网图层类,继承自TileLayer.Traffic&&实时交通图层类,继承自Buildings&&&&&&3D楼块图层类IndoorMap&&&室内地图图层类ImageLayer&&&图片图层类MassMarks&&&海量麻点图层类&例如var&mass&=&new&AMap.MassMarks({anchor:new&AMap.Pixel(5,5),url:&'/theme/v1.3/markers/n/mark_b.png',&//必填参数,图标的地址cursor:’pointer’,size:&new&AMap.Size(5,&7),})mass.setMap(map)mass.setData([])&//&data:&Array&坐标数据集例:……&结合marker&=&new&AMap.Marker({content:’’,map:map})mass.on(“mouseover”,function(e){marker.setPosition(e.data.lnglat);marker.setLabel({content:e.data.name})})&参考链接:&二、调用高德地图&style&&&&&#container{&&&&&&&&width:&500&&&&&&&&height:&500&&&&}&/style&&script&type="text/javascript"&src="/maps?v=1.3&key=您申请的值&div&id=”container”&&/div&var&map&=&new&AMap.Map(‘container’,{zoom:10,center:[116,40]});&三、点标注marker&=&new&AMap.Marker({&&&&position:&provinces[i].center.split(','),&&&&title:&provinces[i].name,&&&&map:&mapObj});&3.1使用自定义标注var&marker&=&new&AMap.Marker({&&&&&&&&&&&&icon&:&'/icons/b18/1/2.png',//24px*24px&&&&&&&&&&&&position&:&provinces[i].center.split(','),&&&&&&&&&&&&offset&:&new&AMap.Pixel(-12,-12),&&&&&&&&&&&&map&:&map&&&&});但通常我们使用类来设置的,因为的大小通常和默认的大小不一致,对于使用了组合图片的开发者来说,这种方式也是最合适的,可以通过增加属性来调整图片的显示区域:&&var&icon&=&new&AMap.Icon({&&&&&&&&&&&&image&:&'/icons/b18/1/2.png',//24px*24px&&&&&&&&&&&&//icon可缺省,缺省时为默认的蓝色水滴图标,&&&&&&&&&&&&size&:&new&AMap.Size(24,24)&&&&});&&&&var&marker&=&new&AMap.Marker({&&&&&&&&&&&&icon&:&icon,//24px*24px&&&&&&&&&&&&position&:&provinces[i].center.split(','),&&&&&&&&&&&&offset&:&new&AMap.Pixel(-12,-12),&&&&&&&&&&&&map&:&mapObj&&&&});&&3.2&Icon参数详情参数名称&类型&说明size&&&Size&图标尺寸,默认值imageOffset&Pixel&图标取图偏移量。当使用了图片精灵时,可通过和配合,显示图标的指定范围image&&String&图标的取图地址。默认为蓝色图钉图片imageSize&Size&修改原始图片的大小,将拉伸或压缩图片,等同于中的&属性。可用于实现高清屏的高清效果&3.3在地图上画圆var&circle&=&new&AMap.Circle({map:map,center:["116.418757","39.917544"],&&&//圆的中心位置radius:10000,&&//表示半径的为多少米fillColor:"#ff0000",&&&//填充颜色必须为进制})650) this.width=650;" src="/ueditor/php/upload/image/3.png" title="6533.png" alt="6533.png" />&参考:四、区域搜索AMap.service('AMap.DistrictSearch',function(){//回调函数&&&&districtSearch&=&new&AMap.DistrictSearch({&&&&&level:"country",&&&&&extensions:"all",&&&&&subdistrict:3&&&&});&&&&districtSearch.search('中国&&&&&&&console.log(result)&&&&})})返回结果Object&{info:&"OK",&districtList:&Array[1]}districtList:Array[1]&&//数组内有一个元素0:Obejct&&&//数组内的元素boundaries:&&//边界center:citycodename:&"中华人民共和国districtList:Array[34]&&//34个区域,个省、个直辖市、个特别行政区、个自治区。....&依次类推650) this.width=650;" src="/ueditor/php/upload/image/7.png" title="3097.png" alt="3097.png" />650) this.width=650;" src="/ueditor/php/upload/image/6.png" title="7996.png" alt="7996.png" />&&650) this.width=650;" src="/ueditor/php/upload/image/8.png" title="4858.png" alt="4858.png" />&&District&对象属性&类型&说明name&String&行政区名称citycode&String&城市编码adcode&String&区域编码center&LngLat&城市中心点level&String&行政区划级别boundaries&Array.&Array.&LngLat&&&&extensions为“”时,行政区边界坐标集合&若行政区包含群岛,则坐标点为各岛的边界,岛间边界经纬度使用二维数组来表示districtList&&Array.&District&&下级行政区信息列表&为时,不返回该对象&返回结果中的可以直接当做来调用。4.1&画边界函数districtSearch.search('朝阳区&&&&var&bounds&=&result.districtList[0].&&&&var&polygon&=&new&AMap.Polygon({&&&&&&&&map:&map,&&&&&&&&strokeWeight:&1,&&&&&&&&path:&bounds,&&&&&&&&fillOpacity:&0.7,&&&&&&&&fillColor:&'#CCF3FF',&&&&&&&&strokeColor:&'#CC66CC'&&&&});&&&&map.setFitView();});&&amapAdcode.addPolygon&=&function(boundaries)&{//往地图上添加覆盖物&&&&if&(boundaries)&{&&&&&&&&&&&for&(var&i&=&0,&l&=&boundaries.&i&&&l;&i++)&{&&&&&&&&&&&&//生成行政区划&&&&&&&&&&&&var&polygon&=&new&AMap.Polygon({&&&&&&&&&&&&&&&&map:&map,&&&&&&&&&&&&&&&&path:&boundaries[i]&&&&&&&&&&&&});&&&&&&&&&&&&this._overlay.push(polygon);&&&&&&&&}&&&&&&&&map.setFitView();//地图自适应&&&&}};&for(var&i=0;i&res.districtList[0].boundaries.i++){polygon&=&new&AMap.Polygon({map:map,path:res.districtList[0].boundaries[i],fillOpacity:0,strokeWidth:2px})}五、高德地图服务插件AMap.service(service:Array.&service&,callback:function)服务加载方法,参数可以为服务插件中的一个或多个&AMap.Autocomplete输入提示,根据输入关键字提示匹配信息AMap.ArrivalRange公交到达圈,根据起点坐标,计算出在指定时间内能够到达的距离范围AMap.CitySearch城市查询,定位获取当前城市信息AMap.DistrictSearch行政区查询服务,提供行政区相关信息AMap.Driving驾车路线规划服务,提供起、终点坐标的驾车导航路线查询功能AMap.Geocoder地理编码与逆地理编码服务,用于地址描述与坐标间的相互转换AMap.LineSearch公交路线服务,提供公交路线相关信息查询服务AMap.PlaceSearch地点搜索服务插件,提供某一特定地区的位置查询服务AMap.RoadInfoSearch道路及道路交叉口查询服务AMap.StationSearch公交站点查询服务,提供途经公交线路、站点经纬度等信息AMap.Transfer公交换乘服务,提供起、终点公交路线规划服务,整合步行方式AMap.Walking步行导航服务,提供起、终点步行路线规划服务AMap.Weather天气查询服务,提供城市区县天气预报服务&&PlaceSearch&说明。650) this.width=650;" src="/ueditor/php/upload/image/8.png" title="1618.png" alt="1618.png" />&res.districtList[0].districtList[0].districtList[0].districtList[0]&&5.1地点搜素&&&&AMap.service(["AMap.PlaceSearch"],&function()&{&&&&&&&&&&&&placeSearch&=&new&AMap.PlaceSearch({&//构造地点查询类&&&&&&&&&&&&&&&&type:'医疗保健服务&&&&&&&&&&&&&&&&pageSize:30,&&&&&&&&&&&&&&&&city:&"010"&//城市&&&&&&&&&&&&});&&&&&&&&&&&&//关键字查询&&&&&&&&&&&&placeSearch.search('',&function(status,&result)&{&&&&&&&&&&&&&&&&if&(status&===&'complete'&&&&&===&'OK')&{&&&&&&&&&&&&&&&&&&&&res&=&&&&&&&&&&&&&&&&&&&&&console.log(result)&&&&&&&&&&&&&&&&}&&&&&&&&&&&&});&&&&&&&&});&&缺陷,一页只能显示个点。&&六、海量点MassMarks&类此类表示海量点类,利用该类可同时在地图上展示万级别的点,目前仅适用于浏览器。AMap.MassMarks(data:Array.&Object&,opts:)MassMarksOptions&&类型&说明zIndex&Number&&图层叠加的顺序值,表示最底层。默认:opacity&Float&&图层的透明度,取值范围,代表完全不透明,代表完全透明zooms&Array&&支持的缩放级别范围,默认范围,在上,取值范围为;在移动设备上,取值范围为anchor&Pixel&&必填参数,图标显示位置偏移量,以图标的左上角为基准点()点,例如:url&String&&必填参数图标的地址size&Size&&&必填参数,图标的尺寸;例如:cursor&String&指定鼠标悬停时的鼠标样式,自定义,仅支持格式,不支持自定义alwaysRender&Boolean&&表示是否在拖拽缩放过程中实时重绘,默认,建议超过的时候设置&&data:&[{lnglat:&[116..904989],&name:&i,id:1},{},&…或串,支持从服务器直接取数据本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)引用高德地图需要key这个要申请或者有使用测试key。是在页面引用这个key,才能调用高德地图进行二次开发。
1.在画地图的时候,初始化前应该申请一个“地方”用来放置地图,比如&div id=&Map&&&/div&
2.可以在页面直接添加&script&src=&/maps?v=1.2&key=yourkey&&type=&text/javascript&&&/script&脚本。也可以
在页面放一个服务器端控件,然后赋值文本,如下所示
&& & &Literal1.Text = &&script&src=&/maps?v=1.2&key=yourkey&&type=&text/javascript&&&/script&&;
然后再脚本里初始化,比如
3.&script type =&text/javascript& language = &javascript&&
& & function mapInit() {
& & & & var position = new AMap.LngLat(117.9109); //创建中心点坐标 &
& & & & var mapObj = new AMap.Map(&Map&, { center: position }); //创建地图实例 &
& & & & var opts = {
& & & & & & pov: {
& & & & & & & & heading: 270,
& & & & & & & & pitch: 0
& & & & & & },
& & & & & & position: position
& & & & };
& & & & var panorama = new AMap.Panorama('Map', opts);
& &mapInit();
4.最后根据自己的需求添加想要的功能和应用
若果与后台操作,可以用
& & &&[System.Web.Services.WebMethod]
& & & & public static string PageMethods_H()//方法
& & & & & & return &你好&;
界面代码调用&
PageMethods.PageMethods_H(so);&
本文已收录于以下专栏:
相关文章推荐
最近在做基于高德地图的定位、导航及添加大头针的功能,特此记录下来。。。方便刚接触的同学参考。。。
获取用户Key:
1.访问 http://lbs....
高德地图开发者平台:
Android 高德地图定位 SDK 是一套简单的LBS服务定位接口,您可以使用这套定位API获取定位结果(包括全球定位、辅助H5...
   
   
   
   
   
   
   
iOS系统不允许使用第三方定位,定位功能是对iOS系统定位的二次封装。通过封装,可将原始的定位点无偏差的显示在高德地图上。
1)2.3.0(含)之前版本的SDK,在iOS8中无法定...
在&官方文档&中其实已经写得很清楚了,不过我想如果是第一次碰这类东西还是容易出错的吧?而且也有一些易错点文档说得不是很清楚,那我再来简单归纳一下。
最近比较闲,所以就顺便研究高德地图,原因是之前基本上都用的百度地图,但是百度地图的代码太多了,两字,很烦。先来个效果图:
蓝色的marker就是点击的,蓝色的圆圈是我当前位置。
apk下载地址...
最近赶项目,好久没更新。抽出时间把高德地图的搜索和路径规划整理一下
项目中想加入地图功能,使用高德地图第三方,想要实现确定一个位置,搜索路线并且显示的方法。耗了一番功夫,总算实现了。一、配置工作1....
本人从事安卓开发不久,所以写的东西没什么技术含量。
现在写一些我在开发中遇到的问题吧!
关于华为手机无法定位的一些细节问题:
public EUExLocation(Context contex...
他的最新文章
讲师:汪剑
讲师:刘道宽
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)iOS 高德地图的简单使用心得
iOS 高德地图的简单使用心得
定位 搜索 附近相关信息
pod AMap2DMap
pod AMapSeaerch
pod AMapLocation#import &MAMapKit/MAMapKit.h&
#import &AMapSearchKit/AMapSearchKit.h&
#import &AMapLocationKit/AMapLocationKit.h&
@interface ViewController ()&MAMapViewDelegate,AMapSearchDelegate&
MAMapView * _mapV
AMapSearchAPI * _
AMapLocationManager * _locationM
NSString * _
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self searchPosition];
[self creatAmapView];
[self getCurrentPositionInfo];
mark -------------------根据经纬度搜索周围信息-------------------------
-(void)searchPosition{
//搜索地址获得地址附近信息
[AMapSearchServices sharedServices].apiKey = @"你申请的key";
_search = [[AMapSearchAPI alloc] init];
_search.delegate =
[self ahah];
-(void)ahah{
AMapPOIAroundSearchRequest *request = [[AMapPOIAroundSearchRequest alloc] init];
request.location = [AMapGeoPoint locationWithLatitude:26.063184 longitude:119.298224];
request.keywords = _
// types属性表示限定搜索POI的类别,默认为:餐饮服务|商务住宅|生活服务
// POI的类型共分为20种大类别,分别为:
// 汽车服务|汽车销售|汽车维修|摩托车服务|餐饮服务|购物服务|生活服务|体育休闲服务|
// 医疗保健服务|住宿服务|风景名胜|商务住宅|政府机构及社会团体|科教文化服务|
// 交通设施服务|金融保险服务|公司企业|道路附属设施|地名地址信息|公共设施
request.types = @"餐饮服务|生活服务|商务住宅";
request.sortrule = 0;
request.radius = 700;
request.requireExtension = YES;
//发起周边搜索
[_search AMapPOIAroundSearch: request];
//实现POI搜索对应的回调函数
- (void)onPOISearchDone:(AMapPOISearchBaseRequest *)request response:(AMapPOISearchResponse *)response
if(response.pois.count == 0)
//通过 AMapPOISearchResponse 对象处理搜索结果
//NSString *strCount = [NSString stringWithFormat:@"count: %ld",response.count];
//NSString *strSuggestion = [NSString stringWithFormat:@"Suggestion: %@", response.suggestion];
NSString *strPoi = @"";
for (AMapPOI *p in response.pois) {
strPoi = [NSString stringWithFormat:@"%@\nPOI: %@", strPoi, p.description];
NSLog(@"%@*%@*%@",p.description,p.name,p.address);
#pragma mark ------------------------地图的创建---------------------------
-(void)creatAmapView{
[MAMapServices sharedServices].apiKey = @"你申请的key";
_mapView = [[MAMapView alloc] initWithFrame:self.view.frame];
_mapView.showsUserLocation = YES;
[_mapView setZoomLevel:16.1 animated:YES];
_mapView.delegate =
_mapView.userTrackingMode = MAUserTrackingModeF
[self.view addSubview:_mapView];
-(void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation
updatingLocation:(BOOL)updatingLocation
if(updatingLocation)
//取出当前位置的坐标
//NSLog(@"latitude : %f,longitude: %f",userLocation.coordinate.latitude,userLocation.coordinate.longitude);
#pragma mark -----------------获得当前位置信息城市 区 街道-------------------------
-(void)getCurrentPositionInfo{
[AMapLocationServices sharedServices].apiKey = @"你申请的key";
_locationManager = [[AMapLocationManager alloc] init];
[_locationManager setDistanceFilter:kCLLocationAccuracyKilometer];
[self getCurrentAddress];
//获取当前位置信息
-(void)getCurrentAddress{
[_locationManager requestLocationWithReGeocode:YES completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {
if (error) {
NSLog(@"获取当前地址错误");
NSMutableDictionary *addressDic = [NSMutableDictionary dictionary];
[addressDic setValue:regeocode.province forKey:@"province"];
[addressDic setValue:regeocode.city forKey:@"city"];
[addressDic setValue:regeocode.district forKey:@"district"];
NSString * position = [NSString stringWithFormat:@"%@%@%@%@",regeocode.city,regeocode.district,regeocode.street,regeocode.number];
_position =
//city 市 district 区 street 街道 number
NSLog(@"%@%@%@%@",regeocode.city,regeocode.district,regeocode.street,regeocode.number);
#pragma mark --------点击地图得到点击点的坐标------------------
//点击地图获得该点击地点的经纬度
-(void)mapView:(MAMapView *)mapView didSingleTappedAtCoordinate:(CLLocationCoordinate2D)coordinate{
NSLog(@"%f,%f",coordinate.latitude,coordinate.longitude);
All the great, all from a brave start

我要回帖

更多关于 高德地图amap 的文章

 

随机推荐