Find a Pinpoint on map using Google Map url
<?php
$email = 'https://www.google.co.in/maps/place/Tour+Eiffel,+5+Avenue+Anatole+France,+75007+Paris,+France/@48.8582641,2.2923184,17z/data=!3m1!4b1!4m2!3m1!1s0x47e66fe1f3bfb4ad:0x7bd31375becf28cd';
if(isset($_POST['get_location']))
{
$email = $_POST['location_url'];
}
$domain = strstr($email, '@');
echo $domain;
echo "<br/>";
echo "<br/>";
echo strpbrk($domain, '@');
echo "<br/>";
$keywords = preg_split("/[\s,@]+/", $domain);
extract($keywords);
echo $keywords[0] ;
echo "<br/>";
echo $keywords[1] ;
echo "<br/>";
echo $keywords[2];
echo "<br/>";
$zoom = $keywords[3];
echo $zoom;
echo "<br/>";
$zoomlevel = substr($zoom, 0, -1);
echo $zoomlevel;
?>
<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js">
</script>
<script>
var lan = "<?php echo $keywords[1]; ?>";
var lang = "<?php echo $keywords[2]; ?>";
var zoom = "<?php echo $zoomlevel; ?>";
var zoomlevel =parseInt(zoom);
var myCenter=new google.maps.LatLng(lan,lang);
function initialize()
{
var mapProp = {
center:myCenter,
zoom:zoomlevel,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker=new google.maps.Marker({
position:myCenter,
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<form method="post" action="">
<div>
<input type="text" name="location_url">
</div>
<div>
<input type="submit" name="get_location" value="Get Location">
</div>
</form>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
Output:
Comments
Post a Comment