Tag: 谷歌地图

如何使用Google Maps ios SDK跟踪用户的位置并显示path

我目前正在构build一个iOS应用程序,我希望实现一个function,用户的位置显示在Google Map视图上,当他们移动一个折线显示的path已经由用户到目前为止。 这显然需要实时发生。 到目前为止,我已经初始化一个Google Maps视图,并且可以使用observeValueForKeyPath函数显示用户的当前位置。 视图和位置标记随用户移动而更新。 我想最好的方法是创build一个GMSMutablePath对象,每当地图摄像机更新到新位置时添加用户的当前位置,然后从该path创build多段线。 我用这个代码如下: – (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqualToString:@"myLocation"] && [object isKindOfClass:[GMSMapView class]]) { [self.myMapView animateToCameraPosition:[GMSCameraPosition cameraWithLatitude:self.myMapView.myLocation.coordinate.latitude longitude:self.myMapView.myLocation.coordinate.longitude zoom:18]]; [trackedPath addCoordinate:CLLocationCoordinate2DMake(self.myMapView.myLocation.coordinate.latitude, self.myMapView.myLocation.coordinate.longitude)]; GMSPolyline *testPoly = [GMSPolyline polylineWithPath:trackedPath]; testPoly.strokeWidth = 8; testPoly.strokeColor = [UIColor redColor]; testPoly.map = myMapView; } } 这不会在地图上产生任何折线,所以任何帮助/build议将非常感激!

在多段线/path中查找最近的点

我需要从GMSPolyline数组上的给定CLLocationCoordinate2D查找最近点。 如果更好,我可以把它转换成GMSPath 。 有没有现成的方法(或任何存储库)进行这样的计算? 我有一些执行问题。 我想知道如何创build一个algorithm: 1. for all polylines 1.1. find smallest distance between polyline and touch point, save CLLocationCoordinate2D 2. for all distances from point 1.1. 2.1. find the shortest one, it's CLLocationCoordinate2D is our point 现在的问题是如何实现点1.1 ..? 基于SOF最短距离问题 ,我写了这样的代码: – (void)findNearestLineSegmentToCoordinate:(CLLocationCoordinate2D)coordinate { GMSPolyline *bestPolyline; double bestDistance = DBL_MAX; CGPoint originPoint = CGPointMake(coordinate.longitude, […]

更改Google地图的选定标记或更改标记的颜色?

我想知道是否有方法来改变所选标记的颜色或图像,然后将其更改回来,当它不被选中了。 我看到使用Apple Maps的Yelp会改变所选标记的颜色/图像,然后在不再select该标记的情况下返回到原始图像,并且想知道Google Map iOS SDK是否有类似的东西,或者是否有人遇到过这个问题,并find了解决办法。 我曾经尝试过: 我已经通过谷歌的关于标记的文件( 在这里find ),看看他们有marker.opacity这改变了不透明度和marker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]]; 这改变了标记的颜色。 我试图手动改变它-(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker; 通过添加此行marker.icon = [GMSMarker markerImageWithColor: [UIColor differentColor]]; 或这一行marker.icon = [UIImage imageNamed:@"differentColorImage"]; 但是当您点击标记/信息窗口时,图像/颜色保持不变。 任何人有任何想法? 任何帮助。 提前致谢!

像UBER一样在Google Map上移动GMSMarker

我正在谷歌地图上开发一些导航任务。 随着车辆在其应用程序中的移动,我必须移动标记。 我已经尝试了@SO提供的不同的解决scheme,但它不能按我的需要工作。 我得到与以前经纬/长与当前纬度/经度和animationmapwithwith旋转的angular度 这里是代码 [CATransaction begin]; [CATransaction setAnimationDuration:2.0]; NSDictionary *data = [[result objectForKey:@"returnData"] objectForKey:@"data"]; if (![data isEqual: [NSNull null]]) { driverLocationCoordinate = CLLocationCoordinate2DMake([[data objectForKey:@"lat"] doubleValue], [[data objectForKey:@"lng"] doubleValue]); driverMarker.position = driverLocationCoordinate; GMSCameraPosition * camera = [GMSCameraPosition cameraWithLatitude:driverLocationCoordinate.latitude longitude:driverLocationCoordinate.longitude zoom:16]; mapHomeView.camera = camera; if ([data objectForKey:@"preLat"] != [NSNull null] && [data objectForKey:@"preLng"] !=[NSNull null]){ if […]

在Xcode中打开本地谷歌地图

嗨,我有一个使用地图和位置的iPhone应用程序。 我希望用户能够按下一个button,该button将轮到该位置的转向。 我明白,我不允许在应用程序中这样做,但我想知道是否有人可以告诉我,如果有可能做一个链接到本地​​谷歌地图应用程序,将从用户当前位置进入方向的位置。 如果有可能你能告诉我怎么样? 任何帮助,将不胜感激。 谢谢

从代码打开地图应用程序 – 在哪里/如何find“当前位置”?

我正在打开地图应用程序,以显示从用户的当前位置到目标坐标的方向,从我的代码。 我正在使用下面的代码来打开地图应用程序。 我按下button时调用此代码。 getCurrentLocation是返回最近更新的位置的方法。 – (void)showDirectionsToHere { CLLocationCoordinate2D currentLocation = [self getCurrentLocation]; // LINE 1 NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", currentLocation.latitude, currentLocation.longitude, destCoordinate.latitude, destCoordinate.longitude]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; } 这里LINE 1中的 [self getCurrentLocation]使用CLLocationManager来确定当前位置并返回值。 注意 :我还没有在LINE1中实现代码。 我刚刚计划这样做。 我的问题是: 这是在地图应用程序被调用时计算当前位置的好习惯吗? 在openURL被调用之前, [self getCurrentLocation ]会返回当前位置? 在打开地图应用程序之前,我必须确定当前位置吗? 我对这些事情有点困惑。 请引导我。 谢谢。

Google Maps iOS SDK集成不加载地图

我在iPhone应用程序中使用Google地图iOS SDK 。 我在地图上显示地点标记,并使用我的苹果开发者帐户证书在我的iPhone设备上正常工作。 但是,当我使用不同的Enterprise Apple开发人员帐户证书 (Enterprise帐户)将构build发送到testing团队时,地图不会加载,只会在地图加载的黑屏上显示地点标记。 我也尝试在我的iPhone设备与企业苹果开发者帐户,它不是加载地图(空白屏幕上只是一个引脚)。 但用我自己的苹果开发者账户证书,它工作得很好。 我假设这个问题是在企业苹果开发者帐户(可能是我已经改变了苹果开发者帐户上的一些设置为我的应用程序ID)。 我无法find解决scheme。 有人能帮我解决吗? 如果您需要更多的信息,请在评论中提问。 提前致谢!

如何在iOS中显示信息窗口Google地图不用点击标记?

我是iOS开发新手。 这是关于Google Maps iOS SDK中的标记信息窗口。 我明白,我们可以使用GMSMarkerOption创build一个带有信息窗口的标记。 GMSMarkerOption *myLocationOption = [GMSMarkerOption alloc]; myLocationOption .title = @"My Location"; myLocationOption .snippet = @"Lat:…., Lang:…."; [mapView addMarkerOption:myLocationOption]; 根据上面的代码,Marker按照预期显示在Map视图中。 点击标记在Google地图上显示“我的位置”信息窗口,这是很好的。 无论如何,当用户转到自定义地图屏幕时,我们可以以编程方式显示信息窗口?

对于谷歌地图的iOS SDK,当前的位置偶尔得到绘制在0,0

不知道为什么会发生这种情况,但是如果发生这种情况,我们不希望向用户显示他们当前的位置是0,0(位于南非海岸的中间)。 有什么办法来检测这种情况何时发生,以便我们可以向用户显示错误信息或其他信息?

谷歌地图绘制多个标记问题(信息窗口和标记重复)

首先我创build一个用户位置的地图 -(void)initGogleMapView{ GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude zoom:1]; mapView = [GMSMapView mapWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-64) camera:camera]; [self.view addSubview:mapView]; GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = camera.target; marker.appearAnimation = kGMSMarkerAnimationPop; marker.map = mapView; marker.title=@"Current Location"; } 然后我有一个经度和纬度的数组和循环的阴谋 for(int i=0;i<[latLongArr count];i++) { GMSMarker *tempmarker = [[GMSMarker alloc] init]; tempmarker.position = CLLocationCoordinate2DMake([[[latLongArr objectAtIndex:i] valueForKey:@"Latitude"] floatValue],[[[latLongArr objectAtIndex:i] […]