Google Maps iOS SDK:优化查找随机街道视图
这段代码根据一个国家的纬度/经度边界框在谷歌街道地图上找到一个随机位置。但是,即使使用边界框的方式,它仍然会变慢——要找到steet视图照片,可能需要一分钟的时间。我能做些什么来加快速度Google Maps iOS SDK:优化查找随机街道视图,ios,objective-c,google-maps,google-street-view,Ios,Objective C,Google Maps,Google Street View,这段代码根据一个国家的纬度/经度边界框在谷歌街道地图上找到一个随机位置。但是,即使使用边界框的方式,它仍然会变慢——要找到steet视图照片,可能需要一分钟的时间。我能做些什么来加快速度 GMSPanoramaView中的委托方法检查随机位置是否有有效的全景照片。如果没有,则指示查找新的搜索 // Delegate method of GMSPanoramaView that get´s called when didMoveToPanorama: is called - (void)panor
GMSPanoramaView
中的委托方法检查随机位置是否有有效的全景照片。如果没有,则指示查找新的搜索
// Delegate method of GMSPanoramaView that get´s called when didMoveToPanorama: is called
- (void)panoramaView:(GMSPanoramaView *)view didMoveToPanorama:(GMSPanorama *)panorama
nearCoordinate:(CLLocationCoordinate2D)coordinate
{
if (!panorama)
{
[self shuffleLocation];
}
}
- (void)shuffleLocation
{
CLLocationCoordinate2D newLocation = [self randomLatitudeLongitude];
[self.panoView moveNearCoordinate:newLocation];
}
(CLLocationCoordinate2D) randomLatitudeLongitude
{
CountryBBVal auBB = [[GGData SharedInstance] boundingBoxForCountry:Australia];
double ranLongitude = [self randomDoubleBetween: auBB.NELng and: auBB.SWLng]; // Boundix Box
double ranLatitude = [self randomDoubleBetween: auBB.NELat and: auBB.SWLat];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
[formatter setMaximumFractionDigits:4];
[formatter setDecimalSeparator:@"."];
NSString *formattedNumberLng = [formatter stringFromNumber:@(ranLongitude)];
NSString *formattedNumberLat = [formatter stringFromNumber:@(ranLatitude)];
CLLocationCoordinate2D ranLatLng = CLLocationCoordinate2DMake([formattedNumberLat doubleValue], [formattedNumberLng doubleValue]);
//NSLog(@"ranLatLng: [%f] [%f]", ranLatLng.latitude, ranLatLng.longitude);
return ranLatLng;
}
你所拥有的是一种不确定的寻找照片的方式,因此你无法控制它需要多长时间。您所编写的代码是最佳的,并且代码中没有性能改进。只有你这样做的算法不是最优的,你需要想一个更好的策略来获得一张随机照片 是的,如果有某种方法可以移动NearCoordinate:(谷歌SDK的一部分)不要那么挑剔,而是按照名字的意思去做,找到最近的坐标,这就行了。我想如果我想要另一个moveNearCoordinate:method,我需要直接访问Google Maps APIWell,Google SDK不是照片查找API,所以想一种在边界框中查找照片的方法。