1. 程式人生 > >iOS高德地圖定位.自定義標註.搜尋.分類展示(排版)

iOS高德地圖定位.自定義標註.搜尋.分類展示(排版)

一.先前準備

4.0 .jpg4.0 .jpg

這就是公司的需求,上面欄目點選重新整理地圖標註,類目二根據類目一的變化而變化,標註可點選進個人資料,點選下單也可跳轉.

1.0.png1.0.png

1.2).在用到的vc匯入,還有遵循協議<MAMapViewDelegate>,這裡還要謝謝簡書一位仁兄,因為最後兩個檔案我也是參考他的

1.1.png1.1.png

二.上程式碼 2.1).先定義一些需要用到的小寶寶

1.2.png1.2.png

2.2).viewDidLoad裡的幾個方法

1.4.png1.4.png

實現這幾個方法:

2.2.1).- (void)initMapView

{

[AMapServices sharedServices].apiKey = @"你的key";

self.mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, 64+60, CGRectGetWidth(self.view.bounds), self.view.bounds.size.height-64-60)];
self.mapView.delegate = self;
self.mapView.showsCompass = NO;
self.mapView.showsScale = NO;
self.mapView.zoomLevel = 17;
self.mapView.showsUserLocation = YES;

[self.view addSubview:self.mapView];
self.isLocated = NO;
}

2.2.2).- (void)initSearch

{

self.searchPage = 1;

//c6375c001facf8ec415c6b087ba4a364

[AMapServices sharedServices].apiKey = @"你的key";

self.search = [[AMapSearchAPI alloc] init];

}

2.2.3).- (void)initRedWaterView

