From 024ee41f9392c1109c1c1ac06c42f4ed877e5593 Mon Sep 17 00:00:00 2001 From: thyphoonfr Date: Wed, 3 Aug 2016 21:11:02 +0200 Subject: [PATCH 1/4] Add RefreshMapGadget() to refreash the Gadget when resize or other ... --- PBMap.pb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 18247e1..144c994 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -833,6 +833,10 @@ Module PBMap ProcedureReturn Value EndProcedure + Procedure RefreshMapGadget() + SignalSemaphore(OSM\Drawing\Semaphore) + EndProcedure + Procedure Event(Event.l) Protected Gadget.i Protected MouseX.i, MouseY.i @@ -1053,9 +1057,10 @@ CompilerIf #PB_Compiler_IsMainFile EndIf CompilerEndIf -; IDE Options = PureBasic 5.42 LTS (Windows - x86) -; CursorPosition = 11 -; Folding = -------- -; EnableUnicode +; IDE Options = PureBasic 5.50 (Windows - x86) +; CursorPosition = 835 +; FirstLine = 811 +; Folding = --------- ; EnableThread -; EnableXP \ No newline at end of file +; EnableXP +; EnableUnicode \ No newline at end of file From d91ea5ed17f512909b7cca0900be08518d0a96e4 Mon Sep 17 00:00:00 2001 From: thyphoonfr Date: Wed, 3 Aug 2016 21:19:18 +0200 Subject: [PATCH 2/4] Add SetMapServer() and RefreshMapGadget() --- PBMap.pb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 144c994..7934f43 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -267,6 +267,13 @@ Module PBMap EndIf EndProcedure + Procedure SetMapServer(ServerURL.s="http://tile.openstreetmap.org/",TileSize.l=256,ZoomMin.l=0,ZoomMax.l=18) + PBMap\ServerURL = ServerURL + PBMap\ZoomMin = ZoomMin + PBMap\ZoomMax = ZoomMax + PBMap\TileSize = TileSize + EndProcedure + Procedure Quit() ;kill main drawing thread (nicer than KillThread(PBMap\MainDrawingThread)) LockMutex(PBMap\Drawing\Mutex) @@ -1058,8 +1065,8 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf ; IDE Options = PureBasic 5.50 (Windows - x86) -; CursorPosition = 835 -; FirstLine = 811 +; CursorPosition = 272 +; FirstLine = 224 ; Folding = --------- ; EnableThread ; EnableXP From cd673bd3ffb7b50707be97a0a6cee19865697a75 Mon Sep 17 00:00:00 2001 From: thyphoonfr Date: Thu, 4 Aug 2016 09:25:13 +0200 Subject: [PATCH 3/4] Add Zoom With Mouse Wheel --- PBMap.pb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 7934f43..3f1fbf2 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -29,6 +29,7 @@ DeclareModule PBMap ;-Proxy ON/OFF Global Proxy = #False Declare InitPBMap() + Declare SetMapServer(ServerURL.s="http://tile.openstreetmap.org/",TileSize.l=256,ZoomMin.l=0,ZoomMax.l=18) Declare MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i) Declare Event(Event.l) Declare SetLocation(latitude.d, longitude.d, zoom = 15, mode.i = #PB_Absolute) @@ -841,7 +842,7 @@ Module PBMap EndProcedure Procedure RefreshMapGadget() - SignalSemaphore(OSM\Drawing\Semaphore) + SignalSemaphore(PBMap\Drawing\Semaphore) EndProcedure Procedure Event(Event.l) @@ -856,6 +857,8 @@ Module PBMap Select Gadget Case PBMap\Gadget Select EventType() + Case #PB_EventType_MouseWheel + SetZoom(GetGadgetAttribute(PBMap\Gadget,#PB_Canvas_WheelDelta),#PB_Relative) Case #PB_EventType_LeftButtonDown ;Check if we select a marker MouseX = PBMap\Position\x - GadgetWidth(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) @@ -1065,8 +1068,8 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf ; IDE Options = PureBasic 5.50 (Windows - x86) -; CursorPosition = 272 -; FirstLine = 224 +; CursorPosition = 860 +; FirstLine = 847 ; Folding = --------- ; EnableThread ; EnableXP From a851b37ef3e5716086e2998941eafff5214dcac9 Mon Sep 17 00:00:00 2001 From: thyphoonfr Date: Thu, 4 Aug 2016 09:45:14 +0200 Subject: [PATCH 4/4] Add SetCallBackMainPointer() to draw your own main pointer --- PBMap.pb | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 3f1fbf2..5795e5f 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -36,7 +36,8 @@ DeclareModule PBMap Declare DrawingThread(Null) Declare SetZoom(Zoom.i, mode.i = #PB_Relative) Declare ZoomToArea() - Declare SetCallBackLocation(*CallBackLocation) + Declare SetCallBackLocation(CallBackLocation.i) + Declare SetCallBackMainPointer(CallBackMainPointer.i) Declare LoadGpxFile(file.s); Declare AddMarker(Latitude.d,Longitude.d,color.l=-1, CallBackPointer.i = -1) Declare Quit() @@ -122,6 +123,7 @@ Module PBMap Drawing.DrawingParameters ; Drawing parameters based on focus point ; CallBackLocation.i ; @Procedure(latitude.d,lontitude.d) + CallBackMainPointer.i ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib) ; Position.PixelPosition ; Actual focus point coords in pixels (global) MoveStartingPoint.PixelPosition ; Start mouse position coords when dragging the map @@ -701,7 +703,12 @@ Module PBMap DrawTiles(@Drawing) DrawTrack(@Drawing) DrawMarker(@Drawing) - Pointer(Drawing\CenterX, Drawing\CenterY, #Red) + ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib) + If PBMap\CallBackMainPointer > 0 + CallFunctionFast(PBMap\CallBackMainPointer, Drawing\CenterX, Drawing\CenterY) + Else + Pointer(Drawing\CenterX, Drawing\CenterY, #Red) + EndIf StopVectorDrawing() ;Redraw ; If something was not correctly drawn, redraw after a while @@ -817,6 +824,10 @@ Module PBMap PBMap\CallBackLocation = CallBackLocation EndProcedure + Procedure SetCallBackMainPointer(CallBackMainPointer.i) + PBMap\CallBackMainPointer = CallBackMainPointer + EndProcedure + Procedure.d GetLatitude() Protected Value.d LockMutex(PBMap\Drawing\Mutex) @@ -841,10 +852,7 @@ Module PBMap ProcedureReturn Value EndProcedure - Procedure RefreshMapGadget() - SignalSemaphore(PBMap\Drawing\Semaphore) - EndProcedure - + Procedure Event(Event.l) Protected Gadget.i Protected MouseX.i, MouseY.i @@ -982,6 +990,11 @@ CompilerIf #PB_Compiler_IsMainFile FillPath(#PB_Path_Preserve):VectorSourceColor(RGBA(0, 0, 0, 255)):StrokePath(1) EndProcedure + Procedure MainPointer(x.i, y.i) + VectorSourceColor(RGBA(255, 255,255, 255)):AddPathCircle(x, y,32):StrokePath(1) + VectorSourceColor(RGBA(0,0,0, 255)):AddPathCircle(x, y,29):StrokePath(2) + EndProcedure + Procedure ResizeAll() ResizeGadget(#Map,10,10,WindowWidth(#Window_0)-198,WindowHeight(#Window_0)-59) ResizeGadget(#Text_1,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) @@ -1029,6 +1042,7 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::InitPBMap() PBMap::MapGadget(#Map, 10, 10, 512, 512) PBMap::SetCallBackLocation(@UpdateLocation()) + PBMap::SetCallBackMainPointer(@MainPointer()) ;To change the Main Pointer PBMap::SetLocation(49.04599, 2.03347, 17) PBMap::AddMarker(49.0446828398, 2.0349812508, -1, @MyPointer()) @@ -1068,8 +1082,8 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf ; IDE Options = PureBasic 5.50 (Windows - x86) -; CursorPosition = 860 -; FirstLine = 847 +; CursorPosition = 994 +; FirstLine = 969 ; Folding = --------- ; EnableThread ; EnableXP