Last active
October 31, 2019 14:28
-
-
Save flug/3efadeaa86779a3b8c67c70e0a63adb2 to your computer and use it in GitHub Desktop.
[distance map] #php #googleMap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $provenance = '26200 MONTELIMAR'; | |
| $destination = '13001 MARSEILLE'; | |
| $dom = new DOMDocument(); | |
| $dom->validateOnParse = true; | |
| $APIMAP = 'http://maps.googleapis.com/maps/api/distancematrix/xml?origins='.$provenance.'&destinations='.$destination.'&sensor=false'; | |
| $dom->load($APIMAP); | |
| $elemlist=$dom->getElementsByTagName('distance'); | |
| if ($elemlist->length != 0) | |
| { | |
| $elementDistance = $elemlist->item(0); | |
| $valeurKmlist=$elementDistance->getElementsByTagName('value'); | |
| if ($valeurKmlist->length!=0) | |
| { | |
| $valeurKm=$valeurKmlist->item(0); | |
| $resultatEnMetre = $valeurKm->firstChild->nodeValue; | |
| $resultatkm = ceil($resultatEnMetre / 1000); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment