ThinkGeo.com    |     Documentation    |     Premium Support

(URGENT) URL or PATH to VIRTUAL EARTH (sry caps)

Hi everyone,


I have this code to put in background the layers of VE:


 


Code:


{


     Map1.BackgroundFillBrush = new GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"));  

      Map1.CurrentExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);  

      Map1.MapUnit = GeographyUnit.DecimalDegree;

 

      Map1.ClientCache.CacheId = "WorldLayer";  

      Map1.ServerCache.CacheDirectory = MapPath("~/ImageCache/" + Request.Path);  

   

      ShapeFileLayer worldLayer = new ShapeFileLayer(MapPath("~\World\cntry02.shp"));  

      worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.GetSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1);  

      worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  

     Map1.StaticLayers.Add("WorldLayer", worldLayer);

   

     Map1.BackgroundMap.VirtualEarthMap.VirtualEarthMapType = VirtualEarthMapType.Aerial;  

     Map1.BackgroundMap.VirtualEarthMap.Name = "Virtual Earth Map";

     Map1.BackgroundMap.VirtualEarthMap.LibraryUri = "";


}


 


My problem is: when i put the URL of VE (for example the code given in virtual maps) he say: "Cannot implicitly convert type 'string' to 'System.Uri". And the only options i have is VirtualEarthMap.LibraryUri or .Name or .VirtualEarthType so i need to put a string but he don´t accept


Anuone knows what i need to do to solve this?? 


Thanks



Fernando, 



You should use the following way to pass in a URL. 



Map1.BackgroundMap.VirtualEarthMap.LibraryUri = new URI("TheURLYouNeed"); 



Ben



Thanks man. You help me a lot, you can´t imagine. 
  
 One more thing please. Do you know what url i need to put for load Virtual Earth? 
  
 In the samples don´t appear, only the Google Earth url, but i need to work with the Virtual Earth. 
  
 Thanks

Fernando,  
  
 Here are some codes showing how to use virtual earth as background map. 
  
 
    Map1.BackgroundMap.VirtualEarthMap.VirtualEarthMapType = VirtualEarthMapType.Road;
    Map1.BackgroundMap.VirtualEarthMap.Name = "Virtual Earth Map";
    Map1.BackgroundMap.VirtualEarthMap.LibraryUri = new Uri("dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2");
 
  
 Ben.

Thanks again Ben. But i had try and it´s appear like a static image. 
  
 I can´t zoom in or out and can´t move with the mouse. 
  
 Maybe there are something to resolve this, no?

Fernando, 



Sorry forgot to let you know the current web edition (3.0.2) has some issues about integrating Virtual Earth. We have fixed that in the latest beta which will be released in about one week. Can you try the above code again with the new release later? 



Ben 

 



Thanks again Ben. 
  
 One question: when this new version comes out i need to do something or it´s already to work? 
  
 Thanks again for everything!!

And another question: It´s possible put the GE or VE background map and have my own shapefiles? 
  
 I had try but the shapefiles it´s like a staticlayer and i only can use one on the sametime. 
  
 I hope you understand me. But if not say something for i try explain better. 
  
 thanks

Fernando,

Sure you can integrate your shape file data with Virtual Earth / Google Map background. Here is some code with the latest edition which will be available pretty soon.


protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Map1.BackgroundFillBrush = new GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"));
                Map1.MapUnit = GeographyUnit.Meter;
                // Following is a proper extent for showing US in virtual earth, apparently, it doesn’t use Decimal Degrees. 
                Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
                Map1.MapControls.MousePosition.Enabled = true;

                // Create a shape file Layer including major cities in US
                ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(@“C:\Program Files\ThinkGeo\Map Suite Web Full Edition 3.0 (Beta)\Samples\CSharp Samples\SampleData\USA\cities_a.shp”);
                shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Black, 12f);
                shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                shapeFileFeatureLayer.DrawingMarginPercentage = 50;

                // We need to set the projection for the shapefile layer to make it as same as Virtual Earth
                Proj4Projection proj4 = new Proj4Projection();
                proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
                // VE has the same projection with GoogleMap, so we call the following method to get the projection string.
                proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                shapeFileFeatureLayer.FeatureSource.Projection = proj4;

                // Add the shapefile layer to layer overlay
                LayerOverlay layerOverLay = new LayerOverlay();
                layerOverLay.IsBaseOverlay = false;
                layerOverLay.Layers.Add(shapeFileFeatureLayer);

                // Create the virtual earth overlay
                VirtualEarthOverlay ve = new VirtualEarthOverlay(“VirtualEarth Map”);
                ve.VirtualEarthMapType = VirtualEarthMapType.Road;

                // Add the 2 overlays into map
                Map1.Overlays.Add(layerOverLay);
                Map1.Overlays.Add(ve);
            }
        }



Here is the result. The round black circle (I know that not looks good, just make it significant so you can tell it’s not from VE itself) is from the shape file I added with the above code. 



Ben.

Thanks one more time Ben.  
  
 I´ll wait for the new version to try all this. 
  


OK, hope you get all your issues solved with the new version. 
  
 Ben