WMS with Google Maps on iOS

Screen Shot 2014-04-21 at 00.49.02Sample for using WMS sources in Google Maps SDK for iOS. available on github here: https://github.com/Sumbera/WMS_iOS_GoogleMapSDK
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)


There are two ways of overlaying WMS in the Google Maps for iOS SDK:

“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",

          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
  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
                                 Url:(NSString*) url
                            Receiver: (id<GMSTileReceiver>) receiver {
           UIImage             *image   = TileLoad(url,NO); 
           [receiver receiveTileWithX:x y:y zoom:zoom image:image]; 


both ways are used in this sample.

This entry was posted in Code, iOS, iPhone, Mobile, Objective-C, WMS and tagged , , . Bookmark the permalink.

6 Responses to WMS with Google Maps on iOS

  1. Oliver Nass says:

    Hi, great job!
    I have translate this program in Swift (also the program with MapKit).
    In MapKit only the image is shown.

    The problem with GoogleMap is, that the image and the background of the overlay is drawing always with white Color.
    With “overlay.opacity” the image ist transparent and the background is “white transparent”.

    Have you any idea to solve this?
    I can send you a screenshot.

    Thanks and greets

  2. Oliver Nass says:

    Ok, thanks a lot, I will try it with the OGC styles. Now I will delete the project in github and after completation I will upload again. The same for the translated swift version of your code with WMS and MapKit.

  3. Oliver says:

    Hi Stanislav, long time ago. Now I uploaded the project in github, updated with Swift 2.0: https://github.com/revilosun/WMS_GoogleMap_Swift
    The failure with the TRANSPARENT-Parameter is a bug in the simulator. On the device it looks good.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s