Code Monkey home page Code Monkey logo

wms_ios_googlemapsdk's Introduction

WMS_iOS_GoogleMapSDK

Sample for using WMS sources in Google Maps SDK for iOS. Provide your API key in the WMSController.h

  • Google Maps for iOS used : 1.7.2 (April 2014)
  • used XCode 5.1.1 (April 2014)
  • iPad Air, iOS 7.1 (should run in iOS6.0 too)

youtube video

There are two ways of doing this:

  • "Method B": use GMSTileURLConstructor

         // -- method B. WMS tile layer with GMSTileURLConstructor
            GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger z) {
                BBox bbox = bboxFromXYZ(x,y,z);
                NSString *urlKN = [NSString stringWithFormat:@"Your WMS url&BBOX=%f,%f,%f,%f",
                                   bbox.left, bbox.bottom,bbox.right,bbox.top];
                
                return [NSURL URLWithString:urlKN];
            };
    
  • "Method A": use custom TileLayer derived from GMSTileLayer

  1. your derived class from GMSTileLayer (here WMSTileLayer.h) will receive tile request

       -(void)requestTileForX:(NSUInteger)x   y:(NSUInteger)y    zoom:(NSUInteger)z    receiver:(id<GMSTileReceiver>)receiver
    
  2. WMSTileLayer first checks for cached tile and if found calls :

        [self drawTileAtX:x y:y zoom:z Url:urlStr Receiver:receiver] ;
    
  3. if tile is not cached we download it, save it to the file system (using MD5 hash) and call to draw it

        [data  writeToFile: filePath  atomically:YES];
        [self drawTileAtX:x y: y zoom: z Url:urlStr Receiver:receiver] ;
    
  4. drawTileAtX is very simple:

        -(void) drawTileAtX: (NSUInteger) x   y:(NSUInteger)y    zoom:(NSUInteger)zoom   Url:(NSString*) url Receiver: (id<GMSTileReceiver>) receiver {
             UIImage             *image   = TileLoad(url,NO); // loads tile from file system
             [receiver receiveTileWithX:x y:y zoom:zoom image:image]; // pass it to the SDK API
        }
    

}

both ways are used in this sample.

wms_ios_googlemapsdk's People

Contributors

sumbera avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.