ThinkGeo.com    |     Documentation    |     Premium Support

googleMapsLayer Issue

Google Map is not projecting correctly. Map is coming in a small portion. How to fix it Code is Given Below.

                        LayerOverlay lo = new LayerOverlay("World Map",true,TileType.SingleTile);
                        lo.TransitionEffect = TransitionEffect.Stretching;
                        wfMap.CustomOverlays.Add(lo);

                    GoogleMapsLayer googleLayer = new GoogleMapsLayer();
                    googleLayer.TileMode = ThinkGeo.MapSuite.Layers.GoogleMapsTileMode.SingleTile;
                    googleLayer.PictureFormat = ThinkGeo.MapSuite.Layers.GoogleMapsPictureFormat.Png8;
     
                    googleLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException;
                    WebProxy wp = new WebProxy(new Uri("https://maps.google.com/maps/api/js?key=*myKey*"));
                    googleLayer.WebProxy = wp;
                    
                    LayerOverlay worldOverlay = (LayerOverlay)wfMap.CustomOverlays["World Map"];
                    worldOverlay.TileType = TileType.SingleTile;
                    if (worldOverlay.Layers.Count > 0)
                        worldOverlay.Layers.Clear();
                    worldOverlay.Layers.Add("googleLayer", googleLayer);
                    wfMap.ZoomLevelSet = new GoogleMapsZoomLevelSet();
             
                    switch (googleOptions)
                    {
                        case "1": googleLayer.MapType = ThinkGeo.MapSuite.Layers.GoogleMapsMapType.RoadMap; break;
                        case "2": googleLayer.MapType = ThinkGeo.MapSuite.Layers.GoogleMapsMapType.Hybrid; break;
                        case "3": googleLayer.MapType = ThinkGeo.MapSuite.Layers.GoogleMapsMapType.Satellite;  break;
                        case "4": googleLayer.MapType = ThinkGeo.MapSuite.Layers.GoogleMapsMapType.Terrain;  break;
                        default: googleLayer.MapType = ThinkGeo.MapSuite.Layers.GoogleMapsMapType.Terrain; break;
                    }

Hi Bibek,

The proxy is not used for connect to google JS library, that’ why your code cannot works well.

The GoogleMapsLayer works for the static library, you should want to use it follow our API like this:

                Map1.MapUnit = GeographyUnit.Meter;
            Map1.CurrentExtent = new RectangleShape(-20000000, 20000000, 20000000, -20000000);
            
            LayerOverlay lo = new LayerOverlay("World Map", true, TileType.SingleTile);
            lo.TransitionEffect = TransitionEffect.Stretching;
            Map1.CustomOverlays.Add(lo);

            GoogleMapsLayer googleLayer = new GoogleMapsLayer("cachefolder", "myclientid", "myprivatekey");

            googleLayer.TileMode = ThinkGeo.MapSuite.Layers.GoogleMapsTileMode.SingleTile;
            googleLayer.PictureFormat = ThinkGeo.MapSuite.Layers.GoogleMapsPictureFormat.Png8;

            googleLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException;
            //WebProxy wp = new WebProxy(new Uri("https://maps.google.com/maps/api/js?key=*myKey*"));
            //googleLayer.WebProxy = wp;

            LayerOverlay worldOverlay = (LayerOverlay)Map1.CustomOverlays["World Map"];
            worldOverlay.TileType = TileType.SingleTile;
            if (worldOverlay.Layers.Count > 0)
                worldOverlay.Layers.Clear();
            worldOverlay.Layers.Add("googleLayer", googleLayer);
            Map1.ZoomLevelSet = new GoogleMapsZoomLevelSet();

            googleLayer.MapType = ThinkGeo.MapSuite.Layers.GoogleMapsMapType.Terrain;

It works well like this:

Regards,

Ethan