Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Google maps api with GET lat and long. php

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Google maps api with GET lat and long. php

Postby nichodiaz » Sat Apr 06, 2013 3:54 pm

I have been working on this for three days.. if you go here you can see what I have...

http://www.ogsolutions.us/aziz/directions.php


This is my current code. If someone would be willing to help me debug it I would appreciate it.. .

<html>
<head>
<link rel="stylesheet" href="styles/layout.css" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="/gmap3/gmap3.min.js"></script>
<script type="text/javascript" src="scripts/jquery.gmap.js"></script>
<script type="text/javascript">
function initGeolocation()
{
if( navigator.geolocation )
{
// Call getCurrentPosition with success and failure callbacks
navigator.geolocation.getCurrentPosition( success, fail );
}
else
{
alert("Sorry, your browser does not support geolocation services.");
}
}


function success(position)
{


document.getElementById('lat').value = position.coords.latitude
document.getElementById('longitude').value = position.coords.longitude;


}
function fail()
{
// Could not obtain location
}


</script>


</head>


<body onLoad="initialize(); initGeolocation();">


<div class="wrapper col1">


<?php
include("includes/header.php")
?>




<div id="topnav">
<?php
include("includes/nav.php")
?>




</div>
<br class="clear" />
</div>
</div>
<div class="wrapper col2">
<div id="breadcrumb">
<center>
<ul>


<form name="directions" method="GET" action="directions.php">
&nbsp;&bull;<tr>
<td valign="top">
<label for="lat">Latitude:</label>
</td>
<td valign="top">
<INPUT TYPE="text" NAME="lat" ID="lat" maxlength="30" size="25" value"">
</td>
</tr>
&nbsp;&bull;<tr>
<td valign="top">
<label for="longitude">Longitude:</label>
</td>
<td valign="top">
<INPUT TYPE="text" NAME="longitude" ID="longitude" maxlength="30" size="25" value"">
</td>
&nbsp;&bull;<tr>
<label for="submit">Submit:</label>
<td colspan="2" style=text-align:center, >
<input type="submit" value="Directions">
</center>
</td>
</tr>
</table>
</form></tr>




</div>
</div>
</ul>
</div>
<br class="clear" />
</div>




<div id="mapWrap">
<div id="mapContainer">

<?php


$latitude = $_GET["lat"];
$longitude = $_GET["longitude"];


$lat_long = $latitude.",".$longitude;


?>


<style type="text/css">
#map {
height: 500px;
width: 700px;
top: 31;
margin: 20px auto;
border: 1px solid black;
}


#list {
height: 250px;
width: 300px;
}
</style>


<script type="text/javascript">


$(function(){


$("#map").gmap3({
getroute:{
options:{
origin:"<? echo $lat_long; ?>",
destination:"32.794213,-96.618572",
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
callback: function(results){
if (!results) return;
$(this).gmap3({
map:{
options:{
zoom: 15
}
},
directionsrenderer:{
container: $(document.getElementById("list")),
options:{
directions:results
}
}
});
}
}});
});
</script>
</head>
<body>
<center>
<table>
<tr>
<td style="width: 325px">
<div id="list"></div>
</td>
<td>
<div id="map"></div>
</td>
</tr>
</table>
</center>
</body>
</div>


<br class="clear" />


</div>




<<!--
#################################################################################################### ### -->


<div class="wrapper col4">
<?php
include("includes/footer.php")
?>
</div>
</body>
</html>
nichodiaz
New php-forum User
New php-forum User
 
Posts: 7
Joined: Sat Aug 25, 2012 10:23 pm

Re: Google maps api with GET lat and long. php

Postby johnj » Sun Apr 07, 2013 9:11 pm

johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.