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.

6 thoughts on “WMS with Google Maps on iOS

  1. Oliver Nass

    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

    1. Stanislav Post author

      Hi Oliver, make sure returned image from WMS is really transparent (&TRANSPARENT=TRUE In url request). It would be great if you can post your code on github or create Swift branch for this sample. It might be useful to check the code directly.

      1. Oliver

        Hi Stanislav, ok the url was correct. I created a repository on github (https://github.com/revilosun/WMS_GoogleMap_Swift).
        I’m new on iOS and Swift (and github :-) ), the sample is only to check the code.
        I need it to complete it with comments and proof of errors etc.

        I think it’s a problem with the GMSURLTileLayer.
        If I compile without the WMSTileOverlay, the “no data” always white.

      2. Stanislav Post author

        Hi Oliver, great, I have checked this URL : https://maps.dwd.de/geoserver/dwd/wms?LAYERS=Pollenflug_Graeser&STYLES=&SERVICE=WMS&VERSION=1.3&REQUEST=GetMap&SRS=EPSG:4326&width=256&height=256&format=image/png8&transparent=true&BBOX=5,41,28,57
        and also looked on your screenshots , it is all OK, returned map has color (in this case yellow) and you request bbox with transparency – that is happening and you can see this on your screenshots too – there is no visible white bbox – all area that is not filled with the color is transparent.
        In other words – the problem is that data are not transparent by itself, but I guess you can use OGC styles with WMS to set-up your own ‘fill style’. That said this is not Swift problem at all.

  2. Oliver Nass

    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.


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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.