{

self.redWaterView = [[UIView alloc]initWithFrame:CGRectMake((kScreenWidth-60)/2, self.mapView.bounds.size.height/2-50, 60, 60)];

self.redWaterView.center = CGPointMake(CGRectGetWidth(self.view.bounds) / 2, CGRectGetHeight(self.mapView.bounds) / 2 - CGRectGetHeight(self.redWaterView.bounds) / 2);

self.redWaterView.backgroundColor = kAppClearColor;

UIImage *image = [UIImage imageNamed:@"
[email protected]
"]; UIImageView *ImageV = [[UIImageView alloc]initWithFrame:CGRectMake((60-image.size.width)/2, 30, image.size.width, image.size.height)]; ImageV.image = image; UIButton *BTn = [UIButton buttonWithType:UIButtonTypeCustom]; BTn.frame = CGRectMake(0, 0, 60, 25); BTn.layer.cornerRadius = 10; BTn.layer.masksToBounds = YES; BTn.backgroundColor = kAppGoodColor; [BTn setTitle:@"點選下單" forState:UIControlStateNormal]; [BTn setTitleColor:kAppWhiteColor forState:UIControlStateNormal]; BTn.titleLabel.font = [UIFont systemFontOfSize:13]; [BTn addTarget:self action:@selector(AddOrder:) forControlEvents:UIControlEventTouchUpInside]; [self.redWaterView addSubview:BTn]; [self.redWaterView addSubview:ImageV]; [self.view addSubview:self.redWaterView]; } 2.2.4).- (void)initLocationButton //這是左下角的定位按鈕 { self.imageLocated = [UIImage imageNamed:@"
[email protected]
"]; self.imageNotLocate = [UIImage imageNamed:@"[email protected]"]; self.locationBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetWidth(self.mapView.bounds)*0.8+10, CGRectGetHeight(self.mapView.bounds)*0.8+64, 40, 40)]; self.locationBtn.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; self.locationBtn.backgroundColor = [UIColor colorWithRed:239.0/255 green:239.0/255 blue:239.0/255 alpha:1]; self.locationBtn.layer.cornerRadius = 3; [self.locationBtn addTarget:self action:@selector(actionLocation) forControlEvents:UIControlEventTouchUpInside]; [self.locationBtn setImage:self.imageNotLocate forState:UIControlStateNormal]; [self.view addSubview:self.locationBtn]; }

2.3).一些協議方法和自己定義的方法

/* 移動視窗彈一下的動畫 */

- (void)redWaterAnimimate

{

[UIView animateWithDuration:0.5

delay:0

options:UIViewAnimationOptionCurveEaseOut

animations:^{

CGPoint center = self.redWaterView.center;

center.y -= 20;

[self.redWaterView setCenter:center];}

completion:nil];

[UIView animateWithDuration:0.45

delay:0

options:UIViewAnimationOptionCurveEaseIn

animations:^{

CGPoint center = self.redWaterView.center;

center.y += 20;

[self.redWaterView setCenter:center];}

completion:nil];

}

#pragma mark - Utility

/* 根據中心點座標來搜周邊的POI. */

- (void)searchPoiByCenterCoordinate:(CLLocationCoordinate2D )coord

{

AMapPOIAroundSearchRequest*request = [[AMapPOIAroundSearchRequest alloc] init];

request.location = [AMapGeoPoint locationWithLatitude:coord.latitude  longitude:coord.longitude];

request.radius  = 500;//自己定義搜尋半徑

request.sortrule = 1;

request.page    = self.searchPage;

[self.search AMapPOIAroundSearch:request];

}

- (void)searchReGeocodeWithCoordinate:(CLLocationCoordinate2D)coordinate

{

AMapReGeocodeSearchRequest *regeo = [[AMapReGeocodeSearchRequest alloc] init];

regeo.location = [AMapGeoPoint locationWithLatitude:coordinate.latitude longitude:coordinate.longitude];

regeo.requireExtension = YES;

[self.search AMapReGoecodeSearch:regeo];

}

#pragma mark - MapViewDelegate

- (void)mapView:(MAMapView *)mapView regionDidChangeAnimated:(BOOL)animated

{

if (!self.isMapViewRegionChangedFromTableView && self.mapView.userTrackingMode == MAUserTrackingModeNone)

{

[self searchReGeocodeWithCoordinate:self.mapView.centerCoordinate];

[self searchPoiByCenterCoordinate:self.mapView.centerCoordinate];

self.searchPage = 1;

[self redWaterAnimimate];

}

self.isMapViewRegionChangedFromTableView = NO;

}

#pragma mark - userLocation

- (void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation updatingLocation:(BOOL)updatingLocation

{

if(!updatingLocation)

return ;

if (userLocation.location.horizontalAccuracy < 0)

{

return ;

}

// only the first locate used.

if (!self.isLocated)

{

self.isLocated = YES;

[self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(userLocation.location.coordinate.latitude, userLocation.location.coordinate.longitude)];

NSLog(@"latitude : %f,longitude: %f",userLocation.location.coordinate.latitude, userLocation.location.coordinate.longitude);

}

}

- (void)mapView:(MAMapView *)mapView  didChangeUserTrackingMode:(MAUserTrackingMode)mode animated:(BOOL)animated

{

if (mode == MAUserTrackingModeNone)

{

[self.locationBtn setImage:self.imageNotLocate forState:UIControlStateNormal];

}

else

{

[self.locationBtn setImage:self.imageLocated forState:UIControlStateNormal];

}

}

- (void)mapView:(MAMapView *)mapView didFailToLocateUserWithError:(NSError *)error

{

//NSLog(@"error = %@",error);

}

#pragma mark - Handle Action

- (void)actionLocation

{

if (self.mapView.userTrackingMode == MAUserTrackingModeFollow)

{

[self.mapView setUserTrackingMode:MAUserTrackingModeNone animated:YES];

}

else

{

self.searchPage = 1;

[self.mapView setCenterCoordinate:self.mapView.userLocation.coordinate animated:YES];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

[self.mapView setUserTrackingMode:MAUserTrackingModeFollow animated:YES];

});

}

}

2.4).獲取資料以及生成UI

-(void)createData

{根據介面獲取到類目資料 生成UI  [self createUI]}

實現這個方法,就是上面類目UI的實現

-(void)createUI

{

FbwManager *Manger = [FbwManager shareManager];

for (NSDictionary *dic in _TwoDataArray[0]) {//資料已經獲取到

[_DataArray2 addObject:dic[@"name"]];

[_DataArray2Id addObject:dic[@"id"]];

}

__weak __typeof(self)weakSelf = self;

UIScrollView *topScrollView = [[UIScrollView alloc]init];

[self.view addSubview:topScrollView];

[topScrollView mas_makeConstraints:^(MASConstraintMaker *make) {

make.top.equalTo(@64);

make.left.equalTo(weakSelf.view);

make.right.equalTo(@0);//make.right.equalTo(@-30);

make.height.equalTo(@30);//make.height.equalTo(@30);

}];

topScrollView.backgroundColor = kAppGoodColor;

topScrollView.contentSize = CGSizeMake(_OneDataArray.count * (kScreenWidth-30)/4.f, 0);

UIButton *_lastBtn;

NSInteger i = 0;

for (NSString *title in _OneDataArray) {

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

btn.frame = CGRectMake(_lastBtn ? _lastBtn.right : 0, 0, (kScreenWidth-30)/4.f, 30);

[topScrollView addSubview:btn];

//        [btn mas_makeConstraints:^(MASConstraintMaker *make) {

//            make.left.equalTo(_lastBtn ? _lastBtn.mas_right : @0);

//            make.top.bottom.equalTo(topScrollView);

//            make.width.equalTo(@((kScreenWidth-30)/4.f));

//        }];

btn.backgroundColor = kAppClearColor;

[btn setTitleColor:kAppWhiteColor forState:UIControlStateNormal];

[btn setTitle:title forState:UIControlStateNormal];

btn.titleLabel.font = [UIFont boldSystemFontOfSize:14];

[btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];

_lastBtn = btn;

i++;

btn.tag = 10+i;

if (btn.tag == 11) {

}}

UIScrollView *bottomScrollView = [[UIScrollView alloc]init];

[self.view addSubview:bottomScrollView];

[bottomScrollView mas_makeConstraints:^(MASConstraintMaker *make) {

make.top.equalTo(topScrollView.mas_bottom);

make.left.right.equalTo(weakSelf.view);

make.height.equalTo(@30);

}];

bottomScrollView.backgroundColor = [UIColor colorWithRed:230/255.f green:230/255.f blue:230/255.f alpha:1];

bottomScrollView.tag = 101;

[self createBottomViewWithArray:_DataArray2];//類目二根據類目一生成

[self createMapAnni];//生成標註

if (_DataArray2.count != 0) {

Manger.YueOrderName = _DataArray2[0];

}

if (_DataArray2Id.count != 0) {

Manger.YueOrderId = _DataArray2Id[0];

}

}

2.4.1).標註的生成以及實現過程

-(void)createMapAnni

{
  //根據你的定位座標和設定的搜尋半徑以及類目的ID獲取到該類目下的使用者 獲取到資料 呼叫[self initAnnotations];
}

-(void)initAnnotations{

NSMutableArray *coordinates = [NSMutableArray array];}

for (int i = 0; i < _dataArray.count; i++)

{

ThirdMcModel *model = _dataArray[i];

//            MAPointAnnotation *a1 = [[MAPointAnnotation alloc] init];

//            a1.coordinate = CLLocationCoordinate2DMake([model.UserX doubleValue],[model.UserY doubleValue]);

//            [coordinates addObject:a1];

HQMCustomAnnotation *femaleAnn = [[HQMCustomAnnotation alloc] init];//此方法參考了一位簡書的同仁 很好用,下面會給該檔案的.h .m

femaleAnn.type = CustomAnnotationTypeFemale;

femaleAnn.imagePath = model.UserPic;

femaleAnn.coordinate = CLLocationCoordinate2DMake([model.UserX doubleValue],[model.UserY doubleValue]);

[coordinates addObject:femaleAnn];

}

[self.mapView addAnnotations:coordinates];

- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id)annotation//這個方法也少不了 匹配模型資料

{

if ([annotation isKindOfClass:[HQMCustomAnnotation class]]) {

HQMCustomAnnotation *cusAnnotation = (HQMCustomAnnotation *)annotation;

static NSString *cusAnnotationID = @"HQMCustomAnnotation";

HQMCustomAnnotationView *cusAnnotationView = (HQMCustomAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:cusAnnotationID];

if (!cusAnnotationView) {

cusAnnotationView = [[HQMCustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:cusAnnotationID];

}

cusAnnotationView.annotation = cusAnnotation;

//        cusAnnotationView.tag = i++;

return cusAnnotationView;

}

return nil;

}

2.4.2)根據點選類目一類目二的實現.

-(void)createBottomViewWithArray:(NSArray *)array

{

UIScrollView *bottomScrollView = [self.view viewWithTag:101];

for (UIView *subView in bottomScrollView.subviews) {

[subView removeFromSuperview];

}

bottomScrollView.contentSize = CGSizeMake(array.count * (kScreenWidth-30)/6.f, 0);

UIButton *_last1Btn;

NSInteger i = 0;

for (NSString *title in array) {

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

btn.frame = CGRectMake(_last1Btn ? _last1Btn.right : 0, 0, (kScreenWidth-30)/6.f, 30);

[bottomScrollView addSubview:btn];

//        [btn mas_makeConstraints:^(MASConstraintMaker *make) {

//            make.left.equalTo(_lastBtn ? _lastBtn.mas_right : @0);

//            make.top.bottom.equalTo(topScrollView);

//            make.width.equalTo(@((kScreenWidth-30)/4.f));

//        }];

btn.backgroundColor = kAppClearColor;

[btn setTitle:title forState:UIControlStateNormal];

//        [topScrollView addSubview:btn];

btn.titleLabel.font = [UIFont boldSystemFontOfSize:12];

//        [btn setTitleColor:[UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1] forState:UIControlStateNormal];

[btn setTitleColor:kAppBlackColor forState:UIControlStateNormal];

[btn addTarget:self action:@selector(btnAction1:) forControlEvents:UIControlEventTouchUpInside];

_last1Btn = btn;

i++;

btn.tag = 40+i;

if (btn.tag == 41) {

[btn setTitleColor:kAppGoodColor forState:UIControlStateNormal];

self.selectButton = btn;

}

}

}

2.5).點選類目一以及類目二的item

-(void)btnAction:(UIButton *)tb

{

[_DataArray2 removeAllObjects];

[_DataArray2Id removeAllObjects];

for (NSDictionary *dic in _TwoDataArray[tb.tag-11]) {

if (NotNilAndNull(dic[@"name"])) {

[_DataArray2 addObject:dic[@"name"]];

}

if (NotNilAndNull(dic[@"id"])) {

[_DataArray2Id addObject:dic[@"id"]];

}

}

[self createBottomViewWithArray:_DataArray2];

}

.//點選類目二item

-(void)btnAction1:(UIButton *)tb

{

//    NSLog(@"按鈕%ld",tb.tag);

if(self.selectButton == tb) {

//上次點選過的按鈕,不做處理

} else{

//本次點選的按鈕設為紅色

[tb setTitleColor:kAppGoodColor forState:UIControlStateNormal];

//將上次點選過的按鈕設為黑色

[self.selectButton setTitleColor:kAppBlackColor forState:UIControlStateNormal];

}

self.selectButton = tb;

[self.mapView removeOverlays:self.mapView.overlays];

[self.mapView removeAnnotations:self.mapView.annotations];

//跟之前的生成標註一樣 移除資料來源 再次重新請求此類目下的使用者資訊

}

2.6).最後就是點選標註進入資訊 根據標註的位置和使用者的位置進行判斷

- (void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view
{
// clickLocation 位置資訊

CLLocationCoordinate2D clickLocation = view.annotation.coordinate;

for (int i = 0; i < _dataArray.count; ++i)

{

ThirdMcModel *Model = _dataArray[i];

//        NSLog(@"我你那麼 %f  %f",[Model.UserX doubleValue],[Model.UserY doubleValue]);

if ([Model.UserX doubleValue] == clickLocation.latitude && [Model.UserY doubleValue] == clickLocation.longitude){

PersonalDataVC *person = [[PersonalDataVC alloc]init];

[self.navigationController pushViewController:person animated:YES];

   }
  }
}

2.7).最後上兩張做好的效果圖吧 上面的demo夠用了

1.5.jpg
1.5.jpg1.6.jpg
1.6.jpg

2.8).帶HQMCustomAnnotation.h .m 和
HQMCustomAnnotationView.h.m

2.8.1)HQMCustomAnnotation.h

#import<MAMapKit/MAMapKit.h>

typedef NS_ENUM(NSUInteger, CustomAnnotationType){

CustomAnnotationTypeMe = 1,

CustomAnnotationTypeFemale,

CustomAnnotationTypeMale,

};

@interface HQMCustomAnnotation : MAPointAnnotation

@property (nonatomic, assign) CustomAnnotationType type;

@property (nonatomic, assign) NSInteger number;

@property (nonatomic, copy)  NSString *imagePath;

@end

2.8.2)HQMCustomAnnotation.m

#import "HQMCustomAnnotation.h"

@implementation HQMCustomAnnotation

@end

2.8.3)HQMCustomAnnotationView.h

#import<MAMapKit/MAMapKit.h>

@class HQMCustomAnnotation;@interface HQMCustomAnnotationView : MAAnnotationView
//一定要重寫,否則當滑動地圖,annotation出現和消失時候會出現資料混亂
- (void)setAnnotation:(id)annotation;
@end

2.8.4)HQMCustomAnnotationView.m

import "HQMCustomAnnotationView.h"

#import "HQMCustomAnnotation.h"

@interface HQMCustomAnnotationView()

@property (nonatomic, strong) UIImageView *backgroundImageView;

@property (nonatomic, strong) UIImageView *avatarImageView;

@property (nonatomic, strong) UIImageView *dotImageView;

@property (nonatomic, assign) NSInteger number;

@end
@implementation HQMCustomAnnotationView

#pragma mark - Life Cycle

- (void)dealloc {    self.backgroundImageView = nil;    self.avatarImageView = nil;    self.dotImageView = nil;}

- (id)initWithAnnotation:(id)annotation reuseIdentifier:(NSString *)reuseIdentifier {    HQMCustomAnnotation *ann = (HQMCustomAnnotation *)annotation;    self = [super initWithAnnotation:ann reuseIdentifier:reuseIdentifier];    if (self) {        self.backgroundColor = [UIColor clearColor];        [self initializeAnnotation:ann];    }        return self;}

- (void)initializeAnnotation:(HQMCustomAnnotation *)ann {    [self setupAnnotation:ann];}- (void)setAnnotation:(id)annotation {

[super setAnnotation:annotation];

HQMCustomAnnotation *ann = (HQMCustomAnnotation *)self.annotation;

//當annotation滑出地圖時候,即ann為nil時,不設定(否則由於列舉的型別會執行不該執行的方法),只有annotation在地圖範圍內出現時才設定,可以打斷點除錯

if (ann) {
   [self setupAnnotation:ann];
  }
}


