Hi
There is option in my web application that user can choose any GoogleOverLay, YahooOverLay, BingMapsOverLay, or WorldMapKitWmsWebOverlay at run time.
Everything works fine on first time.
(for example when user select WorldMapKitWmsWebOverlay or GoogleOverlay and then user add some layers like shp files at runtime…etc it works well)
But in next step after adding shp file
when user want to change background overlay again e.g. GoogleOverLay
then it does not work. no background changed
Is there is any Map1.refresh() function??
Following is my code; please guide me in this regard; how I can achieve this???
//this code fires when user click to choose thinkgeo background
protected void buttonThinkGeo_Click(object sender, ImageClickEventArgs e)
{
if (Map1.CustomOverlays.Contains("BackgroundOverlay")){
Map1.CustomOverlays.Remove("BackgroundOverlay");
}
WorldMapKitWmsWebOverlay wObj = new WorldMapKitWmsWebOverlay("BackgroundOverlay");
Map1.CustomOverlays.Insert(0, wObj);
}
//this code fires when user click to choose google background
protected void buttonGoogle_Click(object sender, ImageClickEventArgs e)
{
if (Map1.CustomOverlays.Contains("BackgroundOverlay")){
Map1.CustomOverlays.Remove("BackgroundOverlay");
}
GoogleOverlay google = new GoogleOverlay ("BackgroundOverlay");
google.JavaScriptLibraryUri = new ("path of google uri");
google.GoogleMapType = GoogleMapType.Normal;
Map1.CustomOverlays.Insert(0, google );
}
I will really appreciated if you can propose solution to achieve my problem?
Problem in adding CustomOverlays at runtime
Hi Zuhaib,
Thanks for your post, because every post back can be regarded as a map refresh() so the issue is not because of Map1.refresh() function as
As far as I know the problem might be caused by two reasons:
the first is the projection. Since the WorldMapKitWmsWebOverlay is under EPSG 4326, the GoogleOverlay or BingOverlay is under SphericalMercator projection system. So, we need to keep the shapelayer has a same projection with the basemap by converting shapelayer’s projection.
The second possible reason is we need to make sure that the LayerOverlay, which includes the shapefile layer, is not base overlay.
Attached code should fit your requirement, would you please get it and try it again?
if you have any more question , please feel free to let us know.
Best Regards
Summer
post11368.txt (2.71 KB)
Hi Zuhaib,
Thanks for your post, because every post back can be regarded as a map refresh() so the issue is not because of Map1.refresh() function as
As far as I know the problem might be caused by two reasons:
the first is the projection. Since the WorldMapKitWmsWebOverlay is under EPSG 4326, the GoogleOverlay or BingOverlay is under SphericalMercator projection system. So, we need to keep the shapelayer has a same projection with the basemap by converting shapelayer’s projection.
The second possible reason is we need to make sure that the LayerOverlay, which includes the shapefile layer, is not base overlay.
Attached code should fit your requirement, would you please get it and try it again?
if you have any more question , please feel free to let us know.
Best Regards
Summer
001_post11368.txt (2.71 KB)