Hi,
I have 2 questions about bingmap layer or googleMap layer.
1) I would like having bingmap layer as the base maps of our application but I have a problem with the proxy
The code is :
public class LayerBingMap : RasterLayerBase
{
public LayerBingMap(string nomLayer, string nomOverlay, int orderDisplay, bool? visible, ServicesMap servicesMap)
: base(nomLayer, nomOverlay, orderDisplay, visible, servicesMap)
{
this.NomLayerAffichage = “Bing”;
this.ProjectionAffichage = (int)CodeEPSGProjectionMap.GoogleBingMap;
}
internal override Layer CreateLayer(ReprojectionMap parametresPays, int projectionAffichage)
{
string applicationID = Invivo.Framework.Config.Default.GetString(“BingMapCleID”);
BingMapsLayer lyr = new BingMapsLayer(applicationID, BingMapsMapType.Aerial);
lyr.Name = NomLayer;
WebProxy proxyObject = (WebProxy)NetworkConnectionManager.Defaut.GetCurrentWebProxy(true);
lyr.Proxy = proxyObject;
return lyr;
}
}
}
I have a message error (ie. Bingmap_20140428.txt)
So I changed the code and I added :
public class LayerBingMap : RasterLayerBase
{
public LayerBingMap(string nomLayer, string nomOverlay, int orderDisplay, bool? visible, ServicesMap servicesMap)
: base(nomLayer, nomOverlay, orderDisplay, visible, servicesMap)
{
this.NomLayerAffichage = “Bing”;
this.ProjectionAffichage = (int)CodeEPSGProjectionMap.GoogleBingMap;
}
internal override Layer CreateLayer(ReprojectionMap parametresPays, int projectionAffichage)
{
string applicationID = Invivo.Framework.Config.Default.GetString(“BingMapCleID”);
BingMapsLayer lyr = new BingMapsLayer(applicationID, BingMapsMapType.Aerial);
lyr.Name = NomLayer;
WebProxy proxyObject = (WebProxy)NetworkConnectionManager.Defaut.GetCurrentWebProxy(true);
proxyObject.Credentials = CredentialCache.DefaultCredentials;
lyr.Proxy = proxyObject;
return lyr;
}
}
}
static UcMapOccupSolWorkspace()
{
AssemblyResolver.Initialize();
System.Net.WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials;
}
I can have the bingmap layer as baseMap and no proxy problem on my computer. (But on the pc of customers it will not work)
It’s not correct to use “CredentialCache.DefaultCredentials”.
But I don’t know where is the problem ?
And the other question, have you a sample with bingmap layer ?
Thanks a lot for your help.
Regards.
Steph.
ProxyBing_20140428.txt (3.13 KB)
Proxy problem with bingmap
Hi Steph,
For the first question, as we don’t have the context of NetworkConnectionManager, it is hard for us to recreate it, but it seems there is a similar thread about it, please check it: thinkgeo.com/forums/MapSuit…fault.aspx
For the second question, I am using the below codes to test and the bing map shows fine:
private
void
WpfMap_Loaded(
object
sender, RoutedEventArgs e)
{
Map1.MapUnit = GeographyUnit.Meter;
Map1.CurrentExtent =
new
RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
WorldMapKitWmsWpfOverlay worldOverlay =
new
WorldMapKitWmsWpfOverlay();
//Map1.Overlays.Add(“WMK”, worldOverlay);
BingMapsLayer binglayer =
new
BingMapsLayer(
“ApplicationId”
);
binglayer.SendingWebRequest +=
new
System.EventHandler<sendingwebrequesteventargs>(binglayer_SendingWebRequest);
//WebProxy proxyObject = HttpWebRequest.DefaultWebProxy as WebProxy;//(WebProxy)NetworkConnectionManager.Defaut.GetCurrentWebProxy(true);
//proxyObject.Credentials = CredentialCache.DefaultCredentials;
//binglayer.Proxy = proxyObject;
LayerOverlay overlay =
new
LayerOverlay();
overlay.Layers.Add(binglayer);
Map1.Overlays.Add(overlay);
Map1.Refresh();
}
void
binglayer_SendingWebRequest(
object
sender, SendingWebRequestEventArgs e)
{
e.WebRequest.Proxy = HttpWebRequest.DefaultWebProxy;
// or WebRequest.DefaultWebProxy
e.WebRequest.Credentials = CredentialCache.DefaultCredentials;
}
Hope it helps.
Regards,
Troy