- (void)setupAnnotation:(HQMCustomAnnotation *)ann {

NSString *mask = @"";

CGRect frame = CGRectZero;

switch (ann.type) {

case CustomAnnotationTypeMe: {//我的頭像背景

frame = CGRectMake(0, 0, 48., 60.);

mask = @"xh_dq_zb_bg.png";

break;

}

case CustomAnnotationTypeFemale: {

frame = CGRectMake(0, 0, 44., 44.);

//            mask = @"xh_zb_red_ic.png";

break;
}

case CustomAnnotationTypeMale: {

frame = CGRectMake(0, 0, 34., 46.);
mask = @"xh_zb_ic.png";
break;
}
}

self.bounds = frame;

self.centerOffset = CGPointMake(0, -self.bounds.size.height*0.5);

//設定背景圖片

self.backgroundImageView.image = [UIImage imageNamed:mask];

self.backgroundImageView.frame = self.bounds;

//設定頭像圖片

self.avatarImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.width);

self.avatarImageView.layer.cornerRadius = (self.bounds.size.width) * 0.5;

self.avatarImageView.layer.masksToBounds = YES;

//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(ClickImage:)];

//    [self.avatarImageView addGestureRecognizer:tap];

if (ann.type == CustomAnnotationTypeMe) {

if (!self.dotImageView) {

self.dotImageView = [[UIImageView alloc] init];

self.dotImageView.frame = CGRectMake((frame.size.width - 11)/2, frame.size.height - 8, 12, 12);

[self addSubview:self.dotImageView];

[self sendSubviewToBack:self.dotImageView];

self.dotImageView.image = [UIImage imageNamed:@"xh_yuandian_ic.png"];

}

} else {

if (self.dotImageView) {

  [self.dotImageView removeFromSuperview];

   self.dotImageView = nil;
   }
 }
 [self setupAvatarImage];
}

- (void)setupAvatarImage {

HQMCustomAnnotation *ann = (HQMCustomAnnotation *)self.annotation;

[self.avatarImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",BASEURL,ann.imagePath]] placeholderImage:[UIImage imageNamed:@"網紅1"]];
}

- (UIImageView *)backgroundImageView {

if (!_backgroundImageView) {

_backgroundImageView = [[UIImageView alloc] init];

[self addSubview:_backgroundImageView];
}
return _backgroundImageView;
}

- (UIImageView *)avatarImageView {

if (!_avatarImageView) {

_avatarImageView = [[UIImageView alloc] init];
[self.backgroundImageView addSubview:_avatarImageView];
}
return _avatarImageView;
}
@end

相關推薦

iOS地圖定位.定義標註.搜尋.分類展示(排版)

一.先前準備 4.0 .jpg 這就是公司的需求,上面欄目點選重新整理地圖標註,類目二根據類目一的變化而變化,標註可點選進個人資料,點選下單也可跳轉. 1.0.png 1.2).在用到的vc匯入,還有遵循協議<MAMapViewDelegate>,這裡還要謝謝簡書一位仁兄,因為最後兩個

(三)地圖定義縮放及縮放動畫效果

這一節主要實現的功能是地圖的自定義縮放及縮放的動畫效果,還是直接放上程式碼更直觀些,主要部位裡面基本有註解 還是老樣子,首先是新建activity_zoom_animate.xml佈局檔案 <?xml version="1.0" encoding="utf-8"?> <

Android地圖定義底圖(午夜藍主題風格地圖

官網上介紹:地址連結 從 3D 地圖 SDK V4.1.3版本開始支援自定義地圖底圖功能。 功能說明:支援對部分地圖元素自定義顏色,包括:填充色、邊框色、文字顏色。 先上圖,我自己做出來的自定義地圖(底圖) 效果圖就是以上這樣,下面來說一下實現的步驟

Android整合地圖如何定義marker

高德地圖自定義Marker 高德地圖預設的marker樣式是這種 一般的修改樣式是通過icon介面來調整 MarkerOptions markerOptions = new MarkerOpt

地圖新增定義圖示

1.新增自定義圖示 aMap.addMarker(new MarkerOptions() .draggable(true) .title(jsonObject.getString("functionDetail")

iOS地圖 初始化 重定義比例尺

使用的為高德地圖 遷移到自己專案中也根據官方文件來引入高德地圖 但是2D地圖的API中沒有直接設定地圖比例尺的大小,而預設的MAMapView的建立所展示的5個點的位置由於地圖比例尺的不合適,會產生重疊,怎樣來調整初始化時候地圖比例尺的問題 API中有寫道  REGION

地圖定位

經緯度 pan sta 一個 第一個 llc ide transform pre 當前互聯網地圖的坐標系現狀 地球坐標 (WGS84) 國際標準,從專業GPS 設備中取出的數據的坐標系 國際地圖提供商使用的坐標系 火星坐標 (GCJ-02)也叫國測局坐標系 中國標準,

百度地圖API 定義標註圖標

cit rop 設置 src rip ddc 使用 options city 通過Icon類可實現自定義標註的圖標,下面示例通過參數MarkerOptions的icon屬性進行設置, 也可以使用marker.setIcon()方法。 <script type="te

Android實現地圖定位詳細流程

 要實現高德地圖定位呢,首先需要做好以下幾步準備:  如果你嫌筆者寫的不好或者懶得看,只需要程式碼的話,請選擇: github:點選開啟連結,此連線可能和文章內容有所出入,因

地圖開發之點標註marker

在地圖上新增標記點是常使用的方法,用它可以將任何你希望或感興趣的點標註在地圖上,同時也可以指定任意的圖示或內容等。Marker就是這樣一個用於在地圖上新增點標記的類。 1. 要有一個地圖物件例項,如下: var mapObj = new AMap.Map('container',

從頭開發一個Flutter外掛(二)地圖定位外掛

在上一篇文章從頭開發一個Flutter外掛(一)開發流程裡具體介紹了flutter外掛的具體開發流程,從建立專案到釋出。接下來將會為Flutter天氣專案開發一個基於高德定位sdk的flutter定位外掛。 完整程式碼在git倉庫裡 github.com/KinsomyJS/l… 申請key 首先先進入

vue-amap 地圖定位 點選獲取經緯度和具體地址的使用

官方文件地址: 點這裡!!   經緯度獲取只要通過點選事件就可以通過e.lnglat來獲取,然後就是外掛Geocoder使用了。在main.js中initAMapApiLoader中寫入:AMap.Geocoder,注意 官方文件中有提示: 所以外掛中使用

地圖 定位 搜尋

<body> <input type="text" id="mymap_search"> <button class="search">search</button> <input type="text" name=

百度地圖API 定義標註圖示

                     通過Icon類可實現自定義標註的圖示,下面示例通過引數MarkerOptions的icon屬性進行設定, 也可以使用marker.setIcon()方法。<script type="text/javascript">    // 百度地圖API功能   

地圖定位 基礎

** 高德地圖定位 ** 首先新建應用:https://lbs.amap.com/dev/key/app 一、依賴 implementation 'com.amap.api:location:4.4.0' 二、許可權 <!--用於進行網路定位-->

android地圖定位功能的實現

<1>先去高德開放平臺去申請開發者賬號,並且建立應用,獲取API Key <2>在清單檔案中配置key,其中value是應用的key值 <meta-data android:name="com.amap

地圖定位api以及導航和定位 位置的偏差

   <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.2&key=37d9a4da394e46e29***d0521eb7"></script>  

地圖定位功能在Android上的整合

First: 關聯高德地圖的SDK,Android Studio是在app build.gradle 中的dependencies 根節點下新增 compile 'com.amap.api:location:latest.integration'//定位 compile

地圖定位、新增定點陣圖標、連線(二)

定位之後想在地圖中顯示,那麼就要在新增一個jar包,該jar包中有地圖的控制元件 一、新增定位標記 1、在build.gradle中新增 compile files('libs/AMap_3DMap_V3.3.1_20160419.jar') 使用的

地圖定位(簡易版)

首先要有在官網下載的demo 首先導依賴 在當前module 中的build.grade 中新增 sourceSets { main { jniLibs.srcDirs = ['libs'] } } 建立一個 名為