我想在地图中显示this位置而不使用谷歌地图URL方案。我使用GMSPanoramaView通过使用给定的纬度/经度来显示街景 (53.426398,-2.242795)< / em> 但在未显示的建筑区域内,该区域显示在浏览器或URL方案中。
我使用github demo代码显示街景,但我想在应用内部显示正好位置。
我不想使用webview,safari或谷歌地图应用。
答案 0 :(得分:5)
我认为你错过了
[panoramaView_ moveToPanoramaID:@"i3XJvXkmgNMAAAQW-ezYnQ"];
答案 1 :(得分:1)
有可能!从user2744623's post提取panoid
:
这是一个替代链接(用于Google商家视图的嵌入器)https://maps.google.com/maps?layer=c&panoid=shcQTg4Y9qh9T0p5aspVvA&ie=UTF8&source=embed&output=svembed&cbp=13%2C213%2C%2C0%2C0
然后在iOS SDK中将其用作PanoramaID
:
GMSPanoramaView *view_ = [GMSPanoramaView panoramaWithFrame:CGRectZero
nearCoordinate:CLLocationCoordinate2DMake(53.426398, -2.242795)];
[view_ moveToPanoramaID:@"shcQTg4Y9qh9T0p5aspVvA"];
然后,您可以将GMSPanoramaCamera:cameraWithHeading:pitch:zoom:
设置为您喜欢的任何角度:
[GMSPanoramaCamera cameraWithHeading:200.0f pitch:-10.0f zoom:1];
GMSPanoramaView:moveToPanoramaID:
上的Here's the official documentation:
请求
panoramaID
的全景图。 成功完成后,panoramaView:didMoveToPanorama:
将发送至GMSPanoramaViewDelegate
。错误panoramaView:error:onMoveToPanoramaID:
将被发送。重复调用moveToPanoramaID:
会导致之前的待处理(不完整)转化被取消 - 只有最新的moveNearCoordinate:
和moveToPanoramaId:
会继续生成事件。仅支持从Google Maps SDK for iOS获得的panoramaID
。
我认为你可以忽略最后一句话,呵呵。
这是一个完整的实现,改编自SDK演示项目:
@interface PanoramaViewController () <GMSPanoramaViewDelegate>
@end
@implementation PanoramaViewController {
GMSPanoramaView *view_;
BOOL configured_;
}
- (void)viewDidLoad {
[super viewDidLoad];
view_ = [GMSPanoramaView panoramaWithFrame:CGRectZero
nearCoordinate:CLLocationCoordinate2DMake(53.426398, -2.242795)];
view_.backgroundColor = [UIColor grayColor];
view_.delegate = self;
self.view = view_;
[view_ moveToPanoramaID:@"shcQTg4Y9qh9T0p5aspVvA"];
}
#pragma mark - GMSPanoramaDelegate
- (void)panoramaView:(GMSPanoramaView *)view
didMoveToPanorama:(GMSPanorama *)panorama {
if (!configured_) {
view_.camera = [GMSPanoramaCamera cameraWithHeading:200.0f pitch:-10.0f zoom:1];
configured_ = YES;
}
}
// Use to fine-tune initial heading and pitch
- (void)panoramaView:(GMSPanoramaView *)panoramaView
didMoveCamera:(GMSPanoramaCamera *)camera {
NSLog(@"Camera: (%f,%f,%f)", camera.orientation.heading, camera.orientation.pitch, camera.zoom);
}
// Helpful in finding other panorama IDs or debugging:
- (void)panoramaView:(GMSPanoramaView *)view
willMoveToPanoramaID:(NSString *)panoramaID {
NSLog(@"willMoveToPanoramaID: %@", panoramaID);
}
- (void)panoramaView:(GMSPanoramaView *)view
error:(NSError *)error
onMoveToPanoramaID:(NSString *)panoramaID {
NSLog(@"error: %@ onMoveToPanoramaID: %@", error, panoramaID);
}
@end
答案 2 :(得分:0)
您有两种选择。下载全景图或使用Google批准的许多方法之一来获取视图。
这是一个替代链接(用于Google Business View的Embedder) https://maps.google.com/maps?layer=c&panoid=shcQTg4Y9qh9T0p5aspVvA&ie=UTF8&source=embed&output=svembed&cbp=13%2C213%2C%2C0%2C0
使用Pano Fetch
抓住全景使用API - 以下是部分psudo代码,您需要少量的Javascript知识。
var your_pano = new google.maps.LatLng(53.426398,-2.242795);
var panoramaOptions2 = {
position: your_pano,
addressControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER
},
zoomControl: false,
linksControl: true,
panControl: false,
fov: 110,
pov: {
heading: 100,
pitch: -20
},
zoom: 0
};
var your_pano = new google.maps.StreetViewPanorama(
document.getElementById('your_pano'),
panoramaOptions2);
your_pano.setVisible(true);