GoogleMap API for iOS 使用 之 动点画线
2013-04-19 13:45
519 查看
所谓的动点画线,就是根据用户的当前位置,获取到的经纬度,画出移动轨迹。
画线方法如:
-(void) loadRoute
{
GMSPolylineOptions *options = [GMSPolylineOptionsoptions];
GMSMutablePath *path = [GMSMutablePathpath];
//_locations 是从定位获取的坐标数组
for(int idx =0; idx <_locations.count;
idx++)
{
NSString* currentPointString = [_locationsobjectAtIndex:idx];
NSArray* latLonArr = [currentPointStringcomponentsSeparatedByCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@","]];
CLLocationDegrees latitude = [[latLonArrobjectAtIndex:0]doubleValue];
CLLocationDegrees longitude = [[latLonArrobjectAtIndex:1]doubleValue];
// create our coordinate and add it to the correct spot in the array
CLLocationCoordinate2D coordinate =CLLocationCoordinate2DMake(latitude, longitude);
[pathaddCoordinate:coordinate];
}
options.path = path;
options.color = [UIColorgreenColor];
options.width =10.0f;
options.geodesic =YES;
[_mapViewaddPolylineWithOptions:options];
}
//通过locationManager管理 使用次代理方法
#pragma mark - 位置管理 delegate methond
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
NSArray *_mutableArray = [[NSArray alloc]initWithObjects:[NSStringstringWithFormat:@"%3.4f,%3.4f",[newLocationcoordinate].latitude,
[newLocationcoordinate].longitude],nil];
[_locationsaddObjectsFromArray:_mutableArray];
NSLog(@"********位置管理代理方法*********************_locations = %@",_locations);
if ([_locationscount] >1) {
[selfloadRoute];//开始画线~~~
}
}
参考资料如下:
画线方法如:
-(void) loadRoute
{
GMSPolylineOptions *options = [GMSPolylineOptionsoptions];
GMSMutablePath *path = [GMSMutablePathpath];
//_locations 是从定位获取的坐标数组
for(int idx =0; idx <_locations.count;
idx++)
{
NSString* currentPointString = [_locationsobjectAtIndex:idx];
NSArray* latLonArr = [currentPointStringcomponentsSeparatedByCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@","]];
CLLocationDegrees latitude = [[latLonArrobjectAtIndex:0]doubleValue];
CLLocationDegrees longitude = [[latLonArrobjectAtIndex:1]doubleValue];
// create our coordinate and add it to the correct spot in the array
CLLocationCoordinate2D coordinate =CLLocationCoordinate2DMake(latitude, longitude);
[pathaddCoordinate:coordinate];
}
options.path = path;
options.color = [UIColorgreenColor];
options.width =10.0f;
options.geodesic =YES;
[_mapViewaddPolylineWithOptions:options];
}
//通过locationManager管理 使用次代理方法
#pragma mark - 位置管理 delegate methond
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
NSArray *_mutableArray = [[NSArray alloc]initWithObjects:[NSStringstringWithFormat:@"%3.4f,%3.4f",[newLocationcoordinate].latitude,
[newLocationcoordinate].longitude],nil];
[_locationsaddObjectsFromArray:_mutableArray];
NSLog(@"********位置管理代理方法*********************_locations = %@",_locations);
if ([_locationscount] >1) {
[selfloadRoute];//开始画线~~~
}
}
参考资料如下:
iOS开发之在地图上绘制出你运行的轨迹
相关文章推荐
- [ios培训]iOS Cllocationmanger定位, 使用Google Map API在mapview上画路径
- iOS Cllocationmanger定位, 使用Google Map API在mapview上画路径
- iOS使用Google Map Api…
- googleMap sdk for iOS的一些使用 介绍问题
- iOS Cllocationmanger定位, 使用Google Map API在mapview上画路径
- Android Google Map API使用的八个步骤
- Android 使用Google Map API;云计算概念IaaS,PaaS,SaaS,CaaS,MaaS
- Android Google Map API使用的八个步骤---插件生成key
- Google Map API使用详解(五)——Google Map基本常识(下)
- ArcGIS API for iOS开发教程四 使用GraphicsLayer
- Google Map API使用中出现的“google未定义”解决办法
- 在emacs中使用google map api?!
- 如何使用google map api制作自己的地图(转载)
- Google Map API使用详解(六)——Google Map API Key的解读和使用技巧
- Google Map API使用详解(一)——Google Map开发背景知识
- 使用Google Map API可能会遇到的问题汇总
- 获取 google map api key for android app
- Google Map API使用详解(七)——加载Google Map API URL的详细解读
- Google Map API使用详解(如何在自己的网页中嵌入地图)
- Google Map for iOS SDK 开发之沿街道渲染轨迹