From b1a8db8b1e60408fb3846d09bf70ccc4042cfcfc Mon Sep 17 00:00:00 2001 From: djes Date: Sun, 18 Sep 2016 14:19:27 +0200 Subject: [PATCH 1/4] Cursor keys to move markers --- PBMap.pb | 55 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 2c4b00e..eb386e9 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -585,6 +585,11 @@ Module PBMap *Location\Latitude = Degree(ATan(SinH(#PI * (1.0 - 2.0 * *Coords\y / n)))) EndProcedure + ;Ensures the longitude to be in the range [-180;180[ + Procedure.d ClipLongitude(Longitude.d) + ProcedureReturn Mod(Mod(Longitude + 180, 360.0) + 360.0, 360.0) - 180 + EndProcedure + ;Lat Lon coordinates 2 pixel absolute [0 to 2^Zoom * TileSize [ Procedure LatLon2Pixel(*Location.GeographicCoordinates, *Pixel.PixelCoordinates, Zoom) Protected tilemax = Pow(2.0, Zoom) * PBMap\TileSize @@ -1410,11 +1415,41 @@ Module PBMap Case #PB_Shortcut_Delete DeleteSelectedMarkers() EndSelect + PBMap\Redraw = #True If GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Modifiers)&#PB_Canvas_Control = 0 CtrlKey = #False EndIf - Case #PB_EventType_KeyDown - If GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Modifiers)&#PB_Canvas_Control <> 0 + Case #PB_EventType_KeyDown + With PBMap\Markers() + Select GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Key) + Case #PB_Shortcut_Left + ForEach PBMap\Markers() + If \Selected + \GeographicCoordinates\Longitude = ClipLongitude( \GeographicCoordinates\Longitude - 10* 360 / Pow(2, PBMap\Zoom + 8)) + EndIf + Next + Case #PB_Shortcut_Up + ForEach PBMap\Markers() + If \Selected + \GeographicCoordinates\Latitude + 10* 360 / Pow(2, PBMap\Zoom + 8) + EndIf + Next + Case #PB_Shortcut_Right + ForEach PBMap\Markers() + If \Selected + \GeographicCoordinates\Longitude = ClipLongitude( \GeographicCoordinates\Longitude + 10* 360 / Pow(2, PBMap\Zoom + 8)) + EndIf + Next + Case #PB_Shortcut_Down + ForEach PBMap\Markers() + If \Selected + \GeographicCoordinates\Latitude - 10* 360 / Pow(2, PBMap\Zoom + 8) + EndIf + Next + EndSelect + EndWith + PBMap\Redraw = #True + If GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Modifiers)&#PB_Canvas_Control <> 0 CtrlKey = #True EndIf Case #PB_EventType_LeftDoubleClick @@ -1513,9 +1548,9 @@ Module PBMap If Distance(MarkerCoords\x, MarkerCoords\y, MouseX, MouseY) < 8 PBMap\Markers()\Focus = #True Else - If CtrlKey = #False - PBMap\Markers()\Focus = #False - EndIf + ;If CtrlKey = #False + PBMap\Markers()\Focus = #False + ;EndIf EndIf Next EndIf @@ -1743,10 +1778,10 @@ CompilerIf #PB_Compiler_IsMainFile EndIf CompilerEndIf -; IDE Options = PureBasic 5.50 (Windows - x64) -; CursorPosition = 1500 -; FirstLine = 1478 +; IDE Options = PureBasic 5.42 LTS (Windows - x64) +; CursorPosition = 1433 +; FirstLine = 1405 ; Folding = ------------- +; EnableUnicode ; EnableThread -; EnableXP -; EnableUnicode \ No newline at end of file +; EnableXP \ No newline at end of file From e3b1bc8a6dafe0dcc98c4b338d985f203bfde322 Mon Sep 17 00:00:00 2001 From: djes Date: Sat, 24 Sep 2016 11:29:59 +0200 Subject: [PATCH 2/4] Multitracks wip, markers moving with cursor --- .gitignore | 1 + PBMap.pb | 161 ++++++++++++++++++++++++++++++++--------------------- 2 files changed, 97 insertions(+), 65 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a024d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +PBMap.pb.bak \ No newline at end of file diff --git a/PBMap.pb b/PBMap.pb index eb386e9..2f9aaa1 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -40,6 +40,7 @@ DeclareModule PBMap #MODE_SELECT = 2 #MODE_EDIT = 3 + ;-Declarations Declare InitPBMap(window) Declare SetOption(Option.s, Value.s) Declare LoadOptions(PreferencesFile.s = "PBMap.prefs") @@ -50,7 +51,8 @@ DeclareModule PBMap Declare SetLocation(latitude.d, longitude.d, Zoom = -1, mode.i = #PB_Absolute) Declare Drawing() Declare SetZoom(Zoom.i, mode.i = #PB_Relative) - Declare ZoomToArea() + Declare ZoomToArea(MinY.d, MaxY.d, MinX.d, MaxX.d) + Declare ZoomToTracks(*Tracks) Declare SetCallBackLocation(*CallBackLocation) Declare SetCallBackMainPointer(CallBackMainPointer.i) Declare SetMapScaleUnit(ScaleUnit=PBMAP::#SCALE_KM) @@ -111,8 +113,6 @@ Module PBMap TileCoordinates.Coordinates Bounds.TileBounds Canvas.i - PBMapTileX.i - PBMapTileY.i PBMapZoom.i GeographicCoordinates.GeographicCoordinates CenterX.i @@ -176,6 +176,9 @@ Module PBMap ServerURL.s ; Web URL ex: http://tile.openstreetmap.org/ EndStructure + Structure Tracks + List Track.GeographicCoordinates() + EndStructure ;-PBMap Structure Structure PBMap Window.i ; Parent Window @@ -206,7 +209,7 @@ Module PBMap Moving.i Dirty.i ; To signal that drawing need a refresh - List track.GeographicCoordinates() ; To display a GPX track + List TracksList.Tracks() ; To display a GPX track List Markers.Marker() ; To diplay marker EditMarker.l @@ -672,21 +675,22 @@ Module PBMap Protected *MainNode,*subNode,*child,child.l *MainNode=MainXMLNode(0) *MainNode=XMLNodeFromPath(*MainNode,"/gpx/trk/trkseg") - ClearList(PBMap\track()) + Protected *NewTrack.Tracks = AddElement(PBMap\TracksList()) For child = 1 To XMLChildCount(*MainNode) *child = ChildXMLNode(*MainNode, child) - AddElement(PBMap\track()) + AddElement(*NewTrack\Track()) If ExamineXMLAttributes(*child) While NextXMLAttribute(*child) Select XMLAttributeName(*child) Case "lat" - PBMap\track()\Latitude=ValD(XMLAttributeValue(*child)) + *NewTrack\Track()\Latitude=ValD(XMLAttributeValue(*child)) Case "lon" - PBMap\track()\Longitude=ValD(XMLAttributeValue(*child)) + *NewTrack\Track()\Longitude=ValD(XMLAttributeValue(*child)) EndSelect Wend EndIf Next + ZoomToTracks(LastElement(PBMap\TracksList())) ; <-To center the view, and zoom on the tracks EndIf EndProcedure @@ -894,6 +898,14 @@ Module PBMap DrawVectorImage(ImageID(PBMap\ImgNothing)) ;EndIf EndIf + If PBMap\Options\ShowDebugInfos + VectorFont(FontID(PBMap\Font), 16) + VectorSourceColor(RGBA(0, 0, 0, 80)) + MovePathCursor(px, py) + DrawVectorText("x:" + Str(tilex)) + MovePathCursor(px, py + 16) + DrawVectorText("y:" + Str(tiley)) + EndIf Next Next EndProcedure @@ -1007,47 +1019,56 @@ Module PBMap DrawVectorText(Str(dist)) EndProcedure - Procedure DrawTrack(*Drawing.DrawingParameters) + Procedure DrawTracks(*Drawing.DrawingParameters) Protected Pixel.PixelCoordinates Protected Location.GeographicCoordinates Protected km.f, memKm.i - If ListSize(PBMap\track())>0 - ;Trace Track - ForEach PBMap\track() - ;If *Drawing\GeographicCoordinates\Latitude<>0 And *Drawing\GeographicCoordinates\Longitude<>0 - LatLon2PixelRel(@PBMap\track(), @Pixel, PBMap\Zoom) - If ListIndex(PBMap\track())=0 - MovePathCursor(Pixel\X, Pixel\Y) - Else - AddPathLine(Pixel\X, Pixel\Y) - EndIf - ;EndIf - Next - VectorSourceColor(RGBA(0, 255, 0, 150)) - StrokePath(10, #PB_Path_RoundEnd|#PB_Path_RoundCorner) - ;Draw Distance - ForEach PBMap\track() - ;Test Distance - If ListIndex(PBMap\track())=0 - Location\Latitude=PBMap\track()\Latitude - Location\Longitude=PBMap\track()\Longitude - Else - km=km+HaversineInKM(@Location,@PBMap\track()) ;<- display Distance - Location\Latitude=PBMap\track()\Latitude - Location\Longitude=PBMap\track()\Longitude + ;Trace Track + If ListSize(PBMap\TracksList()) > 0 + BeginVectorLayer() + ForEach PBMap\TracksList() + If ListSize(PBMap\TracksList()\Track()) > 0 + ForEach PBMap\TracksList()\Track() + ;If *Drawing\GeographicCoordinates\Latitude<>0 And *Drawing\GeographicCoordinates\Longitude<>0 + LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom) + If ListIndex(PBMap\TracksList()\Track()) = 0 + MovePathCursor(Pixel\X, Pixel\Y) + Else + AddPathLine(Pixel\X, Pixel\Y) + EndIf + ;EndIf + Next + VectorSourceColor(RGBA(0, 255, 0, 150)) + StrokePath(10, #PB_Path_RoundEnd|#PB_Path_RoundCorner) EndIf - If PBMap\Options\TrackShowKms - LatLon2PixelRel(@PBMap\track(),@Pixel, PBMap\Zoom) - If Int(km)<>memKm - memKm=Int(km) - If PBMap\Zoom>10 - BeginVectorLayer() + Next + EndVectorLayer() + EndIf + ;Draw Distance + If PBMap\Options\TrackShowKms And ListSize(PBMap\TracksList()) > 0 + BeginVectorLayer() + ForEach PBMap\TracksList() + km = 0 : memKm = -1 + ForEach PBMap\TracksList()\Track() + ;Test Distance + If ListIndex(PBMap\TracksList()\Track()) = 0 + Location\Latitude = PBMap\TracksList()\Track()\Latitude + Location\Longitude = PBMap\TracksList()\Track()\Longitude + Else + km = km + HaversineInKM(@Location, @PBMap\TracksList()\Track()) + Location\Latitude = PBMap\TracksList()\Track()\Latitude + Location\Longitude = PBMap\TracksList()\Track()\Longitude + EndIf + LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom) + If Int(km) <> memKm + memKm = Int(km) + If PBMap\Zoom > 10 TrackPointer(Pixel\X , Pixel\Y, Int(km)) - EndVectorLayer() EndIf EndIf - EndIf + Next Next + EndVectorLayer() EndIf EndProcedure @@ -1153,6 +1174,8 @@ Module PBMap EndIf Next DrawVectorText(Str(ThreadCounter)) + MovePathCursor(50,110) + DrawVectorText(Str(PBMap\Zoom)) EndProcedure ;-*** Main drawing @@ -1179,7 +1202,7 @@ Module PBMap DrawTiles(*Drawing, ListIndex(PBMap\Layers())) Next If PBMap\Options\ShowTrack - DrawTrack(*Drawing) + DrawTracks(*Drawing) EndIf If PBMap\Options\ShowMarkers DrawMarkers() @@ -1257,24 +1280,9 @@ Module PBMap EndIf EndProcedure - Procedure ZoomToArea() + Procedure ZoomToArea(MinY.d, MaxY.d, MinX.d, MaxX.d) ;Source => http://gis.stackexchange.com/questions/19632/how-to-calculate-the-optimal-zoom-level-to-display-two-or-more-points-on-a-map ;bounding box in long/lat coords (x=long, y=lat) - Protected MinY.d,MaxY.d,MinX.d,MaxX.d - ForEach PBMap\track() - If ListIndex(PBMap\track())=0 Or PBMap\track()\LongitudeMaxX - MaxX=PBMap\track()\Longitude - EndIf - If ListIndex(PBMap\track())=0 Or PBMap\track()\LatitudeMaxY - MaxY=PBMap\track()\Latitude - EndIf - Next Protected DeltaX.d=MaxX-MinX ;assumption ! In original code DeltaX have no source Protected centerX.d=MinX+DeltaX/2 ; assumption ! In original code CenterX have no source Protected paddingFactor.f= 1.2 ;paddingFactor: this can be used to get the "120%" effect ThomM refers to. Value of 1.2 would get you the 120%. @@ -1299,6 +1307,30 @@ Module PBMap EndIf EndProcedure + Procedure ZoomToTracks(*Tracks.Tracks) + Protected MinY.d, MaxY.d, MinX.d, MaxX.d + If ListSize(*Tracks\Track()) > 0 + With *Tracks\Track() + FirstElement(*Tracks\Track()) + MinX = \Longitude : MaxX = MinX : MinY = \Latitude : MaxY = MinY + ForEach *Tracks\Track() + If \Longitude < MinX + MinX = \Longitude + EndIf + If \Longitude > MaxX + MaxX = \Longitude + EndIf + If \Latitude < MinY + MinY = \Latitude + EndIf + If \Latitude > MaxY + MaxY = \Latitude + EndIf + Next + ZoomToArea(MinY.d, MaxY.d, MinX.d, MaxX.d) + EndWith + EndIf + EndProcedure Procedure SetZoom(Zoom.i, mode.i = #PB_Relative) Select mode Case #PB_Relative @@ -1715,7 +1747,7 @@ CompilerIf #PB_Compiler_IsMainFile ;Our main gadget PBMap::InitPBMap(#Window_0) PBMap::SetOption("ShowDegrees", "1") - PBMap::SetOption("ShowDebugInfos", "1") + PBMap::SetOption("ShowDebugInfos", "0") PBMap::SetOption("ShowScale", "1") PBMap::SetOption("ShowMarkersLegend", "1") PBMap::SetOption("TrackShowKms", "1") @@ -1747,7 +1779,6 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::SetZoom( - 1) Case #Gdt_LoadGpx PBMap::LoadGpxFile(OpenFileRequester("Choose a file to load", "", "Gpx|*.gpx", 0)) - PBMap::ZoomToArea() ; <-To center the view, and zoom on the tracks Case #StringLatitude, #StringLongitude Select EventType() Case #PB_EventType_LostFocus @@ -1778,10 +1809,10 @@ CompilerIf #PB_Compiler_IsMainFile EndIf CompilerEndIf -; IDE Options = PureBasic 5.42 LTS (Windows - x64) -; CursorPosition = 1433 -; FirstLine = 1405 +; IDE Options = PureBasic 5.50 (Windows - x64) +; CursorPosition = 11 ; Folding = ------------- -; EnableUnicode ; EnableThread -; EnableXP \ No newline at end of file +; EnableXP +; DisableDebugger +; EnableUnicode \ No newline at end of file From 90f3d8a6a5def73913bbce8cdf93c4dedc1a6ebb Mon Sep 17 00:00:00 2001 From: djes Date: Sat, 24 Sep 2016 12:54:22 +0200 Subject: [PATCH 3/4] esthetic --- PBMap.pb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 2f9aaa1..20d4588 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -2,18 +2,14 @@ ; Program: PBMap ; Description: Permits the use of tiled maps like ; OpenStreetMap in a handy PureBASIC module -; Author: Thyphoon, Djes And Idle +; Author: Thyphoon, djes And Idle ; Date: Mai 17, 2016 ; License: Free, unrestricted, credit appreciated ; but not required. ; Note: Please share improvement ! ; Thanks: Progi1984 -; Usage: Change the Proxy global variables if needed -; (see also Proxy Details) ;************************************************************** -;#Red = 255 - CompilerIf #PB_Compiler_Thread = #False MessageRequester("Warning !!","You must enable ThreadSafe support in compiler options",#PB_MessageRequester_Ok ) End @@ -1810,7 +1806,8 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf ; IDE Options = PureBasic 5.50 (Windows - x64) -; CursorPosition = 11 +; CursorPosition = 24 +; FirstLine = 159 ; Folding = ------------- ; EnableThread ; EnableXP From a79c06299b465111f735ef3ccd04434aa22a22ed Mon Sep 17 00:00:00 2001 From: djes Date: Sun, 25 Sep 2016 18:49:36 +0200 Subject: [PATCH 4/4] New marker with legend by yves86 + colour options wip --- PBMap.pb | 144 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 97 insertions(+), 47 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 20d4588..1373b1f 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -143,6 +143,7 @@ Module PBMap CallBackPointer.i ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib) EndStructure + ;-Options Structure Option HDDCachePath.s ; Path where to load and save tiles downloaded from server DefaultOSMServer.s ; Base layer OSM server @@ -157,13 +158,15 @@ Module PBMap ShowDebugInfos.i ShowScale.i ShowTrack.i + ShowTrackKms.i ShowMarkers.i ShowPointer.i TimerInterval.i MaxMemCache.i ; in MiB - TrackShowKms.i ShowMarkersNb.i ShowMarkersLegend.i + ;Colours + ColourFocus.i EndStructure Structure Layer @@ -348,6 +351,27 @@ Module PBMap EndSelect EndMacro + Procedure.i ColourString2Value(Value.s) + ;TODO : better string check + Protected Col.s = RemoveString(Value, " ") + If Left(Col, 1) = "$" + Protected r.i, g.i, b.i, a.i = 255 + Select Len(Col) + Case 4 ;RGB (eg : "$9BC" + r = Val("$"+Mid(Col, 2, 1)) : g = Val("$"+Mid(Col, 3, 1)) : b = Val("$"+Mid(Col, 4, 1)) + Case 5 ;RGBA (eg : "$9BC5") + r = Val("$"+Mid(Col, 2, 1)) : g = Val("$"+Mid(Col, 3, 1)) : b = Val("$"+Mid(Col, 4, 1)) : a = Val("$"+Mid(Col, 5, 1)) + Case 7 ;RRGGBB (eg : "$95B4C2") + r = Val("$"+Mid(Col, 2, 2)) : g = Val("$"+Mid(Col, 4, 2)) : b = Val("$"+Mid(Col, 6, 2)) + Case 9 ;RRGGBBAA (eg : "$95B4C249") + r = Val("$"+Mid(Col, 2, 2)) : g = Val("$"+Mid(Col, 4, 2)) : b = Val("$"+Mid(Col, 6, 2)) : a = Val("$"+Mid(Col, 8, 2)) + EndSelect + ProcedureReturn RGBA(r, g, b, a) + Else + ProcedureReturn Val(Value) + EndIf + EndProcedure + Procedure SetOption(Option.s, Value.s) Option = StringCheck(Option) Select LCase(Option) @@ -381,8 +405,10 @@ Module PBMap SelBool(ShowMarkersNb) Case "showmarkerslegend" SelBool(ShowMarkersLegend) - Case "trackshowkms" - SelBool(TrackShowKms) + Case "showtrackkms" + SelBool(ShowTrackKms) + Case "colourfocus" + PBMap\Options\ColourFocus = ColourString2Value(Value) EndSelect EndProcedure @@ -393,28 +419,32 @@ Module PBMap Else CreatePreferences(PreferencesFile) EndIf + With PBMap\Options PreferenceGroup("PROXY") - WritePreferenceInteger("Proxy", PBMap\Options\Proxy) - WritePreferenceString("ProxyURL", PBMap\Options\ProxyURL) - WritePreferenceString("ProxyPort", PBMap\Options\ProxyPort) - WritePreferenceString("ProxyUser", PBMap\Options\ProxyUser) + WritePreferenceInteger("Proxy", \Proxy) + WritePreferenceString("ProxyURL", \ProxyURL) + WritePreferenceString("ProxyPort", \ProxyPort) + WritePreferenceString("ProxyUser", \ProxyUser) PreferenceGroup("URL") - WritePreferenceString("DefaultOSMServer", PBMap\Options\DefaultOSMServer) + WritePreferenceString("DefaultOSMServer", \DefaultOSMServer) PreferenceGroup("PATHS") - WritePreferenceString("TilesCachePath", PBMap\Options\HDDCachePath) + WritePreferenceString("TilesCachePath", \HDDCachePath) PreferenceGroup("OPTIONS") - WritePreferenceInteger("WheelMouseRelative", PBMap\Options\WheelMouseRelative) - WritePreferenceInteger("MaxMemCache", PBMap\Options\MaxMemCache) - WritePreferenceInteger("ShowDegrees", PBMap\Options\ShowDegrees) - WritePreferenceInteger("ShowDebugInfos", PBMap\Options\ShowDebugInfos) - WritePreferenceInteger("ShowScale", PBMap\Options\ShowScale) - WritePreferenceInteger("ShowMarkers", PBMap\Options\ShowMarkers) - WritePreferenceInteger("ShowPointer", PBMap\Options\ShowPointer) - WritePreferenceInteger("ShowTrack", PBMap\Options\ShowTrack) - WritePreferenceInteger("ShowMarkersNb", PBMap\Options\ShowMarkersNb) - WritePreferenceInteger("ShowMarkersLegend", PBMap\Options\ShowMarkersLegend) - WritePreferenceInteger("TrackShowKms", PBMap\Options\TrackShowKms) + WritePreferenceInteger("WheelMouseRelative", \WheelMouseRelative) + WritePreferenceInteger("MaxMemCache", \MaxMemCache) + WritePreferenceInteger("ShowDegrees", \ShowDegrees) + WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos) + WritePreferenceInteger("ShowScale", \ShowScale) + WritePreferenceInteger("ShowMarkers", \ShowMarkers) + WritePreferenceInteger("ShowPointer", \ShowPointer) + WritePreferenceInteger("ShowTrack", \ShowTrack) + WritePreferenceInteger("ShowTrackKms", \ShowTrackKms) + WritePreferenceInteger("ShowMarkersNb", \ShowMarkersNb) + WritePreferenceInteger("ShowMarkersLegend", \ShowMarkersLegend) + ;Colours; + WritePreferenceInteger("ColourFocus", \ColourFocus) ClosePreferences() + EndWith EndProcedure Procedure LoadOptions(PreferencesFile.s = "PBMap.prefs") @@ -436,33 +466,37 @@ Module PBMap ; WritePreferenceString("ProxyUser", "myproxyname") ; WritePreferenceString("ProxyPass", "myproxypass") ;TODO !Warning! !not encoded! ; ClosePreferences() + With PBMap\Options PreferenceGroup("PROXY") - PBMap\Options\Proxy = ReadPreferenceInteger("Proxy", #False) - If PBMap\Options\Proxy - PBMap\Options\ProxyURL = ReadPreferenceString("ProxyURL", "") ;InputRequester("ProxyServer", "Do you use a Proxy Server? Then enter the full url:", "") - PBMap\Options\ProxyPort = ReadPreferenceString("ProxyPort", "") ;InputRequester("ProxyPort" , "Do you use a specific port? Then enter it", "") - PBMap\Options\ProxyUser = ReadPreferenceString("ProxyUser", "") ;InputRequester("ProxyUser" , "Do you use a user name? Then enter it", "") - PBMap\Options\ProxyPassword = InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO + \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 = InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO EndIf PreferenceGroup("URL") - PBMap\Options\DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/") + \DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/") PreferenceGroup("PATHS") - PBMap\Options\HDDCachePath = ReadPreferenceString("TilesCachePath", GetTemporaryDirectory()) + \HDDCachePath = ReadPreferenceString("TilesCachePath", GetTemporaryDirectory()) PreferenceGroup("OPTIONS") - PBMap\Options\WheelMouseRelative = ReadPreferenceInteger("WheelMouseRelative", #True) - PBMap\Options\MaxMemCache = ReadPreferenceInteger("MaxMemCache", 20480) ;20 MiB, about 80 tiles in memory - PBMap\Options\ShowDegrees = ReadPreferenceInteger("ShowDegrees", #False) - PBMap\Options\ShowDebugInfos = ReadPreferenceInteger("ShowDebugInfos", #False) - PBMap\Options\ShowScale = ReadPreferenceInteger("ShowScale", #False) - PBMap\Options\ShowMarkers = ReadPreferenceInteger("ShowMarkers", #True) - PBMap\Options\ShowPointer = ReadPreferenceInteger("ShowPointer", #True) - PBMap\Options\ShowTrack = ReadPreferenceInteger("ShowTrack", #True) - PBMap\Options\ShowMarkersNb = ReadPreferenceInteger("ShowMarkersNb", #True) - PBMap\Options\ShowMarkersLegend = ReadPreferenceInteger("ShowMarkersLegend", #False) - PBMap\Options\TrackShowKms = ReadPreferenceInteger("TrackShowKms", #False) - PBMap\Options\TimerInterval = 20 + \WheelMouseRelative = ReadPreferenceInteger("WheelMouseRelative", #True) + \MaxMemCache = ReadPreferenceInteger("MaxMemCache", 20480) ;20 MiB, about 80 tiles in memory + \ShowDegrees = ReadPreferenceInteger("ShowDegrees", #False) + \ShowDebugInfos = ReadPreferenceInteger("ShowDebugInfos", #False) + \ShowScale = ReadPreferenceInteger("ShowScale", #False) + \ShowMarkers = ReadPreferenceInteger("ShowMarkers", #True) + \ShowPointer = ReadPreferenceInteger("ShowPointer", #True) + \ShowTrack = ReadPreferenceInteger("ShowTrack", #True) + \ShowTrackKms = ReadPreferenceInteger("ShowTrackKms", #False) + \ShowMarkersNb = ReadPreferenceInteger("ShowMarkersNb", #True) + \ShowMarkersLegend = ReadPreferenceInteger("ShowMarkersLegend", #False) + \TimerInterval = 20 + PreferenceGroup("COLOURS") + \ColourFocus = ReadPreferenceInteger("ColourFocus", RGBA(255, 255, 0, 255)) ClosePreferences() + EndWith EndProcedure Procedure InitPBMap(Window) @@ -1041,7 +1075,7 @@ Module PBMap EndVectorLayer() EndIf ;Draw Distance - If PBMap\Options\TrackShowKms And ListSize(PBMap\TracksList()) > 0 + If PBMap\Options\ShowTrackKms And ListSize(PBMap\TracksList()) > 0 BeginVectorLayer() ForEach PBMap\TracksList() km = 0 : memKm = -1 @@ -1069,6 +1103,7 @@ Module PBMap EndProcedure Procedure DrawMarker(x.i, y.i, Nb, Color.l, Legend.s, Focus.i, Selected.i) + ;Nice marker by yves86 VectorSourceColor(color) MovePathCursor(x, y) AddPathLine(-8, -16, #PB_Path_Relative) @@ -1080,10 +1115,10 @@ Module PBMap VectorSourceColor(Color) FillPath(#PB_Path_Preserve) If Focus - VectorSourceColor(RGBA(255, 255, 0, 255)) + VectorSourceColor(PBMap\Options\ColourFocus) StrokePath(3) ElseIf Selected - VectorSourceColor(RGBA(255, 255, 0, 255)) + VectorSourceColor(PBMap\Options\ColourFocus) StrokePath(4) Else VectorSourceColor(Color) @@ -1098,7 +1133,21 @@ Module PBMap EndIf If PBMap\Options\ShowMarkersLegend VectorFont(FontID(PBMap\Font), 13) - Protected Height = VectorParagraphHeight(Legend, 100, 13) +; Protected Height = VectorParagraphHeight(Legend, 100, 13) + ;dessin d'un cadre avec fond transparent + Protected Height = VectorParagraphHeight(Legend, 100, 100) + Protected Width.l + If Height < 20 ; une ligne + Width = VectorTextWidth(Legend) + Else + Width = 100 + EndIf + AddPathBox(x - (Width / 2), y - 30 - Height, Width, Height) + VectorSourceColor(RGBA(168, 255, 255, 100)) + FillPath() + AddPathBox(x - (Width / 2), y - 30 - Height, Width, Height) + VectorSourceColor(RGBA(36, 36, 255, 100)) + StrokePath(2) MovePathCursor(x - 50, y - 30 - Height) VectorSourceColor(RGBA(0, 0, 0, 255)) DrawVectorParagraph(Legend, 100, Height, #PB_VectorParagraph_Center) @@ -1746,7 +1795,8 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::SetOption("ShowDebugInfos", "0") PBMap::SetOption("ShowScale", "1") PBMap::SetOption("ShowMarkersLegend", "1") - PBMap::SetOption("TrackShowKms", "1") + PBMap::SetOption("ShowTrackKms", "1") + 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 @@ -1806,8 +1856,8 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf ; IDE Options = PureBasic 5.50 (Windows - x64) -; CursorPosition = 24 -; FirstLine = 159 +; CursorPosition = 1104 +; FirstLine = 1107 ; Folding = ------------- ; EnableThread ; EnableXP