From c1b55ef8c3f6c08eee13150bd0c111bc1bff5ee1 Mon Sep 17 00:00:00 2001 From: djes Date: Wed, 15 Mar 2017 15:33:37 +0100 Subject: [PATCH 1/4] "HERE" update --- PBMap.pb | 105 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 32 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index de583d5..28a3441 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -20,7 +20,9 @@ EnableExplicit InitNetwork() UsePNGImageDecoder() +UseJPEGImageDecoder() UsePNGImageEncoder() +UseJPEGImageEncoder() ;- Module declaration @@ -50,7 +52,9 @@ DeclareModule PBMap Declare SaveOptions(PreferencesFile.s = "PBMap.prefs") Declare.i AddOSMServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/") Declare.i AddHereServerLayer(LayerName.s, Order.i, APP_ID.s, APP_CODE.s, ServerURL.s = "aerial.maps.api.here.com", path.s = "/maptile/2.1/", ressource.s = "maptile", id.s = "newest", scheme.s = "satellite.day", format.s = "jpg", lg.s = "eng", lg2.s = "eng", param.s = "") - Declare DeleteLayer(Nb.i) + Declare DeleteLayer(*Ptr) + Declare EnableLayer(*Ptr) + Declare DisableLayer(*Ptr) Declare BindMapGadget(Gadget.i) Declare SetCallBackLocation(*CallBackLocation) Declare SetCallBackMainPointer(CallBackMainPointer.i) @@ -203,6 +207,7 @@ Module PBMap Name.s ServerURL.s ; Web URL ex: http://tile.openstreetmap.org/ LayerType.i ; OSM : 0 ; Here : 1 + Enabled.i ;> HERE specific params APP_ID.s APP_CODE.s @@ -760,13 +765,15 @@ Module PBMap ;-*** Layers + ; "OpenStreetMap" layer Procedure.i AddOSMServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/") Protected *Ptr = AddElement(PBMap\Layers()) If *Ptr PBMap\Layers()\Name = LayerName PBMap\Layers()\Order = Order PBMap\Layers()\ServerURL = ServerURL - PBMap\Layers()\LayerType = 0 + PBMap\Layers()\LayerType = 0 ; OSM + PBMap\Layers()\Enabled = #True SortStructuredList(PBMap\Layers(), #PB_Sort_Ascending, OffsetOf(Layer\Order),TypeOf(Layer\Order)) ProcedureReturn *Ptr Else @@ -774,6 +781,7 @@ Module PBMap EndIf EndProcedure + ; "Here" layer ;see there for parameters : https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/resource-base-maptile.html ;you could use base.maps.api.here.com or aerial.maps.api.here.com or traffic.maps.api.here.com or pano.maps.api.here.com. ;use *.cit.map.api.com For Customer Integration Testing (see https://developer.here.com/rest-apis/documentation/enterprise-Map-tile/common/request-cit-environment-rest.html) @@ -786,7 +794,8 @@ Module PBMap \ServerURL = ServerURL \path = path \ressource = ressource - \LayerType = 1 + \LayerType = 1 ; HERE + \Enabled = #True \APP_CODE = APP_CODE \APP_ID = APP_ID \format = format @@ -806,10 +815,24 @@ Module PBMap Procedure DeleteLayer(*Ptr) ChangeCurrentElement(PBMap\Layers(), *Ptr) DeleteElement(PBMap\Layers()) - FirstElement(PBMap\Layers()) SortStructuredList(PBMap\Layers(), #PB_Sort_Ascending, OffsetOf(Layer\Order),TypeOf(Layer\Order)) + FirstElement(PBMap\Layers()) EndProcedure - + + Procedure EnableLayer(*Ptr) + PushListPosition(PBMap\Layers()) + ChangeCurrentElement(PBMap\Layers(), *Ptr) + PBMap\Layers()\Enabled = #True + PopListPosition(PBMap\Layers()) + EndProcedure + + Procedure DisableLayer(*Ptr) + PushListPosition(PBMap\Layers()) + ChangeCurrentElement(PBMap\Layers(), *Ptr) + PBMap\Layers()\Enabled = #False + PopListPosition(PBMap\Layers()) + EndProcedure + ;-*** These are threaded Procedure.i GetTileFromHDD(CacheFile.s) @@ -1016,20 +1039,22 @@ Module PBMap EndIf EndIf With PBMap\Layers() - Select \LayerType - Case 0 ;OSM - URL = \ServerURL + Str(PBMap\Zoom) + "/" + Str(tilex) + "/" + Str(tiley) + ".png" - Case 1 ;Here - HereLoadBalancing = 1 + ((tiley + tilex) % 4) - ;{Base URL}{Path}{resource (tile type)}/{Map id}/{scheme}/{zoom}/{column}/{row}/{size}/{format}?app_id={YOUR_APP_ID}&app_code={YOUR_APP_CODE}&{param}={value} - URL = "https://" + StrU(HereLoadBalancing, #PB_Byte) + "." + \ServerURL + \path + \ressource + "/" + \id + "/" + \scheme + "/" + Str(PBMap\Zoom) + "/" + Str(tilex) + "/" + Str(tiley) + "/256/" + \format + "?app_id=" + \APP_ID + "&app_code" + \APP_CODE + "&lg=" + \lg + "&lg2=" + \lg2 - If \param <> "" - URL + "&" + \param - EndIf - EndSelect + Select \LayerType + Case 0 ;OSM + URL = \ServerURL + Str(PBMap\Zoom) + "/" + Str(tilex) + "/" + Str(tiley) + ".png" + ; Tile cache name based on y + CacheFile = DirName + slash + Str(tiley) + ".png" + Case 1 ;Here + HereLoadBalancing = 1 + ((tiley + tilex) % 4) + ;{Base URL}{Path}{resource (tile type)}/{Map id}/{scheme}/{zoom}/{column}/{row}/{size}/{format}?app_id={YOUR_APP_ID}&app_code={YOUR_APP_CODE}&{param}={value} + URL = "https://" + StrU(HereLoadBalancing, #PB_Byte) + "." + \ServerURL + \path + \ressource + "/" + \id + "/" + \scheme + "/" + Str(PBMap\Zoom) + "/" + Str(tilex) + "/" + Str(tiley) + "/256/" + \format + "?app_id=" + \APP_ID + "&app_code=" + \APP_CODE + "&lg=" + \lg + "&lg2=" + \lg2 + If \param <> "" + URL + "&" + \param + EndIf + ; Tile cache name based on y + CacheFile = DirName + slash + Str(tiley) + "." + \format + EndSelect EndWith - ; Tile cache name based on y - CacheFile = DirName + slash + Str(tiley) + ".png" *timg = GetTile(key, URL, CacheFile) If *timg\nImage <> -1 MovePathCursor(px, py) @@ -1562,7 +1587,9 @@ Module PBMap ;TODO add in layers of tiles ;this way we can cache them as 0 base 1.n layers ; such as for openseamap tiles which are overlaid. not that efficent from here though. ForEach PBMap\Layers() - DrawTiles(*Drawing, ListIndex(PBMap\Layers())) + If PBMap\Layers()\Enabled + DrawTiles(*Drawing, ListIndex(PBMap\Layers())) + EndIf Next If PBMap\Options\ShowTrack DrawTracks(*Drawing) @@ -2220,6 +2247,7 @@ CompilerIf #PB_Compiler_IsMainFile #Gdt_LoadGpx #Gdt_AddMarker #Gdt_AddOpenseaMap + #Gdt_AddHereMap #Gdt_Degrees #Gdt_EditMode #Gdt_ClearDiskCache @@ -2289,6 +2317,7 @@ CompilerIf #PB_Compiler_IsMainFile ResizeGadget(#Gdt_AddMarker,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_LoadGpx,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_AddOpenseaMap,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ResizeGadget(#Gdt_AddHereMap,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_Degrees,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_EditMode,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_ClearDiskCache,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) @@ -2321,11 +2350,12 @@ CompilerIf #PB_Compiler_IsMainFile ButtonGadget(#Gdt_AddMarker, 530, 280, 150, 30, "Add Marker") ButtonGadget(#Gdt_LoadGpx, 530, 310, 150, 30, "Load GPX") ButtonGadget(#Gdt_AddOpenseaMap, 530, 340, 150, 30, "Show/Hide OpenSeaMap", #PB_Button_Toggle) - ButtonGadget(#Gdt_Degrees, 530, 370, 150, 30, "Show/Hide Degrees", #PB_Button_Toggle) - ButtonGadget(#Gdt_EditMode, 530, 400, 150, 30, "Edit mode ON/OFF", #PB_Button_Toggle) - ButtonGadget(#Gdt_ClearDiskCache, 530, 430, 150, 30, "Clear disk cache", #PB_Button_Toggle) - TextGadget(#TextGeoLocationQuery, 530, 465, 150, 15, "Enter an address") - StringGadget(#StringGeoLocationQuery, 530, 480, 150, 20, "") + ButtonGadget(#Gdt_AddHereMap, 530, 370, 150, 30, "Show/Hide HERE Aerial", #PB_Button_Toggle) + ButtonGadget(#Gdt_Degrees, 530, 400, 150, 30, "Show/Hide Degrees", #PB_Button_Toggle) + ButtonGadget(#Gdt_EditMode, 530, 430, 150, 30, "Edit mode ON/OFF", #PB_Button_Toggle) + ButtonGadget(#Gdt_ClearDiskCache, 530, 460, 150, 30, "Clear disk cache", #PB_Button_Toggle) + TextGadget(#TextGeoLocationQuery, 530, 495, 150, 15, "Enter an address") + StringGadget(#StringGeoLocationQuery, 530, 510, 150, 20, "") SetActiveGadget(#StringGeoLocationQuery) AddKeyboardShortcut(#Window_0, #PB_Shortcut_Return, #MenuEventGeoLocationStringEnter) ;*** TODO : code to remove when the SetActiveGadget(-1) will be fixed @@ -2338,7 +2368,7 @@ CompilerIf #PB_Compiler_IsMainFile ;*** Define Event.i, Gadget.i, Quit.b = #False Define pfValue.d - Define OpenSeaMap = 0, Degrees = 1 + Define OpenSeaMap = 0, HereMap = 0, Degrees = 1 Define *Track ;Our main gadget @@ -2349,13 +2379,14 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::SetOption("Warning", "1") PBMap::SetOption("ShowMarkersLegend", "1") PBMap::SetOption("ShowTrackKms", "1") - PBMap::SetOption("ColourFocus", "$FFFF00AA") + PBMap::SetOption("ColourFocus", "$FFFF00AA") PBMap::MapGadget(#Map, 10, 10, 512, 512) PBMap::SetCallBackMainPointer(@MainPointer()) ; To change the main pointer (center of the view) PBMap::SetCallBackLocation(@UpdateLocation()) ; To obtain realtime coordinates PBMap::SetLocation(-36.81148, 175.08634,12) ; Change the PBMap coordinates PBMAP::SetMapScaleUnit(PBMAP::#SCALE_KM) ; To change the scale unit PBMap::AddMarker(49.0446828398, 2.0349812508, "", "", -1, @MyMarker()) ; To add a marker with a customised GFX + ;PBMap::AddHereServerLayer("Here", 3, "2WbegPQlhdWwkwF6rtBP", "Js2e6a82ovHndsSOu5vziw") Repeat Event = WaitWindowEvent() @@ -2396,14 +2427,24 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::AddMarker(ValD(GetGadgetText(#StringLatitude)), ValD(GetGadgetText(#StringLongitude)), "", "Test", RGBA(Random(255), Random(255), Random(255), 255)) Case #Gdt_AddOpenseaMap If OpenSeaMap = 0 - OpenSeaMap = PBMap::AddOSMServerLayer("OpenSeaMap", 2, "http://t1.openseamap.org/seamark/") ; Add a special osm overlay map on layer nb 2 + OpenSeaMap = PBMap::AddOSMServerLayer("OpenSeaMap", 3, "http://t1.openseamap.org/seamark/") ; Add a special osm overlay map on layer nb 3 SetGadgetState(#Gdt_AddOpenseaMap, 1) Else PBMap::DeleteLayer(OpenSeaMap) OpenSeaMap = 0 SetGadgetState(#Gdt_AddOpenseaMap, 0) EndIf - PBMAP::Refresh() + PBMap::Refresh() + Case #Gdt_AddHereMap + If HereMap = 0 + HereMap = PBMap::AddHereServerLayer("Here", 2, "2WbegPQlhdWwkwF6rtBP", "Js2e6a82ovHndsSOu5vziw") ; Add a here overlay map on layer nb 2 + SetGadgetState(#Gdt_AddHereMap, 1) + Else + PBMap::DeleteLayer(HereMap) + HereMap = 0 + SetGadgetState(#Gdt_AddHereMap, 0) + EndIf + PBMap::Refresh() Case #Gdt_Degrees Degrees = 1 - Degrees PBMap::SetOption("ShowDegrees", Str(Degrees)) @@ -2452,11 +2493,11 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf - ; IDE Options = PureBasic 5.60 beta 7 (Windows - x64) -; CursorPosition = 1037 -; FirstLine = 1000 -; Folding = ----------------- +; CursorPosition = 769 +; FirstLine = 751 +; Folding = ------------------ ; EnableThread ; EnableXP +; DisableDebugger ; EnableUnicode \ No newline at end of file From 2346bf3b335154d1df5ce01866f428e3e0f10f5f Mon Sep 17 00:00:00 2001 From: djes Date: Wed, 15 Mar 2017 18:17:51 +0100 Subject: [PATCH 2/4] "HERE" addons and layer modifications Layers are now map and list based to facilitate ordering and deletion --- PBMap.pb | 157 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 96 insertions(+), 61 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 28a3441..e195f75 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -51,10 +51,11 @@ DeclareModule PBMap Declare LoadOptions(PreferencesFile.s = "PBMap.prefs") Declare SaveOptions(PreferencesFile.s = "PBMap.prefs") Declare.i AddOSMServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/") - Declare.i AddHereServerLayer(LayerName.s, Order.i, APP_ID.s, APP_CODE.s, ServerURL.s = "aerial.maps.api.here.com", path.s = "/maptile/2.1/", ressource.s = "maptile", id.s = "newest", scheme.s = "satellite.day", format.s = "jpg", lg.s = "eng", lg2.s = "eng", param.s = "") - Declare DeleteLayer(*Ptr) - Declare EnableLayer(*Ptr) - Declare DisableLayer(*Ptr) + Declare.i AddHereServerLayer(LayerName.s, Order.i, APP_ID.s = "", APP_CODE.s = "", ServerURL.s = "aerial.maps.api.here.com", path.s = "/maptile/2.1/", ressource.s = "maptile", id.s = "newest", scheme.s = "satellite.day", format.s = "jpg", lg.s = "eng", lg2.s = "eng", param.s = "") + Declare IsLayer(Name.s) + Declare DeleteLayer(Name.s) + Declare EnableLayer(Name.s) + Declare DisableLayer(Name.s) Declare BindMapGadget(Gadget.i) Declare SetCallBackLocation(*CallBackLocation) Declare SetCallBackMainPointer(CallBackMainPointer.i) @@ -200,6 +201,9 @@ Module PBMap ColourFocus.i ColourSelected.i ColourTrackDefault.i + ;HERE specific + appid.s + appcode.s EndStructure Structure Layer @@ -221,7 +225,7 @@ Module PBMap lg2.s ;< EndStructure - + Structure Box x1.i y1.i @@ -255,7 +259,8 @@ Module PBMap PixelCoordinates.PixelCoordinates ; Actual focus point coords in pixels (global) MoveStartingPoint.PixelCoordinates ; Start mouse position coords when dragging the map - List Layers.Layer() ; + List LayersList.Layer() + Map *Layers.Layer() Angle.d ZoomMin.i ; Min Zoom supported by server @@ -284,7 +289,7 @@ Module PBMap ;-*** Global variables ;-Show debug infos - Global MyDebugLevel = 0 + Global MyDebugLevel = 2 Global PBMap.PBMap, Null.i Global slash.s @@ -625,6 +630,10 @@ Module PBMap PBMap\Options\ProxyPort = Value Case "proxyuser" PBMap\Options\ProxyUser = Value + Case "appid" + PBMap\Options\appid = Value + Case "appcode" + PBMap\Options\appcode = Value Case "tilescachepath" PBMap\Options\HDDCachePath = Value Case "maxmemcache" @@ -677,6 +686,9 @@ Module PBMap WritePreferenceString("ProxyURL", \ProxyURL) WritePreferenceString("ProxyPort", \ProxyPort) WritePreferenceString("ProxyUser", \ProxyUser) + PreferenceGroup("HERE") + WritePreferenceString("APP_ID", \appid) + WritePreferenceString("APP_CODE", \appcode) PreferenceGroup("URL") WritePreferenceString("DefaultOSMServer", \DefaultOSMServer) PreferenceGroup("PATHS") @@ -723,6 +735,9 @@ Module PBMap ; WritePreferenceString("ProxyPort", "myproxyport") ; WritePreferenceString("ProxyUser", "myproxyname") ; WritePreferenceString("ProxyPass", "myproxypass") ;TODO !Warning! !not encoded! + ; PreferenceGroup("HERE") + ; WritePreferenceString("APP_ID", "myhereid") ;TODO !Warning! !not encoded! + ; WritePreferenceString("APP_CODE", "myherecode") ;TODO !Warning! !not encoded! ; ClosePreferences() With PBMap\Options PreferenceGroup("PROXY") @@ -731,8 +746,11 @@ Module PBMap \ProxyURL = ReadPreferenceString("ProxyURL", "") ;InputRequester("ProxyServer", "Do you use a Proxy Server? Then enter the full url:", "") \ProxyPort = ReadPreferenceString("ProxyPort", "") ;InputRequester("ProxyPort" , "Do you use a specific port? Then enter it", "") \ProxyUser = ReadPreferenceString("ProxyUser", "") ;InputRequester("ProxyUser" , "Do you use a user name? Then enter it", "") - \ProxyPassword = InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO + \ProxyPassword = ReadPreferenceString("ProxyPass", "") ;InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO EndIf + PreferenceGroup("HERE") + \appid = ReadPreferenceString("APP_ID", "") ;InputRequester("Here App ID", "Do you use HERE ? Enter app ID", "") ;TODO + \appcode = ReadPreferenceString("APP_CODE", "") ;InputRequester("Here App Code", "Do you use HERE ? Enter app Code", "") ;TODO PreferenceGroup("URL") \DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/") @@ -765,16 +783,31 @@ Module PBMap ;-*** Layers + ;Add a layer to a list (to get things ordered) and to a map (to access things easily) + Procedure.i AddLayer(Name.s, Order.i) + Protected *Ptr = 0 + *Ptr = AddMapElement(PBMap\Layers(), Name) + If *Ptr + PBMap\Layers() = AddElement(PBMap\LayersList()) ; This map element is a ptr to a linked list element + If PBMap\Layers() + PBMap\LayersList()\Name = Name + PBMap\LayersList()\Order = Order + ProcedureReturn PBMap\Layers() + Else + *Ptr = 0 + EndIf + EndIf + ProcedureReturn *Ptr + EndProcedure + ; "OpenStreetMap" layer Procedure.i AddOSMServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/") - Protected *Ptr = AddElement(PBMap\Layers()) + Protected *Ptr.Layer = AddLayer(LayerName, Order) If *Ptr - PBMap\Layers()\Name = LayerName - PBMap\Layers()\Order = Order - PBMap\Layers()\ServerURL = ServerURL - PBMap\Layers()\LayerType = 0 ; OSM - PBMap\Layers()\Enabled = #True - SortStructuredList(PBMap\Layers(), #PB_Sort_Ascending, OffsetOf(Layer\Order),TypeOf(Layer\Order)) + *Ptr\ServerURL = ServerURL + *Ptr\LayerType = 0 ; OSM + *Ptr\Enabled = #True + SortStructuredList(PBMap\LayersList(), #PB_Sort_Ascending, OffsetOf(Layer\Order),TypeOf(Layer\Order)) ProcedureReturn *Ptr Else ProcedureReturn #False @@ -785,17 +818,21 @@ Module PBMap ;see there for parameters : https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/resource-base-maptile.html ;you could use base.maps.api.here.com or aerial.maps.api.here.com or traffic.maps.api.here.com or pano.maps.api.here.com. ;use *.cit.map.api.com For Customer Integration Testing (see https://developer.here.com/rest-apis/documentation/enterprise-Map-tile/common/request-cit-environment-rest.html) - Procedure.i AddHereServerLayer(LayerName.s, Order.i, APP_ID.s, APP_CODE.s, ServerURL.s = "aerial.maps.api.here.com", path.s = "/maptile/2.1/", ressource.s = "maptile", id.s = "newest", scheme.s = "satellite.day", format.s = "jpg", lg.s = "eng", lg2.s = "eng", param.s = "") - Protected *Ptr = AddElement(PBMap\Layers()) + Procedure.i AddHereServerLayer(LayerName.s, Order.i, APP_ID.s = "", APP_CODE.s = "", ServerURL.s = "aerial.maps.api.here.com", path.s = "/maptile/2.1/", ressource.s = "maptile", id.s = "newest", scheme.s = "satellite.day", format.s = "jpg", lg.s = "eng", lg2.s = "eng", param.s = "") + Protected *Ptr.Layer = AddLayer(LayerName, Order) If *Ptr - With PBMap\Layers() - \Name = LayerName - \Order = Order + With *Ptr;PBMap\Layers() \ServerURL = ServerURL \path = path \ressource = ressource \LayerType = 1 ; HERE \Enabled = #True + If APP_ID = "" + APP_ID = PBMap\Options\appid + EndIf + If APP_CODE = "" + APP_CODE = PBMap\Options\appcode + EndIf \APP_CODE = APP_CODE \APP_ID = APP_ID \format = format @@ -805,32 +842,33 @@ Module PBMap \param = param \scheme = scheme EndWith - SortStructuredList(PBMap\Layers(), #PB_Sort_Ascending, OffsetOf(Layer\Order),TypeOf(Layer\Order)) + SortStructuredList(PBMap\LayersList(), #PB_Sort_Ascending, OffsetOf(Layer\Order),TypeOf(Layer\Order)) ProcedureReturn *Ptr Else ProcedureReturn #False EndIf EndProcedure - Procedure DeleteLayer(*Ptr) - ChangeCurrentElement(PBMap\Layers(), *Ptr) - DeleteElement(PBMap\Layers()) - SortStructuredList(PBMap\Layers(), #PB_Sort_Ascending, OffsetOf(Layer\Order),TypeOf(Layer\Order)) - FirstElement(PBMap\Layers()) + Procedure.i IsLayer(Name.s) + ProcedureReturn FindMapElement(PBMap\Layers(), Name) EndProcedure - Procedure EnableLayer(*Ptr) - PushListPosition(PBMap\Layers()) - ChangeCurrentElement(PBMap\Layers(), *Ptr) - PBMap\Layers()\Enabled = #True - PopListPosition(PBMap\Layers()) + Procedure DeleteLayer(Name.s) + FindMapElement(PBMap\Layers(), Name) + Protected *Ptr = PBMap\Layers() + ;Free the list element + ChangeCurrentElement(PBMap\LayersList(), *Ptr) + DeleteElement(PBMap\LayersList()) + ;Free the map element + DeleteMapElement(PBMap\Layers()) EndProcedure - Procedure DisableLayer(*Ptr) - PushListPosition(PBMap\Layers()) - ChangeCurrentElement(PBMap\Layers(), *Ptr) - PBMap\Layers()\Enabled = #False - PopListPosition(PBMap\Layers()) + Procedure EnableLayer(Name.s) + PBMap\Layers(Name)\Enabled = #True + EndProcedure + + Procedure DisableLayer(Name.s) + PBMap\Layers(Name)\Enabled = #False EndProcedure ;-*** These are threaded @@ -987,7 +1025,7 @@ Module PBMap ProcedureReturn *timg EndProcedure - Procedure DrawTiles(*Drawing.DrawingParameters, Layer) + Procedure DrawTiles(*Drawing.DrawingParameters, LayerName.s) Protected x.i, y.i,kq.q Protected tx = Int(*Drawing\TileCoordinates\x) ;Don't forget the Int() ! Protected ty = Int(*Drawing\TileCoordinates\y) @@ -997,7 +1035,7 @@ Module PBMap Protected URL.s, CacheFile.s Protected tilemax = 1<= 0 And tiley < tilemax kq = (PBMap\Zoom << 8) | (tilex << 16) | (tiley << 36) - key = PBMap\Layers()\Name + Str(kq) + key = LayerName + Str(kq) ; Creates the cache tree based on the OSM tree+Layer : layer/zoom/x/y.png - Protected DirName.s = PBMap\Options\HDDCachePath + PBMap\Layers()\Name + Protected DirName.s = PBMap\Options\HDDCachePath + LayerName If FileSize(DirName) <> -2 If CreateDirectory(DirName) = #False ; Creates a directory based on the layer name Error("Can't create the following layer directory : " + DirName) @@ -1038,7 +1076,7 @@ Module PBMap MyDebug(DirName + " successfully created", 4) EndIf EndIf - With PBMap\Layers() + With PBMap\LayersList() Select \LayerType Case 0 ;OSM URL = \ServerURL + Str(PBMap\Zoom) + "/" + Str(tilex) + "/" + Str(tiley) + ".png" @@ -1552,6 +1590,7 @@ Module PBMap Protected *Drawing.DrawingParameters = @PBMap\Drawing Protected PixelCenter.PixelCoordinates Protected Px.d, Py.d,a, ts = PBMap\TileSize, nx, ny + Protected LayerOrder.i = 0 Protected NW.Coordinates, SE.Coordinates PBMap\Dirty = #False PBMap\Redraw = #False @@ -1586,9 +1625,9 @@ Module PBMap FillVectorOutput() ;TODO add in layers of tiles ;this way we can cache them as 0 base 1.n layers ; such as for openseamap tiles which are overlaid. not that efficent from here though. - ForEach PBMap\Layers() - If PBMap\Layers()\Enabled - DrawTiles(*Drawing, ListIndex(PBMap\Layers())) + ForEach PBMap\LayersList() + If PBMap\LayersList()\Enabled + DrawTiles(*Drawing, PBMap\LayersList()\Name) EndIf Next If PBMap\Options\ShowTrack @@ -2368,7 +2407,7 @@ CompilerIf #PB_Compiler_IsMainFile ;*** Define Event.i, Gadget.i, Quit.b = #False Define pfValue.d - Define OpenSeaMap = 0, HereMap = 0, Degrees = 1 + Define Degrees = 1 Define *Track ;Our main gadget @@ -2386,7 +2425,6 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::SetLocation(-36.81148, 175.08634,12) ; Change the PBMap coordinates PBMAP::SetMapScaleUnit(PBMAP::#SCALE_KM) ; To change the scale unit PBMap::AddMarker(49.0446828398, 2.0349812508, "", "", -1, @MyMarker()) ; To add a marker with a customised GFX - ;PBMap::AddHereServerLayer("Here", 3, "2WbegPQlhdWwkwF6rtBP", "Js2e6a82ovHndsSOu5vziw") Repeat Event = WaitWindowEvent() @@ -2426,23 +2464,21 @@ CompilerIf #PB_Compiler_IsMainFile Case #Gdt_AddMarker PBMap::AddMarker(ValD(GetGadgetText(#StringLatitude)), ValD(GetGadgetText(#StringLongitude)), "", "Test", RGBA(Random(255), Random(255), Random(255), 255)) Case #Gdt_AddOpenseaMap - If OpenSeaMap = 0 - OpenSeaMap = PBMap::AddOSMServerLayer("OpenSeaMap", 3, "http://t1.openseamap.org/seamark/") ; Add a special osm overlay map on layer nb 3 - SetGadgetState(#Gdt_AddOpenseaMap, 1) - Else - PBMap::DeleteLayer(OpenSeaMap) - OpenSeaMap = 0 + If PBMap::IsLayer("OpenSeaMap") + PBMap::DeleteLayer("OpenSeaMap") SetGadgetState(#Gdt_AddOpenseaMap, 0) + Else + PBMap::AddOSMServerLayer("OpenSeaMap", 3, "http://t1.openseamap.org/seamark/") ; Add a special osm overlay map on layer nb 3 + SetGadgetState(#Gdt_AddOpenseaMap, 1) EndIf PBMap::Refresh() Case #Gdt_AddHereMap - If HereMap = 0 - HereMap = PBMap::AddHereServerLayer("Here", 2, "2WbegPQlhdWwkwF6rtBP", "Js2e6a82ovHndsSOu5vziw") ; Add a here overlay map on layer nb 2 - SetGadgetState(#Gdt_AddHereMap, 1) - Else - PBMap::DeleteLayer(HereMap) - HereMap = 0 + If PBMap::IsLayer("Here") + PBMap::DeleteLayer("Here") SetGadgetState(#Gdt_AddHereMap, 0) + Else + PBMap::AddHereServerLayer("Here", 2) ; Add a here overlay map on layer nb 2 + SetGadgetState(#Gdt_AddHereMap, 1) EndIf PBMap::Refresh() Case #Gdt_Degrees @@ -2494,10 +2530,9 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf ; IDE Options = PureBasic 5.60 beta 7 (Windows - x64) -; CursorPosition = 769 -; FirstLine = 751 +; CursorPosition = 57 +; FirstLine = 32 ; Folding = ------------------ ; EnableThread ; EnableXP -; DisableDebugger ; EnableUnicode \ No newline at end of file From 6bdb4880b672252523ce93215b4d252a0ec0f5c7 Mon Sep 17 00:00:00 2001 From: djes Date: Mon, 20 Mar 2017 11:48:40 +0100 Subject: [PATCH 3/4] Not threadable HTTPProxy bugfixing, plus the not threadable httpproxy() fix --- PBMap.pb | 72 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 33d7d95..aed1312 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -289,7 +289,7 @@ Module PBMap ;-*** Global variables ;-Show debug infos - Global MyDebugLevel = 2 + Global MyDebugLevel = 3 Global PBMap.PBMap, Null.i Global slash.s @@ -743,14 +743,14 @@ Module PBMap PreferenceGroup("PROXY") \Proxy = ReadPreferenceInteger("Proxy", #False) If \Proxy - \ProxyURL = ReadPreferenceString("ProxyURL", "") ;InputRequester("ProxyServer", "Do you use a Proxy Server? Then enter the full url:", "") - \ProxyPort = ReadPreferenceString("ProxyPort", "") ;InputRequester("ProxyPort" , "Do you use a specific port? Then enter it", "") - \ProxyUser = ReadPreferenceString("ProxyUser", "") ;InputRequester("ProxyUser" , "Do you use a user name? Then enter it", "") - \ProxyPassword = ReadPreferenceString("ProxyPass", "") ;InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO + \ProxyURL = ReadPreferenceString("ProxyURL", "") ; = InputRequester("ProxyServer", "Do you use a Proxy Server? Then enter the full url:", "") + \ProxyPort = ReadPreferenceString("ProxyPort", "") ; = InputRequester("ProxyPort" , "Do you use a specific port? Then enter it", "") + \ProxyUser = ReadPreferenceString("ProxyUser", "") ; = InputRequester("ProxyUser" , "Do you use a user name? Then enter it", "") + \ProxyPassword = ReadPreferenceString("ProxyPass", "") ; = InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO EndIf PreferenceGroup("HERE") - \appid = ReadPreferenceString("APP_ID", "") ;InputRequester("Here App ID", "Do you use HERE ? Enter app ID", "") ;TODO - \appcode = ReadPreferenceString("APP_CODE", "") ;InputRequester("Here App Code", "Do you use HERE ? Enter app Code", "") ;TODO + \appid = ReadPreferenceString("APP_ID", "") ; = InputRequester("Here App ID", "Do you use HERE ? Enter app ID", "") ;TODO + \appcode = ReadPreferenceString("APP_CODE", "") ; = InputRequester("Here App Code", "Do you use HERE ? Enter app Code", "") ;TODO PreferenceGroup("URL") \DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/") @@ -875,13 +875,15 @@ Module PBMap Procedure.i GetTileFromHDD(CacheFile.s) Protected nImage.i - If FileSize(CacheFile) > 0 + If FileSize(CacheFile) <> -1 nImage = LoadImage(#PB_Any, CacheFile) If IsImage(nImage) MyDebug("Success loading " + CacheFile + " as nImage " + Str(nImage), 3) ProcedureReturn nImage Else MyDebug("Failed loading " + CacheFile + " as nImage " + Str(nImage) + " -> not an image !", 3) + MyDebug("Deleting faulty image file " + CacheFile, 3) + DeleteFile(CacheFile) EndIf Else MyDebug("Failed loading " + CacheFile + " -> Size <= 0", 3) @@ -893,9 +895,6 @@ Module PBMap Protected *Buffer Protected nImage.i = -1 Protected FileSize.i, timg - If PBMap\Options\Proxy - HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) - EndIf FileSize = ReceiveHTTPFile(TileURL, CacheFile) If FileSize > 0 MyDebug("Loaded from web " + TileURL + " as CacheFile " + CacheFile, 3) @@ -936,7 +935,7 @@ Module PBMap MyDebug("Image key : " + *Tile\key + " web image loaded", 3) *Tile\RetryNb = 0 Else - MyDebug("Image key : " + *Tile\key + " web image not correctly loaded", 3) + MyDebug("Image key : " + *Tile\key + " web image not correctly loaded, will retry in 2 secs", 3) Delay(2000) *Tile\RetryNb - 1 EndIf @@ -2189,6 +2188,16 @@ Module PBMap ; Could be called directly to attach our map to an existing canvas Procedure BindMapGadget(Gadget.i) + If PBMap\Options\Verbose + OpenConsole() + EndIf + If PBMap\Options\Proxy + HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) + EndIf + CreateDirectoryEx(PBMap\Options\HDDCachePath) + If PBMap\Options\DefaultOSMServer <> "" + AddOSMServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer) + EndIf PBMap\Gadget = Gadget BindGadgetEvent(PBMap\Gadget, @CanvasEvents()) AddWindowTimer(PBMap\Window, PBMap\Timer, PBMap\Options\TimerInterval) @@ -2199,6 +2208,16 @@ Module PBMap ; Creates a canvas and attach our map Procedure MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i) + If PBMap\Options\Verbose + OpenConsole() + EndIf + If PBMap\Options\Proxy + HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) + EndIf + CreateDirectoryEx(PBMap\Options\HDDCachePath) + If PBMap\Options\DefaultOSMServer <> "" + AddOSMServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer) + EndIf If Gadget = #PB_Any PBMap\Gadget = CanvasGadget(PBMap\Gadget, X, Y, Width, Height, #PB_Canvas_Keyboard) ;#PB_Canvas_Keyboard has to be set for mousewheel to work on windows Else @@ -2235,7 +2254,7 @@ Module PBMap Procedure InitPBMap(Window) Protected Result.i - PBMap\ZoomMin = 0 + PBMap\ZoomMin = 1 PBMap\ZoomMax = 18 PBMap\Dragging = #False PBMap\TileSize = 256 @@ -2246,13 +2265,6 @@ Module PBMap PBMap\Timer = 1 PBMap\Mode = #MODE_DEFAULT LoadOptions() - If PBMap\Options\Verbose - OpenConsole() - EndIf - CreateDirectoryEx(PBMap\Options\HDDCachePath) - If PBMap\Options\DefaultOSMServer <> "" - AddOSMServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer) - EndIf TechnicalImagesCreation() SetLocation(0, 0) EndProcedure @@ -2418,6 +2430,7 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::InitPBMap(#Window_0) PBMap::SetOption("ShowDegrees", "0") : Degrees = 0 PBMap::SetOption("ShowDebugInfos", "0") + PBMap::SetOption("Verbose", "0") PBMap::SetOption("ShowScale", "1") PBMap::SetOption("Warning", "1") PBMap::SetOption("ShowMarkersLegend", "1") @@ -2481,12 +2494,9 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::DeleteLayer("Here") SetGadgetState(#Gdt_AddHereMap, 0) Else -<<<<<<< HEAD - PBMap::AddHereServerLayer("Here", 2) ; Add a here overlay map on layer nb 2 -======= +; PBMap::AddHereServerLayer("Here", 2) ; Add a "HERE" overlay map on layer nb 2 MessageRequester("Info", "Don't forget to register on HERE and change the line 2485 or edit options file") PBMap::AddHereServerLayer("Here", 2, "my_id", "my_code") ; Add a here overlay map on layer nb 2 ->>>>>>> origin/djes SetGadgetState(#Gdt_AddHereMap, 1) EndIf PBMap::Refresh() @@ -2538,17 +2548,9 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf -<<<<<<< HEAD -; IDE Options = PureBasic 5.60 beta 7 (Windows - x64) -; CursorPosition = 57 -; FirstLine = 32 -======= ; IDE Options = PureBasic 5.60 (Windows - x64) -; CursorPosition = 2475 -; FirstLine = 2453 ->>>>>>> origin/djes +; CursorPosition = 2432 +; FirstLine = 2413 ; Folding = ------------------ ; EnableThread -; EnableXP -; DisableDebugger -; EnableUnicode \ No newline at end of file +; EnableXP \ No newline at end of file From ae1c031ea09a487ceca8a4f9287e6716caf50dd2 Mon Sep 17 00:00:00 2001 From: djes Date: Mon, 20 Mar 2017 12:38:40 +0100 Subject: [PATCH 4/4] Options improvements --- PBMap.pb | 156 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 42 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index aed1312..2dc4d6d 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -27,7 +27,7 @@ UseJPEGImageEncoder() ;- Module declaration DeclareModule PBMap - + CompilerIf #PB_Compiler_OS = #PB_OS_Linux #Red = 255 CompilerEndIf @@ -45,9 +45,10 @@ DeclareModule PBMap #PB_MAP_REDRAW = #PB_EventType_FirstCustomValue + 1 #PB_MAP_RETRY = #PB_EventType_FirstCustomValue + 2 #PB_MAP_TILE_CLEANUP = #PB_EventType_FirstCustomValue + 3 - + Declare InitPBMap(window) Declare SetOption(Option.s, Value.s) + Declare.s GetOption(Option.s) Declare LoadOptions(PreferencesFile.s = "PBMap.prefs") Declare SaveOptions(PreferencesFile.s = "PBMap.prefs") Declare.i AddOSMServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/") @@ -75,7 +76,7 @@ DeclareModule PBMap Declare SetZoomToArea(MinY.d, MaxY.d, MinX.d, MaxX.d) Declare SetZoomToTracks(*Tracks) Declare NominatimGeoLocationQuery(Address.s, *ReturnPosition= 0) ;Send back the position *ptr.GeographicCoordinates - Declare.i LoadGpxFile(file.s); + Declare.i LoadGpxFile(file.s) ; Declare ClearTracks() Declare DeleteTrack(*Ptr) Declare DeleteSelectedTracks() @@ -225,7 +226,7 @@ Module PBMap lg2.s ;< EndStructure - + Structure Box x1.i y1.i @@ -305,7 +306,7 @@ Module PBMap ;TODO use this for all text IncludeFile "gettext.pbi" - + ;-*** Misc tools Macro Min(a, b) @@ -316,7 +317,7 @@ Module PBMap (Bool((a) >= (b)) * (a) + Bool((b) > (a)) * (b)) EndMacro - ;Shows an error msg and terminates the program + ;Shows an error msg and terminates the program Procedure Error(msg.s) MessageRequester("PBMap", msg, #PB_MessageRequester_Ok) End @@ -353,6 +354,8 @@ Module PBMap EndMacro CompilerEndSelect + ;Creates a full tree + ;by Thomas (ts-soft) Schulz Procedure CreateDirectoryEx(DirectoryName.s, FileAttribute = #PB_Default) Protected i, c, tmp.s If Right(DirectoryName, 1) = slash @@ -555,7 +558,7 @@ Module PBMap EndIf EndProcedure - Procedure IsInDrawingBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates) + Procedure.i IsInDrawingBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates) Protected Lat.d = *Position\Latitude, Lon.d = *Position\Longitude Protected LatNW.d = *Drawing\Bounds\NorthWest\Latitude, LonNW.d = *Drawing\Bounds\NorthWest\Longitude Protected LatSE.d = *Drawing\Bounds\SouthEast\Latitude, LonSE.d = *Drawing\Bounds\SouthEast\Longitude @@ -606,10 +609,29 @@ Module PBMap Else ProcedureReturn Val(Value) EndIf - EndProcedure + EndProcedure + + Procedure.s Value2ColourString(Value.i) + ProcedureReturn "$" + StrU(Red(Value), #PB_Byte) + StrU(Green(Value), #PB_Byte) + StrU(Blue(Value), #PB_Byte) + EndProcedure ;-*** Options + Procedure SetOptions() + With PBMap\Options + If \Proxy + HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) + EndIf + If \Verbose + OpenConsole() + EndIf + CreateDirectoryEx(\HDDCachePath) + If \DefaultOSMServer <> "" And IsLayer("OSM") = #False ;First time creation of the basis OSM layer + AddOSMServerLayer("OSM", 1, \DefaultOSMServer) + EndIf + EndWith + EndProcedure + Macro SelBool(Name) Select UCase(Value) Case "0", "FALSE", "DISABLE" @@ -671,6 +693,72 @@ Module PBMap Case "colourtrackdefault" PBMap\Options\ColourTrackDefault = ColourString2Value(Value) EndSelect + SetOptions() + EndProcedure + + Procedure.s GetBoolString(Value.i) + Select Value + Case #False + ProcedureReturn "0" + Default + ProcedureReturn "1" + EndSelect + EndProcedure + + Procedure.s GetOption(Option.s) + Option = StringCheck(Option) + With PBMap\Options + Select LCase(Option) + Case "proxy" + ProcedureReturn GetBoolString(\Proxy) + Case "proxyurl" + ProcedureReturn \ProxyURL + Case "proxyport" + ProcedureReturn \ProxyPort + Case "proxyuser" + ProcedureReturn \ProxyUser + Case "appid" + ProcedureReturn \appid + Case "appcode" + ProcedureReturn \appcode + Case "tilescachepath" + ProcedureReturn \HDDCachePath + Case "maxmemcache" + ProcedureReturn StrU(\MaxMemCache) + Case "verbose" + ProcedureReturn GetBoolString(\Verbose) + Case "warning" + ProcedureReturn GetBoolString(\Warning) + Case "wheelmouserelative" + ProcedureReturn GetBoolString(\WheelMouseRelative) + Case "showdegrees" + ProcedureReturn GetBoolString(\ShowDegrees) + Case "showdebuginfos" + ProcedureReturn GetBoolString(\ShowDebugInfos) + Case "showscale" + ProcedureReturn GetBoolString(\ShowScale) + Case "showmarkers" + ProcedureReturn GetBoolString(\ShowMarkers) + Case "showpointer" + ProcedureReturn GetBoolString(\ShowPointer) + Case "showtrack" + ProcedureReturn GetBoolString(\ShowTrack) + Case "showmarkersnb" + ProcedureReturn GetBoolString(\ShowMarkersNb) + Case "showmarkerslegend" + ProcedureReturn GetBoolString(\ShowMarkersLegend) + Case "showtrackkms" + ProcedureReturn GetBoolString(\ShowTrackKms) + Case "strokewidthtrackdefault" + ProcedureReturn GetBoolString(\StrokeWidthTrackDefault) + Case "colourfocus" + ProcedureReturn Value2ColourString(\ColourFocus) + Case "colourselected" + ProcedureReturn Value2ColourString(\ColourSelected) + Case "colourtrackdefault" + ProcedureReturn Value2ColourString(\ColourTrackDefault) + EndSelect + EndWith EndProcedure ;By default, save options in the user's home directory @@ -749,8 +837,8 @@ Module PBMap \ProxyPassword = ReadPreferenceString("ProxyPass", "") ; = InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO EndIf PreferenceGroup("HERE") - \appid = ReadPreferenceString("APP_ID", "") ; = InputRequester("Here App ID", "Do you use HERE ? Enter app ID", "") ;TODO - \appcode = ReadPreferenceString("APP_CODE", "") ; = InputRequester("Here App Code", "Do you use HERE ? Enter app Code", "") ;TODO + \appid = ReadPreferenceString("APP_ID", "") ; = InputRequester("Here App ID", "Do you use HERE ? Enter app ID", "") ;TODO + \appcode = ReadPreferenceString("APP_CODE", "") ; = InputRequester("Here App Code", "Do you use HERE ? Enter app Code", "") ;TODO PreferenceGroup("URL") \DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/") @@ -777,8 +865,9 @@ Module PBMap \ColourSelected = ReadPreferenceInteger("ColourSelected", RGBA(225, 225, 0, 255)) \ColourTrackDefault = ReadPreferenceInteger("ColourTrackDefault", RGBA(0, 255, 0, 150)) \TimerInterval = 20 - ClosePreferences() - EndWith + ClosePreferences() + EndWith + SetOptions() EndProcedure ;-*** Layers @@ -1586,7 +1675,7 @@ Module PBMap MovePathCursor(GadgetWidth(PBMAP\Gadget) - VectorTextWidth(Text), GadgetHeight(PBMAP\Gadget) - 20) DrawVectorText(Text) EndProcedure - + Procedure Drawing() Protected *Drawing.DrawingParameters = @PBMap\Drawing Protected PixelCenter.PixelCoordinates @@ -1659,7 +1748,7 @@ Module PBMap EndProcedure ;-*** Misc functions - + Procedure.d GetMouseLongitude() Protected MouseX.d = (PBMap\PixelCoordinates\x - PBMap\Drawing\RadiusX + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)) / PBMap\TileSize Protected n.d = Pow(2.0, PBMap\Zoom) @@ -2075,7 +2164,7 @@ Module PBMap Case #PB_EventType_MouseMove ; Drag If PBMap\Dragging -; If PBMap\MoveStartingPoint\x <> - 1 + ; If PBMap\MoveStartingPoint\x <> - 1 MouseX = CanvasMouseX - PBMap\MoveStartingPoint\x MouseY = CanvasMouseY - PBMap\MoveStartingPoint\y PBMap\MoveStartingPoint\x = CanvasMouseX @@ -2157,7 +2246,7 @@ Module PBMap EndIf EndIf Case #PB_EventType_LeftButtonUp -; PBMap\MoveStartingPoint\x = - 1 + ; PBMap\MoveStartingPoint\x = - 1 PBMap\Dragging = #False PBMap\Redraw = #True Case #PB_MAP_REDRAW @@ -2188,16 +2277,6 @@ Module PBMap ; Could be called directly to attach our map to an existing canvas Procedure BindMapGadget(Gadget.i) - If PBMap\Options\Verbose - OpenConsole() - EndIf - If PBMap\Options\Proxy - HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) - EndIf - CreateDirectoryEx(PBMap\Options\HDDCachePath) - If PBMap\Options\DefaultOSMServer <> "" - AddOSMServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer) - EndIf PBMap\Gadget = Gadget BindGadgetEvent(PBMap\Gadget, @CanvasEvents()) AddWindowTimer(PBMap\Window, PBMap\Timer, PBMap\Options\TimerInterval) @@ -2208,16 +2287,6 @@ Module PBMap ; Creates a canvas and attach our map Procedure MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i) - If PBMap\Options\Verbose - OpenConsole() - EndIf - If PBMap\Options\Proxy - HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) - EndIf - CreateDirectoryEx(PBMap\Options\HDDCachePath) - If PBMap\Options\DefaultOSMServer <> "" - AddOSMServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer) - EndIf If Gadget = #PB_Any PBMap\Gadget = CanvasGadget(PBMap\Gadget, X, Y, Width, Height, #PB_Canvas_Keyboard) ;#PB_Canvas_Keyboard has to be set for mousewheel to work on windows Else @@ -2494,9 +2563,12 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::DeleteLayer("Here") SetGadgetState(#Gdt_AddHereMap, 0) Else -; PBMap::AddHereServerLayer("Here", 2) ; Add a "HERE" overlay map on layer nb 2 - MessageRequester("Info", "Don't forget to register on HERE and change the line 2485 or edit options file") - PBMap::AddHereServerLayer("Here", 2, "my_id", "my_code") ; Add a here overlay map on layer nb 2 + If PBMap::GetOption("appid") <> "" And PBMap::GetOption("appcode") <> "" + PBMap::AddHereServerLayer("Here", 2) ; Add a "HERE" overlay map on layer nb 2 + Else + MessageRequester("Info", "Don't forget to register on HERE and change the following line or edit options file") + PBMap::AddHereServerLayer("Here", 2, "my_id", "my_code") ; Add a here overlay map on layer nb 2 + EndIf SetGadgetState(#Gdt_AddHereMap, 1) EndIf PBMap::Refresh() @@ -2549,8 +2621,8 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf ; IDE Options = PureBasic 5.60 (Windows - x64) -; CursorPosition = 2432 -; FirstLine = 2413 -; Folding = ------------------ +; CursorPosition = 758 +; FirstLine = 733 +; Folding = ------------------- ; EnableThread ; EnableXP \ No newline at end of file