ThinkGeo.com    |     Documentation    |     Premium Support

Bing maps background

Hi, I am trying to make a bing map background for my app. I found the sample only for google. The sample sometimes returns 403 error (why is that?), so I decided to try bing maps but I dont get any map at all. Where could be the problem?


 


//On form load
winformsMap1.MapUnit = GeographyUnit.Meter;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));
BingMapsOverlay bingOverlay = new BingMapsOverlay();
bingOverlay.MapType = BingMapsMapType.Birdseye;
winformsMap1.Overlays.Add(bingOverlay);
winformsMap1.ZoomLevelSet = new BingMapsZoomLevelSet();
winformsMap1.Refresh();


So is it possible to show bing or google maps on background?


With that code I cant see bing map.


And google maps sometimes return 403 error.


Am I the only one getting these problems?

How do I solve them?



Hello Hotter,


Thanks for your post, for use BingMapsOverlay in DesktopEdition, I think you need to set application id, see the code below:


bingOverlay.ApplicationId = "Your ApplicationID";


And you can get details about application id here:


help.live.com/help.aspx?mkt=...;query=faq


For the google problem, I also need ask do you have a valid application id for that, otherwise, it will have a 1000 limited every day, if you have the id, could you please debug your web browser and see what's the request and response when the 403 error happen?


I hope this can help.


Regards,


Gary



Yes this helped a bit. I entered bing Id and now see the map, but it isnt showing map in all aria sometimes:



And the point projection doesn't seem to be good:



I set projection like this:


Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3857);
pointLayer.FeatureSource.Projection = proj4;
double Longitude = -95.2809;
double Latitude = 38.9543;
Feature GPSFeature = new Feature(new PointShape(Longitude, Latitude));
pointLayer.InternalFeatures.Add(GPSFeature);

Is it possible to fix these two bugs?



Hello Hotter,  
  
 I’m glad it’s working now, for your new problem, reason is you didn’t use the right projection to you pointshape. you just need change: 
  
 proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
  
 Everything will be ok. 
  
 Regards, 
  
 Gary

No, doesnt help, same problems. Any other ideas?



Hello Hotter,


I think I can make it work in my side, could you please try this code below:



Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
                Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
                Map1.MapUnit = GeographyUnit.Meter;
            
                BingMapsOverlay bingMapsOverlay = new BingMapsOverlay("BingMaps Map");
                bingMapsOverlay.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["BingMapsUri"]);
                bingMapsOverlay.MapType = BingMapsStyle.Road;

                Proj4Projection proj4 = new Proj4Projection();
                proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
                proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();
                pointLayer.FeatureSource.Projection = proj4;
                double Longitude = -95.2809;
                double Latitude = 38.9543;
                Feature GPSFeature = new Feature(new PointShape(Longitude, Latitude));
                pointLayer.InternalFeatures.Add(GPSFeature);

                pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.PointType = PointType.Bitmap;
                pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = new GeoImage(MapPath("~/SampleData/USA/United States.png"));
                pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                
                LayerOverlay dynamicOverlay = new LayerOverlay("DynamicOverlay");
                dynamicOverlay.Layers.Add("ShapeLayer", pointLayer);
                dynamicOverlay.IsBaseOverlay = false;

                Map1.CustomOverlays.Add(bingMapsOverlay);
                Map1.CustomOverlays.Add(dynamicOverlay);

Regards,


Gary



Is this code for desktop edition? because I get lots of errors. I tried to fix it ant here is my code:

 


winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));
winformsMap1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
winformsMap1.MapUnit = GeographyUnit.Meter;

BingMapsOverlay bingOverlay = new BingMapsOverlay("myBingID");
bingOverlay.MapType = BingMapsMapType.Road;

Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();
pointLayer.FeatureSource.Projection = proj4;
double Longitude = -95.2809;
double Latitude = 38.9543;
Feature GPSFeature = new Feature(new PointShape(Longitude, Latitude));
pointLayer.InternalFeatures.Add(GPSFeature);

pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Square, GeoColor.StandardColors.Red, GeoColor.StandardColors.Black, 2, 12);
pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

LayerOverlay dynamicOverlay = new LayerOverlay();
dynamicOverlay.Layers.Add("ShapeLayer", pointLayer);
dynamicOverlay.IsBase = false;

winformsMap1.Overlays.Add(bingOverlay);
winformsMap1.Overlays.Add(dynamicOverlay);
winformsMap1.Refresh();


And the point is still in bad projection.

Hello Hotter,


Sorry I posted the Web Edition code.


I have tested your code in Desktop Edition, looks like everything is right, your pointshape shows in the right position, what's the problem have you met?



Regards,


Gary



Strange, I copied and pasted (added ID) that code too and this is what I get:




 


 Maybe I use old version of map suite? but I started using it before one month, so it shouldnt be old I guess. Runtime version v2.0.50727 Version 5.5.0.0.


Any ideas where could be the problem?



Hello Hotter, 
  
 5.5.0.0 is half years ago, could you please try the latest version 5.5.159.0 or later? 
  
 Regards, 
  
 Gary

Well if I look file properties on dll it shows 5,5,0,91 and in visual studio it shows file properties shows 5,5,0,0. Still having that problem... 



Hello Hotter, 
  
 You can ge the latest version from helpdesk.thinkgeo.com —> My Product Downloads—> Daily Development Builds, and you can get 5.5.157.0 or later to test. 
  
 If you still meet problem after refer the new dlls, could you please provide your sample to me? 
  
 Regards, 
  
 Gary

Thanks Gary, 5.5.157.0 fixed both my problems. But here is a new that I discovered. I have last zoom problem when I zoom out to much and bing map disappear. It happens on last zoom out when I zoom out with mouse scroll wheel. Maybe I can just remove one last zoom point?



Hello Hotter,


I'm glad the pointshape is working now, for your second question, one customer mentioned this before, his problem is when he zoom in too far map become blank, your problem is when you zoom out too far, map become blank.


Please check this post, we can't recreate his problem, could you please have a look at and point me if this is the same situation and how to recreate it?


gis.thinkgeo.com/Support/Dis...fault.aspx


Regards,


Gary



I think its the same. If you want to try recreate I can upload my project. I hope this helps.


So maybe we can avoid this by setting max zoom out or something? but I dont know if there is a way to set such max zoom. 



Hello Hotter,


Thanks for your sample, I can see the problem you mentioned, and I compare with the post I mentioned, I think it's different situation, we still can't recreate his problem.


We will do some more deep research on this, for now, you can ignore the zoomlevel01 as workaround, please see the code below, we can't delete or remove the default zoomlevelset, so we need use customzoomlevels to ignore the original one.



            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel02);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel03);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel04);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel05);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel06);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel07);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel08);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel09);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel10);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel11);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel12);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel13);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel14);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel15);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel16);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel17);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel18);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel19);
            winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(winformsMap1.ZoomLevelSet.ZoomLevel20);

Regards,


Gary



Hello Hotter, 
  
 We have fixed this problem in 6.0.1.0, you can update to the new dlls and remove the custom zoomlevel now. 
  
 Please let me know if you meet any problem after you update. 
  
 Regards, 
  
 Gary