utiliser Google map et compagnie

Partagez votre expérience de PureBasic avec les autres utilisateurs.
Avatar de l’utilisateur
Zorro
Messages : 2185
Inscription : mar. 31/mai/2016 9:06

utiliser Google map et compagnie

Message par Zorro »

voici un code, qui montre différentes façons d'afficher une carte Google map , openStreet map etc ...


en entrant une coordonnée GPS ou bien une adresse , on peut faire calculer un trajet
différentes possibilités d'affichage , il suffit de dé-commenter les choix proposés :)

Code : Tout sélectionner

;{- Enumerations / DataSections
;{ Windows
Enumeration
		#Window
EndEnumeration
;}
;{ Gadgets
Enumeration
		#Web
EndEnumeration
;}
Define.l Event
Declare setbrowseremulation()
;}
SetBrowserEmulation()
If OpenWindow(#Window, 1, 1, 1195, 732, "GPS", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
		; DEcochez le WebGadget que vous voulez tester .......... 
		; en utilisant  OpenStreetMap
		
		; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		; par point GPS :
		; coordonées de la tour eiffel : 48.85826,2.29450
		;;WebGadget(#Web, 60, 55, 1055, 645, "http://www.openstreetmap.org/?mlat=48.85826&mlon=2.29450&zoom=17"+layer.s)  .. a activer pour test
		
		; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		; en utilisant FACILMAP (qui pioche chez Google ou openstreetmap ou meme Bing )
		; ici on affiche  un trajet (Fraisses a Firminy en Rhone Alpes )
		; calcul d'un itineraire  de 10 rue de la Gare a Fraisses (42490 ) a Rue de la gare a Firminy (42)
		adresse_dep.s="10 rue de la gare,42490 Fraisses"
		adresse_arr.s="rue de la gare,42700 Firminy France"
		moyen_de_transport.s="car" ; voiture 
		;moyen_de_transport.s="bicycle" ; velo  a activer pour test
		;moyen_de_transport.s="foot" ; a pied  a activer pour test
		;moyen_de_transport.s="bird" ; vol d'oiseau  a activer pour test
		zoom.s="zoom=16"
		;layer.s="layer=MSfR" ; vue OpenstreetmapRoad  a activer pour test
		;layer.s="layer=OSB" ; vue Openstreetmap browser  a activer pour test
		;layer.s="layer=OCyc" ;vue OpenStreetMap cyclo   a activer pour test
		layer.s="layer=GgSt" ; vue Google Street a activer pour test
		;layer.s="layer=GgSa" ; vue Google Satelite   a activer pour test
		;layer.s="layer=GgHy" ; Vue Google Hybride   a activer pour test
		;Layer.s="layer=GgTe" ; vue Gogle Ground   a activer pour test
		;;WebGadget(#Web, 60, 55, 1055, 645, "https://facilmap.org/#lon=4.2756845;lat=45.39088201;"+zoom.s+";"+layer.s+";c.s.type=fastest;c.s.medium="+moyen_de_transport+";q.0=" +adresse_dep.s+";q.1="+adresse_arr.s)   a activer pour test
		; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		; *****************************************************************************
		; *****************************************************************************
		; *****************************************************************************
		; *****************************************************************************
		; SINON 
		; en utilisant GoogleMap :
		; exemple d'utilisation  a activer
		; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		; ************ affichage par point GPS ********************************************************
		; affiche le Lieu: 48.8578583    2.2940307  (la tour Eifel )
		coordonnees.s="48.8578583,+2.2940307"
		zoom.s="17"
		;; sat.s="/data=!3m1!1e3" ; vue satelitte ......... a activer pour test
		WebGadget(#Web, 60, 55, 1055, 645, "https://www.google.fr/maps/dir/"+coordonnees.s+"/"+coordonnees.s+"/@"+coordonnees.s+","+zoom.s+"z"+sat.s)
		; ********************************************************************************************
		; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		; ************* affichage par Adresse et d'un trajet entre deux adresses **************************
		; Affiche le Trajet de l'adresse 12 rue Edouard lefebvre a Versailles  ..... a20+Avenue+du+Général+Leclerc,+Le+Chesnay
		;Adress_dep.s="12 Rue Edouard Lefebvre, Versailles"  a activer pour test
		;Adress_arr.s="20 Avenue du Général Leclerc, Le Chesnay"  a activer pour test
		;zoom.s="14"  a activer pour test
		;sat.s="/data=!3m1!1e3" ; vue satelitte  a activer pour test
		;;WebGadget(#Web, 60, 55, 1055, 645, "https://www.google.fr/maps/dir/"+Adress_dep.s+"/"+Adress_arr.s+","+zoom.s+"z"+sat.s)  a activer pour test
		; **************************************************************
EndIf
;{- Event loop
Repeat
		Event = WaitWindowEvent(12)
		Select Event
				; ///////////////////
		Case #PB_Event_Gadget
				Select EventGadget()
				Case #Web
				EndSelect
				; ////////////////////////
		Case #PB_Event_CloseWindow
				Select EventWindow()
				Case #Window
						CloseWindow(#Window)
						Break
				EndSelect
		EndSelect
Forever
;
Procedure SetBrowserEmulation()
		; https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx
		Protected IEVersion.s = "2AF9" ; setting the desired IE-Version (see below)
		; 11001 (0x2AF9) IE11. Webpages are displayed in IE11 edge mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
		; 11000 (0x2AF8) IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.
		; 10001 (0x2711) IE10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
		; 10000 (0x2710) IE10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for IE 10.
		;  9999 (0x270F) IE9.  Webpages are displayed in IE9 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
		;  9000 (0x2328) IE9.  Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for IE 9. Important  In IE 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
		;  8888 (0x22B8) IE8.  Webpages are displayed in IE8 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
		;  8000 (0x1F40) IE8.  Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for IE 8 Important  In IE 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
		;  7000 (0x1B58) IE7.  Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control. 
		Protected RegistryString.s
		Protected TempRegFile.s
		Protected FF
		RegistryString = "Windows Registry Editor Version 5.00" + #CRLF$ +
		"" + #CRLF$ +
		"[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]" + #CRLF$ +
		Chr(34) + GetFilePart(ProgramFilename()) + Chr(34) + "=dword:" + IEVersion + #CRLF$
		TempRegFile = GetTemporaryDirectory() + "SetBrowserEmulation.reg"
		FF = CreateFile(#PB_Any, TempRegFile)
		If FF
				WriteString(FF, RegistryString)
		CloseFile(FF)
		RunProgram("regedit", "/s " + Chr(34) + TempRegFile + Chr(34), "", #PB_Program_Hide | #PB_Program_Wait)
		DeleteFile(TempRegFile)
		ProcedureReturn #True
EndIf
EndProcedure 
; Epb

Image
Image
Site: http://michel.dobro.free.fr/
Devise :"dis moi ce dont tu as besoin, je t'expliquerai comment t'en passer"