Skip to content

Instantly share code, notes, and snippets.

@vhchung
Created January 24, 2018 07:28
Show Gist options
  • Save vhchung/ca3b6df827eb5f99b823d3bc52db6720 to your computer and use it in GitHub Desktop.
Save vhchung/ca3b6df827eb5f99b823d3bc52db6720 to your computer and use it in GitHub Desktop.
get Long, Lng from google map url
<?php
$mapLink = 'https://www.google.com/maps/place/T%C3%B2a+Nh%C3%A0+S%C3%B4ng+%C4%90%C3%A0/@21.017695,105.7791101,17z/data=!3m1!4b1!4m5!3m4!1s0x313454ab30540137:0x35ac90387f094f93!8m2!3d21.01769!4d105.7813041';
preg_match('/@(\-?[0-9]+\.[0-9]+),(\-?[0-9]+\.[0-9]+)/', $mapLink, $latLngArray);
var_dump($latLngArray);
$lat = $latLngArray[1];
$lng = $latLngArray[2];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment