Two new callbacks to alter tile rendering, and to work on tile file after loading
Prototype.i ProtoDrawTile(x.i, y.i, image.i, alpha.d = 1) Prototype.s ProtoModifyTileFile(Filename.s, OriginalURL.s)
This commit is contained in:
52
PBMap.pb
52
PBMap.pb
@@ -89,6 +89,7 @@ DeclareModule PBMap
|
|||||||
Declare SetCallBackDrawTile(*CallBackLocation)
|
Declare SetCallBackDrawTile(*CallBackLocation)
|
||||||
Declare SetCallBackMarker(*CallBackLocation)
|
Declare SetCallBackMarker(*CallBackLocation)
|
||||||
Declare SetCallBackLeftClic(*CallBackLocation)
|
Declare SetCallBackLeftClic(*CallBackLocation)
|
||||||
|
Declare SetCallBackModifyTileFile(*CallBackLocation)
|
||||||
Declare MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i)
|
Declare MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i)
|
||||||
Declare.d GetLatitude()
|
Declare.d GetLatitude()
|
||||||
Declare.d GetLongitude()
|
Declare.d GetLongitude()
|
||||||
@@ -129,9 +130,10 @@ Module PBMap
|
|||||||
|
|
||||||
EnableExplicit
|
EnableExplicit
|
||||||
|
|
||||||
;-*** Callback Prototypes
|
;-*** Prototypes
|
||||||
|
|
||||||
Prototype ProtoDrawTile(x.i, y.i, image.i, alpha.d = 1)
|
Prototype.i ProtoDrawTile(x.i, y.i, image.i, alpha.d = 1)
|
||||||
|
Prototype.s ProtoModifyTileFile(Filename.s, OriginalURL.s)
|
||||||
|
|
||||||
;-*** Internal Structures
|
;-*** Internal Structures
|
||||||
|
|
||||||
@@ -293,6 +295,7 @@ Module PBMap
|
|||||||
CallBackMarker.i ; @Procedure (latitude.d, lontitude.d) to know the marker position (YA)
|
CallBackMarker.i ; @Procedure (latitude.d, lontitude.d) to know the marker position (YA)
|
||||||
CallBackLeftClic.i ; @Procedure (latitude.d, lontitude.d) to know the position on left click (YA)
|
CallBackLeftClic.i ; @Procedure (latitude.d, lontitude.d) to know the position on left click (YA)
|
||||||
CallBackDrawTile.ProtoDrawTile ; @Procedure (x.i, y.i, nImage.i) to customise tile drawing
|
CallBackDrawTile.ProtoDrawTile ; @Procedure (x.i, y.i, nImage.i) to customise tile drawing
|
||||||
|
CallBackModifyTileFile.ProtoModifyTileFile ; @Procedure (Filename.s, Original URL) to customise image file => New Filename
|
||||||
|
|
||||||
PixelCoordinates.PixelCoordinates ; Actual focus point coords in pixels (global)
|
PixelCoordinates.PixelCoordinates ; Actual focus point coords in pixels (global)
|
||||||
MoveStartingPoint.PixelCoordinates ; Start mouse position coords when dragging the map
|
MoveStartingPoint.PixelCoordinates ; Start mouse position coords when dragging the map
|
||||||
@@ -2150,6 +2153,7 @@ Module PBMap
|
|||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
;-*** Callbacks
|
;-*** Callbacks
|
||||||
|
|
||||||
Procedure SetCallBackLocation(CallBackLocation.i)
|
Procedure SetCallBackLocation(CallBackLocation.i)
|
||||||
PBMap\CallBackLocation = CallBackLocation
|
PBMap\CallBackLocation = CallBackLocation
|
||||||
EndProcedure
|
EndProcedure
|
||||||
@@ -2170,6 +2174,12 @@ Module PBMap
|
|||||||
PBMap\CallBackDrawTile = CallBackLocation
|
PBMap\CallBackDrawTile = CallBackLocation
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure SetCallBackModifyTileFile(CallBackLocation.i)
|
||||||
|
PBMap\CallBackModifyTileFile = CallBackLocation
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
;***
|
||||||
|
|
||||||
Procedure SetMapScaleUnit(ScaleUnit.i = PBMAP::#SCALE_KM)
|
Procedure SetMapScaleUnit(ScaleUnit.i = PBMAP::#SCALE_KM)
|
||||||
PBMap\Options\ScaleUnit = ScaleUnit
|
PBMap\Options\ScaleUnit = ScaleUnit
|
||||||
PBMap\Redraw = #True
|
PBMap\Redraw = #True
|
||||||
@@ -2324,6 +2334,7 @@ Module PBMap
|
|||||||
Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
||||||
Protected key.s, Touch.i
|
Protected key.s, Touch.i
|
||||||
Protected Pixel.PixelCoordinates
|
Protected Pixel.PixelCoordinates
|
||||||
|
Protected ImgNB.i, TileNewFilename.s
|
||||||
Static CtrlKey
|
Static CtrlKey
|
||||||
Protected Location.GeographicCoordinates
|
Protected Location.GeographicCoordinates
|
||||||
CanvasMouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\Drawing\RadiusX
|
CanvasMouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\Drawing\RadiusX
|
||||||
@@ -2572,8 +2583,14 @@ Module PBMap
|
|||||||
PBMap\MemCache\Images(key)\Tile = *Tile\Size
|
PBMap\MemCache\Images(key)\Tile = *Tile\Size
|
||||||
If *Tile\Size
|
If *Tile\Size
|
||||||
PBMap\MemCache\Images(key)\Tile = -1 ; Web loading thread has finished successfully
|
PBMap\MemCache\Images(key)\Tile = -1 ; Web loading thread has finished successfully
|
||||||
;n = LoadImage(#PB_Any, *Tile\CacheFile)
|
;- Allows to post edit the tile image file with a customised code
|
||||||
|
If PBMap\CallBackModifyTileFile
|
||||||
|
TileNewFilename = PBMap\CallBackModifyTileFile(*Tile\CacheFile, *Tile\URL)
|
||||||
|
If TileNewFilename
|
||||||
|
;TODO : Not used by now, a new filename is sent back
|
||||||
|
*Tile\CacheFile = TileNewFilename
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
Else
|
Else
|
||||||
PBMap\MemCache\Images(key)\Tile = 0
|
PBMap\MemCache\Images(key)\Tile = 0
|
||||||
EndIf
|
EndIf
|
||||||
@@ -2748,11 +2765,29 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
Debug "Identifier : " + *Marker\Identifier + "(" + StrD(*Marker\GeographicCoordinates\Latitude) + ", " + StrD(*Marker\GeographicCoordinates\Longitude) + ")"
|
Debug "Identifier : " + *Marker\Identifier + "(" + StrD(*Marker\GeographicCoordinates\Latitude) + ", " + StrD(*Marker\GeographicCoordinates\Longitude) + ")"
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
; Example of a custom procedure to alter tile rendering
|
||||||
Procedure DrawTileCallBack(x.i, y.i, image.i, alpha.d)
|
Procedure DrawTileCallBack(x.i, y.i, image.i, alpha.d)
|
||||||
MovePathCursor(x, y)
|
MovePathCursor(x, y)
|
||||||
DrawVectorImage(ImageID(image), 255 * alpha)
|
DrawVectorImage(ImageID(image), 255 * alpha)
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
; Example of a custom procedure to alter tile file just after loading
|
||||||
|
Procedure.s ModifyTileFileCallback(CacheFile.s, OrgURL.s)
|
||||||
|
Protected ImgNB = LoadImage(#PB_Any, CacheFile)
|
||||||
|
If ImgNB
|
||||||
|
StartDrawing(ImageOutput(ImgNB))
|
||||||
|
DrawText(0, 0,"PUREBASIC", RGB(255, 255, 0))
|
||||||
|
StopDrawing()
|
||||||
|
;*** Could be used to create new files
|
||||||
|
; Cachefile = ReplaceString(Cachefile, ".png", "_PB.png")
|
||||||
|
;***
|
||||||
|
If SaveImage(ImgNB, CacheFile, #PB_ImagePlugin_PNG, 0, 32) ;Warning, the 32 is mandatory as some tiles aren't correctly rendered
|
||||||
|
; Send back the new name (not functional by now)
|
||||||
|
ProcedureReturn CacheFile
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure MainPointer(x.i, y.i)
|
Procedure MainPointer(x.i, y.i)
|
||||||
VectorSourceColor(RGBA(255, 255,255, 255)) : AddPathCircle(x, y,32) : StrokePath(1)
|
VectorSourceColor(RGBA(255, 255,255, 255)) : AddPathCircle(x, y,32) : StrokePath(1)
|
||||||
VectorSourceColor(RGBA(0, 0, 0, 255)) : AddPathCircle(x, y, 29):StrokePath(2)
|
VectorSourceColor(RGBA(0, 0, 0, 255)) : AddPathCircle(x, y, 29):StrokePath(2)
|
||||||
@@ -2853,7 +2888,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
PBMAP::SetMapScaleUnit(PBMAP::#SCALE_KM) ; To change the scale unit
|
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::AddMarker(49.0446828398, 2.0349812508, "", "", -1, @MyMarker()) ; To add a marker with a customised GFX
|
||||||
PBMap::SetCallBackMarker(@MarkerMoveCallBack())
|
PBMap::SetCallBackMarker(@MarkerMoveCallBack())
|
||||||
PBMap::SetCallBackDrawTile(@DrawTileCallBack())
|
;PBMap::SetCallBackDrawTile(@DrawTileCallBack())
|
||||||
|
;PBMap::SetCallBackModifyTileFile(@ModifyTileFileCallback())
|
||||||
|
|
||||||
Repeat
|
Repeat
|
||||||
Event = WaitWindowEvent()
|
Event = WaitWindowEvent()
|
||||||
@@ -2986,9 +3022,9 @@ CompilerEndIf
|
|||||||
|
|
||||||
|
|
||||||
; IDE Options = PureBasic 5.60 (Windows - x64)
|
; IDE Options = PureBasic 5.60 (Windows - x64)
|
||||||
; CursorPosition = 291
|
; CursorPosition = 2888
|
||||||
; FirstLine = 279
|
; FirstLine = 2781
|
||||||
; Folding = --------------------
|
; Folding = ---------------------
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
; CompileSourceDirectory
|
; CompileSourceDirectory
|
Reference in New Issue
Block a user