Add CallBack when Move
Add SetCallBackLocation(CallBackLocation.i) to send Location when you move the map
This commit is contained in:
27
osm.pb
27
osm.pb
@@ -26,6 +26,7 @@ DeclareModule OSM
|
|||||||
Declare SetLocation(latitude.d, longitude.d, zoom = 15)
|
Declare SetLocation(latitude.d, longitude.d, zoom = 15)
|
||||||
Declare DrawingThread(Null)
|
Declare DrawingThread(Null)
|
||||||
Declare SetZoom(Zoom.i, mode.i = #PB_Relative)
|
Declare SetZoom(Zoom.i, mode.i = #PB_Relative)
|
||||||
|
Declare SetCallBackLocation(*CallBackLocation)
|
||||||
Declare LoadGpxFile(file.s);
|
Declare LoadGpxFile(file.s);
|
||||||
EndDeclareModule
|
EndDeclareModule
|
||||||
|
|
||||||
@@ -80,6 +81,8 @@ Module OSM
|
|||||||
TargetLocation.Location ; Latitude and Longitude from focus point
|
TargetLocation.Location ; Latitude and Longitude from focus point
|
||||||
TargetTile.Tile ; Focus Tile coord
|
TargetTile.Tile ; Focus Tile coord
|
||||||
|
|
||||||
|
CallBackLocation.i ; @Procedure(latitude.d,lontitude.d)
|
||||||
|
|
||||||
Position.Pixel ; Actual focus Point coords in pixels
|
Position.Pixel ; Actual focus Point coords in pixels
|
||||||
DeltaX.i
|
DeltaX.i
|
||||||
DeltaY.i
|
DeltaY.i
|
||||||
@@ -666,6 +669,10 @@ Module OSM
|
|||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
|
||||||
|
Procedure SetCallBackLocation(CallBackLocation.i)
|
||||||
|
OSM\CallBackLocation=CallBackLocation
|
||||||
|
EndProcedure
|
||||||
Procedure Event(Event.l)
|
Procedure Event(Event.l)
|
||||||
|
|
||||||
Protected Gadget.i
|
Protected Gadget.i
|
||||||
@@ -715,6 +722,10 @@ Module OSM
|
|||||||
CreateThread(@DrawingThread(), Null)
|
CreateThread(@DrawingThread(), Null)
|
||||||
OSM\MoveStartingPoint\x = GetGadgetAttribute(OSM\Gadget, #PB_Canvas_MouseX)
|
OSM\MoveStartingPoint\x = GetGadgetAttribute(OSM\Gadget, #PB_Canvas_MouseX)
|
||||||
OSM\MoveStartingPoint\y = GetGadgetAttribute(OSM\Gadget, #PB_Canvas_MouseY)
|
OSM\MoveStartingPoint\y = GetGadgetAttribute(OSM\Gadget, #PB_Canvas_MouseY)
|
||||||
|
;If CallBackLocation send Location to function
|
||||||
|
If OSM\CallBackLocation>0
|
||||||
|
CallFunctionFast(OSM\CallBackLocation,@OSM\TargetLocation)
|
||||||
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
Case #PB_EventType_LeftButtonUp
|
Case #PB_EventType_LeftButtonUp
|
||||||
OSM\MoveStartingPoint\x = - 1
|
OSM\MoveStartingPoint\x = - 1
|
||||||
@@ -760,6 +771,16 @@ Enumeration
|
|||||||
#Gdt_LoadGpx
|
#Gdt_LoadGpx
|
||||||
EndEnumeration
|
EndEnumeration
|
||||||
|
|
||||||
|
Structure Location
|
||||||
|
Longitude.d
|
||||||
|
Latitude.d
|
||||||
|
EndStructure
|
||||||
|
|
||||||
|
Procedure UpdateLocation(*Location.Location)
|
||||||
|
SetGadgetText(#String_0,StrD(*Location\Latitude))
|
||||||
|
SetGadgetText(#String_1,StrD(*Location\Longitude))
|
||||||
|
ProcedureReturn 0
|
||||||
|
EndProcedure
|
||||||
;- Main
|
;- Main
|
||||||
If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
|
If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
|
||||||
|
|
||||||
@@ -786,7 +807,7 @@ If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_System
|
|||||||
Define Event.i, Gadget.i, Quit.b = #False
|
Define Event.i, Gadget.i, Quit.b = #False
|
||||||
Define pfValue.d
|
Define pfValue.d
|
||||||
OSM::SetLocation(49.04599, 2.03347, 17)
|
OSM::SetLocation(49.04599, 2.03347, 17)
|
||||||
|
OSM::SetCallBackLocation(@UpdateLocation())
|
||||||
|
|
||||||
Repeat
|
Repeat
|
||||||
Event = WaitWindowEvent()
|
Event = WaitWindowEvent()
|
||||||
@@ -809,8 +830,8 @@ If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_System
|
|||||||
EndIf
|
EndIf
|
||||||
CompilerEndIf
|
CompilerEndIf
|
||||||
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
|
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
|
||||||
; CursorPosition = 783
|
; CursorPosition = 726
|
||||||
; FirstLine = 759
|
; FirstLine = 683
|
||||||
; Folding = -----
|
; Folding = -----
|
||||||
; EnableUnicode
|
; EnableUnicode
|
||||||
; EnableThread
|
; EnableThread
|
||||||
|
Reference in New Issue
Block a user