Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

360 degree panorama street view in iOS from google map sdk

I want to show this location inside the map with out using Google Maps URL Scheme.I used GMSPanoramaView for showing street view by using given lat/long (53.426398,-2.242795) but inside building area not showing , that area is showing in browser or URL Scheme.

I used github demo code to show street view but I want to show exactly above location inside app.

I dont want to use webview ,safari or google map app.

like image 738
Vivek Yadav Avatar asked Jun 04 '14 11:06

Vivek Yadav


People also ask

How do I get 360 image from Google Street View?

Go to Google Maps and type in the address you'd like to view. In the lower right hand corner, you'll see the Street View icon. Select the icon and place it where you'd like to snap a 360 image within the map. Once, you set it down, you will see the 360 view.


2 Answers

I think you are missing

[panoramaView_ moveToPanoramaID:@"i3XJvXkmgNMAAAQW-ezYnQ"];
like image 54
Vivek Yadav Avatar answered Sep 19 '22 14:09

Vivek Yadav


It's possible! Extract the panoid from user2744623's post:

Here's an alternate link (used Embedder for Google Business View) https://maps.google.com/maps?layer=c&panoid=shcQTg4Y9qh9T0p5aspVvA&ie=UTF8&source=embed&output=svembed&cbp=13%2C213%2C%2C0%2C0

And then use it as a PanoramaID in the iOS SDK:

GMSPanoramaView *view_ = [GMSPanoramaView panoramaWithFrame:CGRectZero
                          nearCoordinate:CLLocationCoordinate2DMake(53.426398, -2.242795)];
[view_ moveToPanoramaID:@"shcQTg4Y9qh9T0p5aspVvA"];

You can then set GMSPanoramaCamera:cameraWithHeading:pitch:zoom: to whichever angle you prefer:

[GMSPanoramaCamera cameraWithHeading:200.0f pitch:-10.0f zoom:1];

Here's the official documentation on GMSPanoramaView:moveToPanoramaID::

Requests a panorama with panoramaID. Upon successful completion panoramaView:didMoveToPanorama: will be sent to GMSPanoramaViewDelegate. On error panoramaView:error:onMoveToPanoramaID: will be sent. Repeated calls to moveToPanoramaID: result in the previous pending (incomplete) transitions being cancelled -- only the most recent of moveNearCoordinate: and moveToPanoramaId: will proceed and generate events. Only panoramaIDs obtained from the Google Maps SDK for iOS are supported.

I think you can ignore the last sentence, heh.

Here's a complete-ish implementation, adapted from the SDK demo project:

@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
like image 38
friedbunny Avatar answered Sep 18 '22 14:09

friedbunny