Commit 757af8c1 authored by Gen Braga's avatar Gen Braga Committed by Benoît Minisini

Map.Proxy is a new property that allows to define the proxy used by all HTTP...

Map.Proxy is a new property that allows to define the proxy used by all HTTP requests made to retrieve the map tiles.

[GB.MAP]
* NEW: Map.Proxy is a new property that allows to define the proxy used by all HTTP requests made to retrieve the map tiles.
parent 315eb81d
......@@ -12,6 +12,8 @@ Property Read PixelBox As Rect
Property Read Bounds As MapBounds
Property Read Count As Integer
Property MaxZoom As Integer
Public _Proxy As _MapProxy
Property Read Proxy As _MapProxy ''Returns a object used for defining proxy parameters.
Private $iMaxZoom As Integer = 18
Private $iZoom As Integer = 1
Private $mpCenter As New MapPoint
......@@ -184,14 +186,14 @@ End
Public Sub AddTile(Name As String, Pattern As String, Optional Args As Collection, Optional CacheName As String) As _MapTile
Dim hLayer As New _MapTile(CacheName)
Dim hLayer As New _MapTile(CacheName, Me)
hLayer.Name = Name
'hLayer.Pattern = Pattern
hLayer.SetPattern(Pattern, Args)
$aLayers.Add(hLayer)
$aLayerNames.Add(Name)
Object.Attach(hLayer, Me, "Layer")
'Object.Attach(hLayer, Me, "Layer")
Return hLayer
End
......@@ -373,3 +375,10 @@ Private Sub MaxZoom_Write(Value As Integer)
$iMaxZoom = Value
End
Private Function Proxy_Read() As _MapProxy
If Not _Proxy Then _Proxy = New _MapProxy
Return _Proxy
End
\ No newline at end of file
......@@ -6,17 +6,15 @@ Inherits UserControl
Public Const _Properties As String = "*,Border{Border.*},AllowEffect=true,ShowControls=true"
Public Const _Group As String = "View"
Property Lock As Boolean
Property Border As Integer
Property Read {Map} As Map
Property AllowEffect As Boolean
Property ShowControls As Boolean
Property Mode As Integer
Private $iMode As Integer
Private $bShowControls As Boolean = True
Private $hCenter As MapPoint
Private $hMap As New Map As "Map"
Private $hView As DrawingArea
......@@ -364,4 +362,4 @@ Private Sub Mode_Write(Value As Integer)
End
End
\ No newline at end of file
......@@ -8,6 +8,14 @@ Dim hbound As MapBounds
'hImg = Scanners["hpaio:/net/HP_LaserJet_MFP_M426fdn?ip=192.168.1.25"].Scan()
'MapView1.Map.AddTile("gmap", "https://khms0.google.com/kh/v={version}?x={x}&y={y}&z={z}", ["version": "821"]).Copyright = "google"
'Authenticated proxy settings bellow
MapView1.Map.Proxy.Auth = Net.AuthBasic
MapView1.Map.Proxy.Type = Net.ProxyHTTP
MapView1.Map.Proxy.Host = "your-proxy-server"
MapView1.Map.Proxy.User = "your-proxy-user"
MapView1.Map.Proxy.Password = "your-proxy-password"
MapView1.Map.AddTile("OpenStreetMap", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", Null).Copyright = "© OpenStreetMap contributors"
MapView1.Map.Center = MapPoint(48.866667, 2.333333)
......
' Gambas class file
''' This virtual class allows to define proxy parameters.
Export
'' Return or set the HTTP authentication mode to use.
'' It can be one of the following constants
'' - Net.AuthNone (the Default)
'' - Net.AuthBasic
'' - Net.AuthNtlm
Public Auth As Integer
'' Return or set the proxy type.
'' It can be one Of the following constant:
'' - Net.ProxyHTTP (the Default)
'' - Net.ProxySocks5
Public Type As Integer
Public Host As String '' Return or set the proxy host name.
Public User As String '' Return or set the proxy user name.
Public Password As String '' Return or set the proxy password.
\ No newline at end of file
......@@ -9,9 +9,9 @@ Property Read Loading As Boolean
Property UseWebMapService As Boolean
Property WMSArgs As Collection
Property MaxBounds As MapBounds
''Delay before refreshing an image in the cache. (By default 30 day)
'' Delay before refreshing an image in the cache. (By default 30 day)
Property CacheRefreshDelay As Integer
''Set the projection used by the WMS server.
'' Set the projection used by the WMS server.
Property WMSProjection As String
Private $aStack As New String[]
......@@ -51,7 +51,7 @@ Private $bCacheRefresh As Boolean = True
' Private $bHaveCache As Boolean
Event Refresh
Public Sub _new(Optional CacheName As String)
Public Sub _new(Optional CacheName As String, Parent As Object)
Dim sTempPath As String
Dim hClient As HttpClient
......@@ -59,6 +59,7 @@ Public Sub _new(Optional CacheName As String)
'Dim hTable As Table
'db.Debug = True
Object.Attach(Me, Parent, "Layer")
$prjLatLon = New Proj("epsg:4326")
If CacheName Then
sTempPath = $sCachePath &/ CacheName
......@@ -77,6 +78,15 @@ Public Sub _new(Optional CacheName As String)
For i = 0 To $aClients.Max
hClient = New HttpClient As "Client"
hClient.Async = True
With GetMap()
If ._Proxy Then
hClient.Proxy.Auth = ._Proxy.Auth
hClient.Proxy.Type = ._Proxy.Type
hClient.Proxy.Host = ._Proxy.Host
hClient.Proxy.User = ._Proxy.User
hClient.Proxy.Password = ._Proxy.Password
Endif
End With
$aClients[i] = hClient
hClient.Timeout = 10
Next
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment