IOS百度地圖自定義大頭針和氣泡
原文連結:http://www.jianshu.com/p/6a334f071c69
著作權歸作者所有,轉載請聯絡作者獲得授權,並標註“簡書作者”。
1.首先實現新增多個標註和自定義氣泡
新增自定義標註
[_mapView addAnnotations:array];
arry 中放入標註(BMKPointAnnotation)的陣列,此方法新增多個標註。
當新增多個標註時就觸發以下代理方法
#pragma mark -- BMKMapdelegate
/**
*根據anntation生成對應的View
*@param mapView 地圖View
*@param annotation 指定的標註
*@return 生成的標註View
*/
-(BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation
{
if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
BMKPinAnnotationView *newAnnotationView = [[BMKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"myAnnotation" ];
newAnnotationView.animatesDrop = YES;
newAnnotationView.annotation = annotation;
//這裡我根據自己需要,繼承了BMKPointAnnotation,添加了標註的型別等需要的資訊
MyBMKPointAnnotation *tt = (MyBMKPointAnnotation *)annotation;
//判斷類別,需要新增不同類別,來賦予不同的標註圖片
if (tt.profNumber == 100000) {
newAnnotationView.image = [UIImage imageNamed:@"ic_map_mode_category_merchants_normal.png"];
}else if (tt.profNumber == 100001){
}
//設定popView的高度,根據是否含有縮圖
double popViewH = 60;
if (annotation.subtitle == nil) {
popViewH = 38;
}
UIView *popView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth-100, popViewH)];
popView.backgroundColor = [UIColor whiteColor];
[popView.layer setMasksToBounds:YES];
[popView.layer setCornerRadius:3.0];
popView.alpha = 0.9;
// //設定彈出氣泡圖片
// UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:tt.imgPath]];
// image.frame = CGRectMake(0, 160, 50, 60);
// [popView addSubview:image];
//自定義氣泡的內容,新增子控制元件在popView上
UILabel *driverName = [[UILabel alloc]initWithFrame:CGRectMake(8, 4, 160, 30)];
driverName.text = annotation.title;
driverName.numberOfLines = 0;
driverName.backgroundColor = [UIColor clearColor];
driverName.font = [UIFont systemFontOfSize:15];
driverName.textColor = [UIColor blackColor];
driverName.textAlignment = NSTextAlignmentLeft;
[popView addSubview:driverName];
UILabel *carName = [[UILabel alloc]initWithFrame:CGRectMake(8, 30, 180, 30)];
carName.text = annotation.subtitle;
carName.backgroundColor = [UIColor clearColor];
carName.font = [UIFont systemFontOfSize:11];
carName.textColor = [UIColor lightGrayColor];
carName.textAlignment = NSTextAlignmentLeft;
[popView addSubview:carName];
if (annotation.subtitle != nil) {
UIButton *searchBn = [[UIButton alloc]initWithFrame:CGRectMake(170, 0, 50, 60)];
[searchBn setTitle:@"檢視路線" forState:UIControlStateNormal];
searchBn.backgroundColor = mainColor;
searchBn.titleLabel.numberOfLines = 0;
[searchBn addTarget:self action:@selector(searchLine)];
[popView addSubview:searchBn];
}
BMKActionPaopaoView *pView = [[BMKActionPaopaoView alloc]initWithCustomView:popView];
pView.frame = CGRectMake(0, 0, ScreenWidth-100, popViewH);
((BMKPinAnnotationView*)newAnnotationView).paopaoView = nil;
((BMKPinAnnotationView*)newAnnotationView).paopaoView = pView;
return newAnnotationView;
}
return nil;
}
點選標註和氣泡響應方法
/**
* 當選中一個annotation views時,呼叫此介面
* @param mapView 地圖View
* @param views 選中的annotation views
*/
- (void)mapView:(BMKMapView *)mapView didSelectAnnotationView:(BMKAnnotationView *)view
{
_shopCoor = view.annotation.coordinate;
}
/**
* 選中氣泡呼叫方法
* @param mapView 地圖
* @param view annotation
*/
- (void)mapView:(BMKMapView *)mapView annotationViewForBubble:(BMKAnnotationView *)view
{
MyBMKPointAnnotation *tt = (MyBMKPointAnnotation *)view.annotation;
if (tt.shopID) {
BusinessIfonUVC *BusinessIfonVC = [[BusinessIfonUVC alloc]init];
BusinessIfonVC.shopId = tt.shopID;
[self.navigationController pushViewController:BusinessIfonVC animated:YES];
}
}
2.實現路線搜尋,路徑規劃,獲取街道名稱等功能
通過經緯度獲取地址,逆地理編碼
-(void)getStartAddress
{
//起點地址
CLGeocoder *Geocoder = [[CLGeocoder alloc]init];
CLGeocodeCompletionHandler handler = ^(NSArray *place,NSError *error){
for(CLPlacemark *placemark in place){
NSString *tmp = [[NSString alloc]init];
tmp = placemark.subThoroughfare;
if (tmp == nil) {
tmp = @"";
}
NSString *startAdr = [[NSString alloc]initWithFormat:@"%@%@",placemark.thoroughfare,tmp];
_startCityText.text = placemark.locality;
if ([startAdr isEqualToString:@"(null)"]) {
_startAddrText.text = @"獲取地址失敗";
}else{
_startAddrText.text = startAdr;
}
}
};
CLLocation *loc = [[CLLocation alloc]initWithLatitude:self.startCoor.latitude longitude:self.startCoor.longitude];
[Geocoder reverseGeocodeLocation:loc completionHandler:handler];
}
路徑檢索,該部分沒有整理,將乘車和換乘資訊放到了LineInfo,steps等模型中。
- (void)onGetTransitRouteResult:(BMKRouteSearch*)searcher result:(BMKTransitRouteResult*)result errorCode:(BMKSearchErrorCode)error
{
NSMutableArray *lineArr = [[NSMutableArray alloc]init];
NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
[_mapView removeAnnotations:array];
array = [NSArray arrayWithArray:_mapView.overlays];
[_mapView removeOverlays:array];
if (error == BMK_SEARCH_NO_ERROR) {
for(int j = 0; j < [result.routes count];j++)
{
NSMutableArray *busTitleArr = [[NSMutableArray alloc]init];
NSMutableArray *lineStepsArr = [[NSMutableArray alloc]init];
NSMutableArray *stepsArr = [[NSMutableArray alloc]init];
//生成資料模型
LineInfoModel *lineInfo = [[LineInfoModel alloc]init];
BMKTransitRouteLine* plan = (BMKTransitRouteLine*)[result.routes objectAtIndex:j];
//資料模型:獲得路線長度
lineInfo.distance = plan.distance;
//資料模型:獲得路線消耗時間
lineInfo.dates = plan.duration.dates;
lineInfo.hours = plan.duration.hours;
lineInfo.minutes = plan.duration.minutes;
lineInfo.seconds = plan.duration.seconds;
// 獲得軌跡點
lineInfo.planStepsArr = plan.steps;
// 計算路線方案中的路段數目
int size = [plan.steps count];
int planPointCounts = 0;
for (int i = 0; i < size; i++) {
BMKTransitStep* transitStep = [plan.steps objectAtIndex:i];
//資料模型:獲得乘坐公交陣列
DLog(@"%@",transitStep.vehicleInfo.title);
if (transitStep.vehicleInfo.title) {
[busTitleArr addObject:transitStep.vehicleInfo.title];
}
//資料模型:獲取換乘資訊
if (transitStep.instruction) {
transitStep.instruction = [transitStep.instruction stringByReplacingOccurrencesOfString:@"<font color=\"#313233\">" withString:@""];
[lineStepsArr addObject:transitStep.instruction];
}
DLog(@"%@ %@",transitStep.vehicleInfo.title,transitStep.instruction);
if(i==0){
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = plan.starting.location;
item.title = @"起點";
item.type = 0;
// [_mapView addAnnotation:item]; // 新增起點標註
//
//
[stepsArr addObject:item];
}else if(i==size-1){
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = plan.terminal.location;
item.title = @"終點";
item.type = 1;
[stepsArr addObject:item];
// [_mapView addAnnotation:item]; // 新增起點標註
//
}
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = transitStep.entrace.location;
item.title = transitStep.instruction;
transitStep.instruction = [transitStep.instruction stringByReplacingOccurrencesOfString:@"<font color=\"#313233\">" withString:@""];
item.type = 3;
[stepsArr addObject:item];
// [_mapView addAnnotation:item];
//
//
// //軌跡點總數累計
planPointCounts += transitStep.pointsCount;
}
lineInfo.vehicleInfoArr = busTitleArr;
lineInfo.lineStepsArr = lineStepsArr;
lineInfo.stepsArr = stepsArr;
lineInfo.planPointCounts = planPointCounts;
[lineArr addObject:lineInfo];
// //軌跡點
// BMKMapPoint * temppoints = new BMKMapPoint[planPointCounts];
// int i = 0;
// for (int j = 0; j < size; j++) {
// BMKTransitStep* transitStep = [plan.steps objectAtIndex:j];
// int k=0;
// for(k=0;k<transitStep.pointsCount;k++) {
// temppoints[i].x = transitStep.points[k].x;
// temppoints[i].y = transitStep.points[k].y;
// i++;
// }
}
self.lineStatusArr = lineArr;
// 通過points構建BMKPolyline
// BMKPolyline* polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];
// [_mapView addOverlay:polyLine]; // 新增路線overlay
// delete []temppoints;
// }
[_tableView reloadData];
}
}
- (void)onGetDrivingRouteResult:(BMKRouteSearch*)searcher result:(BMKDrivingRouteResult*)result errorCode:(BMKSearchErrorCode)error
{
NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
[_mapView removeAnnotations:array];
array = [NSArray arrayWithArray:_mapView.overlays];
[_mapView removeOverlays:array];
if (error == BMK_SEARCH_NO_ERROR) {
BMKDrivingRouteLine* plan = (BMKDrivingRouteLine*)[result.routes objectAtIndex:0];
// 計算路線方案中的路段數目
int size = [plan.steps count];
int planPointCounts = 0;
for (int i = 0; i < size; i++) {
BMKDrivingStep* transitStep = [plan.steps objectAtIndex:i];
if(i==0){
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = plan.starting.location;
item.title = @"起點";
item.type = 0;
[_mapView addAnnotation:item]; // 新增起點標註
}else if(i==size-1){
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = plan.terminal.location;
item.title = @"終點";
item.type = 1;
[_mapView addAnnotation:item]; // 新增起點標註
}
//新增annotation節點
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = transitStep.entrace.location;
item.title = transitStep.entraceInstruction;
item.degree = transitStep.direction * 30;
item.type = 4;
[_mapView addAnnotation:item];
//軌跡點總數累計
planPointCounts += transitStep.pointsCount;
}
// 新增途經點
if (plan.wayPoints) {
for (BMKPlanNode* tempNode in plan.wayPoints) {
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item = [[RouteAnnotation alloc]init];
item.coordinate = tempNode.pt;
item.type = 5;
item.title = tempNode.name;
[_mapView addAnnotation:item];
}
}
//軌跡點
BMKMapPoint * temppoints = new BMKMapPoint[planPointCounts];
int i = 0;
for (int j = 0; j < size; j++) {
BMKDrivingStep* transitStep = [plan.steps objectAtIndex:j];
int k=0;
for(k=0;k<transitStep.pointsCount;k++) {
temppoints[i].x = transitStep.points[k].x;
temppoints[i].y = transitStep.points[k].y;
i++;
}
}
// 通過points構建BMKPolyline
BMKPolyline* polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];
[_mapView addOverlay:polyLine]; // 新增路線overlay
delete []temppoints;
}
}
- (void)onGetWalkingRouteResult:(BMKRouteSearch*)searcher result:(BMKWalkingRouteResult*)result errorCode:(BMKSearchErrorCode)error
{
NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
[_mapView removeAnnotations:array];
array = [NSArray arrayWithArray:_mapView.overlays];
[_mapView removeOverlays:array];
if (error == BMK_SEARCH_NO_ERROR) {
BMKWalkingRouteLine* plan = (BMKWalkingRouteLine*)[result.routes objectAtIndex:0];
int size = [plan.steps count];
int planPointCounts = 0;
for (int i = 0; i < size; i++) {
BMKWalkingStep* transitStep = [plan.steps objectAtIndex:i];
if(i==0){
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = plan.starting.location;
item.title = @"起點";
item.type = 0;
[_mapView addAnnotation:item]; // 新增起點標註
}else if(i==size-1){
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = plan.terminal.location;
item.title = @"終點";
item.type = 1;
[_mapView addAnnotation:item]; // 新增起點標註
}
//新增annotation節點
RouteAnnotation* item = [[RouteAnnotation alloc]init];
item.coordinate = transitStep.entrace.location;
item.title = transitStep.entraceInstruction;
item.degree = transitStep.direction * 30;
item.type = 4;
[_mapView addAnnotation:item];
//軌跡點總數累計
planPointCounts += transitStep.pointsCount;
}
//軌跡點
BMKMapPoint * temppoints = new BMKMapPoint[planPointCounts];
int i = 0;
for (int j = 0; j < size; j++) {
BMKWalkingStep* transitStep = [plan.steps objectAtIndex:j];
int k=0;
for(k=0;k<transitStep.pointsCount;k++) {
temppoints[i].x = transitStep.points[k].x;
temppoints[i].y = transitStep.points[k].y;
i++;
}
}
// 通過points構建BMKPolyline
BMKPolyline* polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];
[_mapView addOverlay:polyLine]; // 新增路線overlay
delete []temppoints;
}
}
3.畫路徑
我這裡實現是跳轉到另一個控制器中了,下面是他一些需要的資料
//路線長度
@property (nonatomic,assign) int distance;
//路線消耗時間
@property (nonatomic,assign) int dates;
@property (nonatomic,assign) int hours;
@property (nonatomic,assign) int minutes;
@property (nonatomic,assign) int seconds;
//交通工具陣列
@property (nonatomic,strong) NSArray *vehicleInfoArr;
//換乘資訊
@property (nonatomic,strong) NSArray *lineStepsArr;
//節點
@property (nonatomic,strong) NSArray *stepsArr;
//軌跡點個數
@property (nonatomic,assign) int planPointCounts;
//軌跡點
@property (nonatomic,strong) NSArray *planStepsArr;
接下來是畫路經,關於乘車資料的展示,就是一個tableview上添加了手勢,不做解釋。
-(void)drawMap
{
BMKPointAnnotation* item = [[BMKPointAnnotation alloc]init];
item = [_lineInfo.stepsArr firstObject];
[_mapView setCenterCoordinate:item.coordinate];
[_mapView addAnnotations:_lineInfo.stepsArr];
BMKMapPoint* temppoints = (BMKMapPoint *)malloc(sizeof(CLLocationCoordinate2D) * _lineInfo.planPointCounts);
int i = 0;
for (int j = 0; j < [_lineInfo.planStepsArr count]; j++) {
BMKTransitStep* transitStep = [_lineInfo.planStepsArr objectAtIndex:j];
int k=0;
for(k=0;k<transitStep.pointsCount;k++) {
temppoints[i].x = transitStep.points[k].x;
temppoints[i].y = transitStep.points[k].y;
i++;
}
}
BMKPolyline* polyLine =[BMKPolyline polylineWithPoints:temppoints count:_lineInfo.planPointCounts];
if (nil != polyLine) {
[_mapView addOverlay:polyLine]; // 新增路線overlay
}
free(temppoints);
}
- (BMKOverlayView*)mapView:(BMKMapView *)map viewForOverlay:(id<BMKOverlay>)overlay
{
if ([overlay isKindOfClass:[BMKPolyline class]]) {
BMKPolylineView* polylineView = [[BMKPolylineView alloc] initWithOverlay:overlay];
polylineView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:1];
polylineView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.7];
polylineView.lineWidth = 3.0;
return polylineView;
}
return nil;
}
// 判斷標註型別,來處理
- (BMKAnnotationView*)getRouteAnnotationView:(BMKMapView *)mapview viewForAnnotation:(MyBMKPointAnnotation*)routeAnnotation
{
BMKAnnotationView* view = nil;
switch (routeAnnotation.type) {
case 0:
{
view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"start_node"];
if (view == nil) {
view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"start_node"];
view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_start.png"]];
view.centerOffset = CGPointMake(0, -(view.frame.size.height * 0.5));
view.canShowCallout = TRUE;
}
view.annotation = routeAnnotation;
}
break;
case 1:
{
view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"end_node"];
if (view == nil) {
view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"end_node"];
view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_end.png"]];
view.centerOffset = CGPointMake(0, -(view.frame.size.height * 0.5));
view.canShowCallout = TRUE;
}
view.annotation = routeAnnotation;
}
break;
case 2:
{
view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"bus_node"];
if (view == nil) {
view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"bus_node"];
view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_bus.png"]];
view.canShowCallout = TRUE;
}
view.annotation = routeAnnotation;
}
break;
case 3:
{
view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"rail_node"];
if (view == nil) {
view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"rail_node"];
view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_rail.png"]];
view.canShowCallout = TRUE;
}
view.annotation = routeAnnotation;
}
break;
case 4:
{
view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"route_node"];
if (view == nil) {
view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"route_node"];
view.canShowCallout = TRUE;
} else {
[view setNeedsDisplay];
}
UIImage* image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_direction.png"]];
view.image = [image imageRotatedByDegrees:routeAnnotation.degree];
view.annotation = routeAnnotation;
}
break;
case 5:
{
view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"waypoint_node"];
if (view == nil) {
view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"waypoint_node"];
view.canShowCallout = TRUE;
} else {
[view setNeedsDisplay];
}
UIImage* image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_waypoint.png"]];
view.image = [image imageRotatedByDegrees:routeAnnotation.degree];
view.annotation = routeAnnotation;
}
break;
default:
break;
}
return view;
}
- (BMKAnnotationView *)mapView:(BMKMapView *)view viewForAnnotation:(id <BMKAnnotation>)annotation
{
if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
return [self getRouteAnnotationView:view viewForAnnotation:(MyBMKPointAnnotation *)annotation];
}
return nil;
}
- (UIImage*)imageRotatedByDegrees:(CGFloat)degrees
{
CGFloat width = CGImageGetWidth(self.CGImage);
CGFloat height = CGImageGetHeight(self.CGImage);
CGSize rotatedSize;
rotatedSize.width = width;
rotatedSize.height = height;
UIGraphicsBeginImageContext(rotatedSize);
CGContextRef bitmap = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(bitmap, rotatedSize.width/2, rotatedSize.height/2);
CGContextRotateCTM(bitmap, degrees * M_PI / 180);
CGContextRotateCTM(bitmap, M_PI);
CGContextScaleCTM(bitmap, -1.0, 1.0);
CGContextDrawImage(bitmap, CGRectMake(-rotatedSize.width/2, -rotatedSize.height/2, rotatedSize.width, rotatedSize.height), self.CGImage);
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
相關推薦
IOS百度地圖自定義大頭針和氣泡
文/煜寒了(簡書作者) 原文連結:http://www.jianshu.com/p/6a334f071c69 著作權歸作者所有,轉載請聯絡作者獲得授權,並標註“簡書作者”。1.首先實現新增多個標註和自定義氣泡 新增自定義標註 [_mapView addAnnotations:array]; arry 中放入標
百度地圖自定義大頭針
今天完成的主要工作是:給任務列表介面增加了下拉重新整理、上拉載入功能,這裡是通過MJRefresh來實現的;在列表介面請求完資料之後通過Block傳遞給任務主介面,以此來載入地圖上的資料。 在這裡實
iOS中設定百度地圖自定義標註圖片,自定義泡泡
#pragma mark - BMKMapViewDelegate // 根據anntation生成對應的View - (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id &l
百度地圖自定義座標標識覆蓋物,隨地圖縮放偏移解決辦法
百度地圖在新增自定義標註的時候可能會遇見座標標識,隨著地圖縮放位置產生偏移,我折騰了一個上午,記下這篇。 在此之前,請參考文章: http://www.cnblogs.com/jz1108/archive/2011/09/15/2152122.html 但是注意:
Android 百度地圖自定義地圖覆蓋物(Marker)
理論和高德地圖一模一樣,換個sdk而已,換湯不換藥,詳情可以參考上一篇高德地圖https://blog.csdn.net/Crystal_xing/article/details/84314359,下面只給出核心程式碼: //自定義佈局 Vie
百度地圖自定義工具欄
function gongju() { // 自定義控制元件 function ZoomControl() { this.defaultAnchor
百度地圖自定義覆蓋物載入時跑偏
直接看圖:正常是這樣的 我點選平面圖後,再點選百度地圖,先把地圖clearOverlays,再非同步請求介面重新載入了覆蓋物,則變成了下圖: 覆蓋物跑到右下角了,滑鼠在地圖上隨意拖拽一下,覆蓋物就正常顯示定位了。 解決辦法: reloadScene
百度地圖自定義icon,定位偏移問題
最近使用百度地圖做一個排程系統,使用定義icon的marker,結果地圖顯示marker和實際位置偏移,最終參考文章: 自定義icon通過設定anchor引數 var icon = ne
百度地圖自定義覆蓋物及建立多個小圖示
// 百度地圖API功能var sContent ="<h4 style='margin:0 0 5px 0;padding:0.2em 0'>天安門</h4>" +"<img style='float:right;margin:4px' id
js 百度地圖自定義彈出資訊視窗
圓形頭像,下方圖文效果 var sContent = {# '<a style="c
android實現百度地圖自定義彈出視窗功能
基本原理就是用ItemizedOverlay來新增附加物,在OnTap方法中向MapView上新增一個自定義的View(如果已存在就直接設為可見),下面具體來介紹我的實現方法: 一、自定義覆蓋物類:MyPopupOverlay,這個類是最關鍵的一個類ItemizedOverlay,用於設定Marke
百度地圖自定義覆蓋物手機端新增點選事件無效
最近在做百度地圖新增自定義覆蓋物時,遇到一個問題。起先參照api都很順利,但是當我在給自定義的覆蓋物新增點選事件時,問題來了:無法觸發。 去網上找了一些解決方案,包括註冊點選事件之類的,都沒有解決。 之後無意發現,當把除錯模式切出手機模式時,點選事件就能夠正
android 百度地圖自定義圓,更改預設圖示等常用方法
總結了一下百度地圖常用的方法(前提是整合百度地圖環境成功): 1:定位到已經經緯度,只需要改變LatLng的引數即可。有兩種方法: 方法1: //定義Maker座標點 LatLng point = new LatLng(39.96317
百度地圖自定義圖層如何實現
如果要在百度地圖上實現一張自己自定義的地圖,就需要使用百度地圖自定義圖層介面。實現效果如下: 但是百度地圖中關於自定義圖層的介紹甚少,便以此博文以記錄,方便同行瞭解和使用。 百度地圖官方文件中,關於自定義圖層的介紹是這樣的: =========華麗麗的分隔線=======
百度地圖自定義繪製的方法
百度地圖中的自定義繪製 圓的繪製方法 CurcleOptions center(LatLng center) 設定圓心座標 extraInfo(Bundle extraInf
百度地圖自定義關閉彈出框陰影
當我們自定義百度地圖彈出框時,一般也會自定義它的關閉按鈕。這樣本來也沒什麼問題,可是會在關閉了彈出框以後,在地圖上出來一個投射的陰影。這就很尷尬了,這會讓設計師很不爽,所以我們需要把這個陰影也去掉,我最開始做的是$('.BMap_shadow').html('');這
百度地圖自定義覆蓋物自定義資訊框
var timeOut=null; // 新增彈出框資料 var data_infoveh = [ [117.215914,39.190908,'1','30','0001','12345678','2016年12月30日',100
百度地圖自定義泡泡檢視
描述:最近專案中用到了百度地圖獲取附近的店鋪資訊,改店鋪資訊需要用自定義PaoPaoView來展示,其設定步驟如下: #import <MapKit/MapKit.h> @interface MapViewController : BaseViewContr
百度地圖-自定義mark以及為其新增資訊搜尋視窗
最近專案中要百度地圖,學習了一下,以下是個簡單的案例 廢話不多說,直接貼程式碼: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE html>
H5+百度地圖自定義定位控制元件、呼叫H5+定位介面
由於百度地圖的定位控制元件是呼叫內建的定位介面,想要呼叫H5+的定位介面就不行,自己改造一下就好了 /** * Author 嶽曉 * * 自定義定位控制元件,呼叫H5+內建定位API */ (function(BMap){ var control =