diff --git a/GMap.NET.Core/GMap.NET.MapProviders/GMapProvider.cs b/GMap.NET.Core/GMap.NET.MapProviders/GMapProvider.cs
index e57d30f5..7f5b0a65 100644
--- a/GMap.NET.Core/GMap.NET.MapProviders/GMapProvider.cs
+++ b/GMap.NET.Core/GMap.NET.MapProviders/GMapProvider.cs
@@ -380,6 +380,18 @@ protected virtual bool CheckTileImageHttpResponse(WebResponse response)
//Debug.WriteLine(response.StatusCode + "/" + response.StatusDescription + "/" + response.ContentType + " -> " + response.ResponseUri);
return response.ContentType.Contains(responseContentType);
}
+
+ string Authorization = string.Empty;
+
+ ///
+ /// http://blog.kowalczyk.info/article/at3/Forcing-basic-http-authentication-for-HttpWebReq.html
+ ///
+ ///
+ ///
+ public void ForceBasicHttpAuthentication(string userName, string userPassword)
+ {
+ Authorization = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(userName + ":" + userPassword));
+ }
protected PureImage GetTileImageUsingHttp(string url)
{
@@ -400,7 +412,12 @@ protected PureImage GetTileImageUsingHttp(string url)
request.PreAuthenticate = true;
request.Credentials = Credential;
}
-
+
+ if(!string.IsNullOrEmpty(Authorization))
+ {
+ request.Headers.Set("Authorization", Authorization);
+ }
+
if (request is HttpWebRequest)
{
var r = request as HttpWebRequest;
@@ -490,6 +507,11 @@ protected string GetContentUsingHttp(string url)
request.PreAuthenticate = true;
request.Credentials = Credential;
}
+
+ if(!string.IsNullOrEmpty(Authorization))
+ {
+ request.Headers.Set("Authorization", Authorization);
+ }
if (request is HttpWebRequest)
{
diff --git a/GMap.NET.Core/GMap.NET.MapProviders/NearMap/NearMapProvider.cs b/GMap.NET.Core/GMap.NET.MapProviders/NearMap/NearMapProvider.cs
index 47b38cf7..15689997 100644
--- a/GMap.NET.Core/GMap.NET.MapProviders/NearMap/NearMapProvider.cs
+++ b/GMap.NET.Core/GMap.NET.MapProviders/NearMap/NearMapProvider.cs
@@ -4,14 +4,22 @@ namespace GMap.NET.MapProviders
using System;
using GMap.NET.Projections;
using System.Net;
+ using System.Text;
+ ///
+ /// http://en.wikipedia.org/wiki/NearMap
+ /// nearmap originally allowed personal use of images for free for non-enterprise users.
+ /// However this free access ended in December 2012, when the company modified its business model to user-pay
+ ///
public abstract class NearMapProviderBase : GMapProvider
{
public NearMapProviderBase()
{
// credentials doesn't work ;/
//Credential = new NetworkCredential("greatmaps", "greatmaps");
- }
+
+ //try ForceBasicHttpAuthentication(...);
+ }
#region GMapProvider Members
public override Guid Id
@@ -161,7 +169,13 @@ string MakeTileImageUrl(GPoint pos, int zoom, string language)
{
// http://web1.nearmap.com/maps/hl=en&x=18681&y=10415&z=15&nml=Map_&nmg=1&s=kY8lZssipLIJ7c5
// http://web1.nearmap.com/kh/v=nm&hl=en&x=20&y=8&z=5&nml=Map_&s=55KUZ
-
+
+ //http://maps.au.nearmap.com/api/0/authentication/checkticket?nmf=json&return200=true&callback=jQuery110206126813754172529_1431499242400&_=1431499242401
+ //jQuery110206126813754172529_1431499242400({"IncidentId":null,"AccountContext":{"AccountId":"account2574457","Username":"demo"},"Result":{"Ticket":{"Ticket":"1637726D061CB8B8A28BC98064443C96FB07008C16531B2F5100F98B9EBFE69C4083C88C920D3BF4C0768A27ADE9ECADF324A380DBF80C3C0982DC83374FE8EBF0F70868735351FC7","Expires":"\/Date(1432103400000)\/","CookieName":"nearmap_web3_app"},"Status":"Ok","Username":"demo","AccountId":"account2574457"}})
+
+ // http://web1.au.nearmap.com/maps/hl=en&x=1855837&y=1265913&z=21&nml=V&httpauth=false&version=2
+ // http://web2.au.nearmap.com/maps/hl=en&x=231977&y=158238&z=18&nml=Dem&httpauth=false&version=2
+
return string.Format(UrlFormat, GetServerNum(pos, 3), pos.X, pos.Y, zoom, GetSafeString(pos));
}