Use Google Maps with Brutile

Mar 10, 2011 at 3:33 PM


I tried the Silverlight.Mapsui sample and it works with OSM maps.

Now I tried to use Google maps:

- in GUIOverlay.xaml I have the following code:

 private Map CreateMap()
            var map = new Map();
            var googleLayer = new TileLayer(new GoogleTileSource(GoogleMapType.GoogleSatellite)) { LayerName = "Google" };
            var pointProvider = new MemoryProvider(GenerateRandomPoints(osmLayer.Envelope));
            map.Layers.Add( new Layer("Points") { DataSource = pointProvider });
            return map;

in GoogleTileSource.cs I have this code:

 public class GoogleTileSource : ITileSource
        private readonly SphericalMercatorInvertedWorldSchema _tileSchema;
        private readonly WebTileProvider _tileProvider;
        public const string UserAgent = @"Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv: Gecko/2009060215 Firefox/3.0.11";
        private const string Referer = "";

        public GoogleTileSource(GoogleMapType mapType)
            : this(new GoogleRequest(mapType), new NullCache())
        public GoogleTileSource(GoogleRequest request)
            : this(request, new NullCache())
        public GoogleTileSource(GoogleRequest request, ITileCache<byte[]> fileCache)
            _tileSchema = new SphericalMercatorInvertedWorldSchema();
            _tileProvider = new WebTileProvider(request, fileCache, UserAgent, Referer, true);


Now I get a securityecxeption. I think it could be the clientaccess/crossdomain.xml problem with SL4.

I didn't find a solution. Does anybody have an idea how to solve that? Is it not necessary to have a valid Google Map Key?

The second problem is, that the point provider in the sample code doesn't show any points. Does anybody know about this problem?


Cheers stefan

Mar 11, 2011 at 5:16 PM
Edited Apr 23, 2011 at 9:19 AM

I have never got Google to work in Silverlight, since my method depends on faking the user agent which is nog possible in SL. 

One thing I havent looked at is the difference between ClientHttp and BrowserHttp. Perhaps with BrowserHttp there will be a different user agent.

Although the referer will still be problem I guess. Wonder how that works in the Google flash api:

I won't have time to look at it myself, be happy hear if you learned anything.

BTW, I assume the Google Maps license probably doesnt allow this without any special agreements.



Mar 17, 2011 at 1:45 PM

Hi Paul

thank you for the information.

It's a pity that this is not easy to realize. I think I gonna keep my fingers off.

So I try to go ahead with my sharpmap/brutile solution with my own data.

But it's pretty hard as my knowledge isn't that big to create the tile services.

cheers stefan

Apr 21, 2011 at 12:41 PM

the issue is that tile urls use some additional parameters, and they change versions pretty often, need add some auto-detection function

Apr 23, 2011 at 9:26 AM

hi radioman! Good to see you here. 

Could this explain why it does work in WPF but not in Silverlight? The Google Maps code that is now in BruTile is actually based on your GMaps code:


Apr 25, 2011 at 10:12 AM

static GoogleRequest()

// just update old versions or enable this somehow to work in sl too