Je commence avec un code sur Google Maps. C'est un vieux code que j'avais fait en me basant sur une procédure que j'avais trouvé sur le forum anglais.
Code : Tout sélectionner
; Google Maps V1
; By MetalOS
Enumeration
#ROADMAP
#SATELLITE
#TERRAIN
#HYBRID
EndEnumeration
;{ Windows
Enumeration
#Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
#Image_0
#Button_1
#Button_2
#Button_3
#Button_4
#String_5
#Button_6
#String_7
#ComboBox_8
#TrackBar_9
#Button_10
EndEnumeration
;}
;{ Images
Enumeration
#Image_Image_0
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
InitNetwork()
UsePNGImageDecoder()
Global MapType, myImage,GX$,GY$,p
Procedure.l getMapImage( MapAddress.s, Zoom=10, MapType = #ROADMAP, Markers.s = "" )
RetVal = 0
If Markers <> ""
myRequestTwo.s = "/maps/api/staticmap?center="+ URLEncoder(MapAddress) + "&" + URLEncoder(Markers) + "&zoom=" + Str(Zoom) + "&size=500x500"
Else
myRequestTwo.s = "/maps/api/staticmap?center="+ URLEncoder(MapAddress) + "&zoom=" + Str(Zoom) + "&size=500x500"
EndIf
Select MapType
Case #SATELLITE
myRequestTwo.s + "&maptype=satellite"
Case #TERRAIN
myRequestTwo.s + "&maptype=terrain"
Case #HYBRID
myRequestTwo.s + "&maptype=hybrid"
Default
myRequestTwo.s + "&maptype=roadmap"
EndSelect
myRequestTwo.s + "&sensor=false"
myConnection = OpenNetworkConnection("maps.google.com", 80, #PB_Network_TCP)
If myConnection = 0
ProcedureReturn 0
EndIf
myRequest.s = "GET "+ myRequestTwo + " HTTP/1.0" + #CRLF$
myRequest.s + "Content-Type: application/x-www-form-urlencoded; charset=iso-8859-1" + #CRLF$
myRequest.s + "Host: maps.google.com" + #CRLF$ + #CRLF$
*buffer = AllocateMemory(65535)
*bufferTwo = AllocateMemory(65535)
bfTwoPtr = 0
mSize = 65535
SendNetworkString(myConnection, myRequest)
dwBytes = 1
While dwBytes > 0
dwBytes = ReceiveNetworkData(myConnection, *buffer, 65535)
If dwBytes > 0
If (*bufferTwo + dwBytes) >= mSize
mSize + 65535
*bufferTwo = ReAllocateMemory(*bufferTwo, mSize)
EndIf
CopyMemory(*buffer, (*bufferTwo+bfTwoPtr), dwBytes)
bfTwoPtr + dwBytes
EndIf
Wend
CloseNetworkConnection(myConnection)
FreeMemory(*buffer)
dblCrlf.s = #CRLF$+#CRLF$
found = 0
For k = 0 To bfTwoPtr
If k > bfTwoPtr
Break
EndIf
If PeekS(*bufferTwo+k, 4) = dblCrlf
found = k
headerInfo.s = PeekS(*bufferTwo, k)
dataBeginSpot = (k + 4)
*dataBegin = (*bufferTwo + dataBeginSpot)
dataLength = (bfTwoPtr - dataBeginSpot)
Break
EndIf
Next
RetVal = CatchImage(#PB_Any, *dataBegin, dataLength)
FreeMemory(*bufferTwo)
ProcedureReturn RetVal
EndProcedure
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 477, 84, 760, 509, "Google Maps V1 by MetalOS", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
ImageGadget(#Image_0, 5, 5, 500, 500, 0, #PB_Image_Border)
ButtonGadget(#Button_1, 600, 285, 40, 60, "H")
ButtonGadget(#Button_2, 645, 345, 40, 60, "D")
ButtonGadget(#Button_3, 555, 345, 40, 60, "G")
ButtonGadget(#Button_4, 600, 405, 40, 60, "B")
StringGadget(#String_5, 535, 55, 60, 20, "48.265")
ButtonGadget(#Button_6, 600, 345, 40, 60, "Ok")
StringGadget(#String_7, 535, 95, 60, 20, "6.358")
ComboBoxGadget(#ComboBox_8, 520, 150, 225, 20)
TrackBarGadget(#TrackBar_9, 515, 470, 230, 30, 1, 20, #PB_TrackBar_Ticks):SetGadgetState(#TrackBar_9,10)
ButtonGadget(#Button_10, 625, 50, 110, 65, "Capturer")
AddGadgetItem(#ComboBox_8, -1,"ROADMAP")
AddGadgetItem(#ComboBox_8, -1,"SATELLITE")
AddGadgetItem(#ComboBox_8, -1,"TERRAIN")
AddGadgetItem(#ComboBox_8, -1,"HYBRID")
SetGadgetState(#ComboBox_8,0)
EndIf
EndProcedure
Procedure GetNewMap()
GX$=GetGadgetText(#String_5)
GY$=GetGadgetText(#String_7)
myImage = getMapImage(GX$+","+GY$,GetGadgetState(#TrackBar_9),GetGadgetState(#ComboBox_8))
If myImage
SetGadgetState(#Image_0,ImageID(myImage))
EndIf
EndProcedure
OpenWindow_Window_0()
;{- Event loop
Repeat
Event = WaitWindowEvent()
Select Event
; ///////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #Image_0
ElseIf EventGadget = #Button_1
Up.f=ValF(GetGadgetText(#String_5))+0.005
SetGadgetText(#String_5,StrF(Up))
GetNewMap()
ElseIf EventGadget = #Button_2
Up.f=ValF(GetGadgetText(#String_7))+0.005
SetGadgetText(#String_7,StrF(Up))
GetNewMap()
ElseIf EventGadget = #Button_3
Up.f=ValF(GetGadgetText(#String_7))-0.005
SetGadgetText(#String_7,StrF(Up))
GetNewMap()
ElseIf EventGadget = #Button_4
Up.f=ValF(GetGadgetText(#String_5))-0.005
SetGadgetText(#String_5,StrF(Up))
GetNewMap()
ElseIf EventGadget = #Button_10
If myImage
SaveImage(myImage,Str(p)+"_"+GX$+"_"+GY$+".bmp")
p+1
EndIf
ElseIf EventGadget = #Button_6
GetNewMap()
ElseIf EventGadget = #ComboBox_8
If MapType<>GetGadgetState(#ComboBox_8)
MapType=GetGadgetState(#ComboBox_8)
GetNewMap()
EndIf
ElseIf EventGadget = #TrackBar_9
GetNewMap()
EndIf
; ////////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
CloseWindow(#Window_0)
Break
EndIf
EndSelect
ForEver
;
;}