Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I threw together a quick implementation to do a lot of this as a demo for you. There are some excellent open source libraries out there that make an amateur version of StreetView very simple. You can check out my demo on GitHub: <a href="https://github.com/ocrickard/StreetViewDemo" rel="nofollow">https://github.com/ocrickard/StreetViewDemo</a></p> <p>You can use the heading and pitch parameters from the Google StreetView API to generate tiles. These tiles could be arranged in a UIScrollView as both Bilal and Geraud.ch suggest. However, I really like the JCTiledScrollView because it contains a pretty nice annotation system for adding pins on top of the images like Google does, and its datasource/delegate structure makes for some very straight forward image handling.</p> <p>The meaty parts of my implementation follow:</p> <pre><code>- (UIImage *)tiledScrollView:(JCTiledScrollView *)scrollView imageForRow:(NSInteger)row column:(NSInteger)column scale:(NSInteger)scale { float fov = 45.f / scale; float heading = fmodf(column*fov, 360.f); float pitch = (scale - row)*fov; if(lastRequestDate) { while(fabsf([lastRequestDate timeIntervalSinceNow]) &lt; 0.1f) { //continue only if the time interval is greater than 0.1 seconds } } lastRequestDate = [NSDate date]; int resolution = (scale &gt; 1.f) ? 640 : 200; NSString *path = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/streetview?size=%dx%d&amp;location=40.720032,-73.988354&amp;fov=%f&amp;heading=%f&amp;pitch=%f&amp;sensor=false", resolution, resolution, fov, heading, pitch]; NSError *error = nil; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:path] options:0 error:&amp;error]; if(error) { NSLog(@"Error downloading image:%@", error); } UIImage *image = [UIImage imageWithData:data]; //Distort image using GPUImage { //This is where you should try to transform the image. I messed around //with the math for awhile, and couldn't get it. Therefore, this is left //as an exercise for the reader... :) /* GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:image]; GPUImageTransformFilter *stillImageFilter = [[GPUImageTransformFilter alloc] init]; [stillImageFilter forceProcessingAtSize:image.size]; //This is actually based on some math, but doesn't work... //float xOffset = 200.f; //CATransform3D transform = [ViewController rectToQuad:CGRectMake(0, 0, image.size.width, image.size.height) quadTLX:-xOffset quadTLY:0 quadTRX:(image.size.width+xOffset) quadTRY:0.f quadBLX:0.f quadBLY:image.size.height quadBRX:image.size.width quadBRY:image.size.height]; //[(GPUImageTransformFilter *)stillImageFilter setTransform3D:transform]; //This is me playing guess and check... CATransform3D transform = CATransform3DIdentity; transform.m34 = fabsf(pitch) / 60.f * 0.3f; transform = CATransform3DRotate(transform, pitch*M_PI/180.f, 1.f, 0.f, 0.f); transform = CATransform3DScale(transform, 1.f/cosf(pitch*M_PI/180.f), sinf(pitch*M_PI/180.f) + 1.f, 1.f); transform = CATransform3DTranslate(transform, 0.f, 0.1f * sinf(pitch*M_PI/180.f), 0.f); [stillImageFilter setTransform3D:transform]; [stillImageSource addTarget:stillImageFilter]; [stillImageFilter prepareForImageCapture]; [stillImageSource processImage]; image = [stillImageFilter imageFromCurrentlyProcessedOutput]; */ } return image; } </code></pre> <p>Now, in order to get the full 360 degree, infinite scrolling effect Google has, you would have to do some trickery in the observeValueForKeyPath method where you observe the contentOffset of the UIScrollView. I've started implementing this, but did not finish it. The idea is that when the user reaches either the left or right side of the view, the <code>contentOffset</code> property of the scrollView is pushed to the opposite side of the scrollView. If you can get the content to align properly, and you set up the contentSize just right, this should work.</p> <p>Finally, I should note that the Google StreetView system has a limit of 10 images/second, so you have to throttle your requests or the IP address of the device will be blacklisted for a certain amount of time (my home internet is now blacked out from StreetView requests for the next few hours 'cause I didn't understand this at first).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload