if you look at this page here…
[url]http://www.ogsolutions.us/aziz/directions.php
I have a google map in the center of the page
at the top of the page I have a form field that auto populates yours lat and long.
When you click the button submit it runs a file called directions.php.
I want this file to take the lat and long of the users position and then map them out
turn by turn directions in to the form field to the left you can see on the page.
I have been working on this all day and I have no clue how to set up the directions.php file.
I assume it needs to post the lat and long and waypoint address the GET the information back from
the server after its interpreted.
if anyone can help me i would appreciate it.
[code=php]
<?
$latitude = $_POST["lat"];
$longitude = $_POST["longitude"];
$lat_long = $latitude.",".$longitude;
?>
[/code]
[code=html]
<script type="text/javascript">
$("#test").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: 10,
}
},
directionsrenderer:{
container: $(document.createElement("div")).addClass("googlemap").insertAfter($("#test")),
options:{
directions:results
}
}
});
}
}});
</script>
<div id="test"></div>
[/code]
<div id="topnav">
<?php
</div>
<br class="clear" />
[code=php]
<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="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="POST" action="actions/getDirections.php">
•<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>
•<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>
•<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">
</div>
<br class="clear" />
</div>
<<!--
#################################################################################################### ### -->
<div class="wrapper col4">
<?php
include("includes/footer.php")
?>
</div>
</body>
</html>
[/code]
[code=php]
<head>
<script type="text/javascript" src="gmap3/jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="gmap3/gmap3.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<?php
$latitude = $_POST["lat"];
$longitude = $_POST["longitude"];
$lat_long = $latitude.",".$longitude;
?>
<style type="text/css">
#map {
height: 300px;
width: 400px;
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>
[/code]
[code=php]
<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>
<?php
if (isset($_POST['submit'])) {
$latitude = $_POST["lat"];
$longitude = $_POST["longitude"];
$lat_long = $latitude.",".$longitude;
}
?>
</head>
<body onLoad="initialize(); initGeolocation();">
<div class="wrapper col1">
<div id="header">
<div id="logoffButton">
<a href="logreg.php"><img src="images/demo/login.png" width="150px;"></a></div>
<br class="clear" />
<div id="logo">
<img class="imgl" src="images/demo/imgl.gif" width="150"alt="" /><br>
<p><bold> Telecommunications</bold></p>
</div>
<div id="topnav">
<ul>
<li><a href="index.php">Home</a>
<li><a href="contact.php">Contact Us</a>
<li><a href="services.php">Services</a>
<li><a href="employees.php">Employees</a>
<li><a href="dashboard.php">Dashboard</a></ul>
</div>
<br class="clear" />
</div>
</div>
<div class="wrapper col2">
<div id="breadcrumb">
<center>
<ul>
<form name="directions" method="POST" action="directions.php">
•<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>
•<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>
•<tr>
<label for="submit">Submit:</label>
<td colspan="2" style=text-align:center, >
<input type="submit" name="submit" value="Directions">
</center>
</td>
</tr>
</table>
</form></tr>
</div>
</div>
</ul>
</div>
<br class="clear" />
</div>
<div id="mapWrap">
<div id="mapContainer">
<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:"28.551772999999997,-80.7944954",
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">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var position = new google.maps.LatLng(32.794213,-96.618572);
var myOptions = {
zoom: 10,
center: position,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(
document.getElementById("map_canvas"),
myOptions);
var marker = new google.maps.Marker({
position: position,
map: map,
title:"Texcom Construction Office."
});
var contentString = '<p style="color:black;"><strong>Texcom Construction LLC</br>1426 Mariposa Dr.</br>Mesquite, TX 75150<br/><br/><a href="directions.php">Click For Directions</a></strong></p1>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
</script>
<html>
<body onLoad="initialize()">
<div id="footer">
<div class="box1">
<h2><center>About Texcom Construction LLC !</center></h2>
<img class="imgl" src="images/demo/imgl.gif" alt="" />
<p>Headquartered in North Texas, Texcom Construction LLC has and continues to provide expertly managed telecommunications technicians to serve the industry's largest wireless carriers. By challenging ourselves to build a positive reputation based on our " Customer First" philosophy and our commitment to exceeding current safety regulations, we have built a strong client base in domestic and international markets. We are ready to put this reputation to work for you. Controlled profitable growth can be achieved by using these core values to make daily decisions while constantly ursuing new oppurtunities. This dedication assures a high rate of return to all of our investors.</p>
</div>
<div class="box contactdetails">
<h2><center>Our Contact Details !</center></h2>
<ul>
<li>Texcom Construction LLC</li>
<li>1426 Mariposa Dr.</li>
<li>Mesquite, TX</li>
<li>75150</li>
<li>Tel: 214-775-0851</li>
<li>Fax: 888-888-888</li>
<li>Email: [email protected]</li>
<li class="last">LinkedIn: <a href="http://www.linkedin.com/pub/jt-cooper/10/873/8a5">JT-Cooper @ Linkedin!</a></li>
</ul>
</div>
<div class="box flickrbox">
<h2><center> <a href="directions.php">Directions To Our Office</a></center></h2>
<div class="wrap">
<div class="fix"></div>
<div id="map_canvas" style= "width:270px; height:400px"></div>
<div class="fix"></div>
</div>
</div>
<br class="clear" />
</div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper col5">
<div id="copyright">
<p class="center">Copyright © 2009 - All Rights Reserved - WWW.TEXCOMCONSTRUCTION.COM</a></p>
<br class="clear" />
</div>
</body>
</html>
</div>
</body>
</html>
[/code]
[code=php]
<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>
<?php
if (isset($_POST['submit'])) {
$latitude = $_POST["lat"];
$longitude = $_POST["longitude"];
$lat_long = $latitude.",".$longitude;
}
?>
</head>
<body onLoad="initialize(); initGeolocation();">
<div class="wrapper col1">
<div id="header">
<div id="logoffButton">
<a href="logreg.php"><img src="images/demo/login.png" width="150px;"></a></div>
<br class="clear" />
<div id="logo">
<img class="imgl" src="images/demo/imgl.gif" width="150"alt="" /><br>
<p><bold> Telecommunications</bold></p>
</div>
<div id="topnav">
<ul>
<li><a href="index.php">Home</a>
<li><a href="contact.php">Contact Us</a>
<li><a href="services.php">Services</a>
<li><a href="employees.php">Employees</a>
<li><a href="dashboard.php">Dashboard</a></ul>
</div>
<br class="clear" />
</div>
</div>
<div class="wrapper col2">
<div id="breadcrumb">
<center>
<ul>
<form name="directions" method="POST" action="directions.php">
•<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>
•<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>
•<tr>
<label for="submit">Submit:</label>
<td colspan="2" style=text-align:center, >
<input type="submit" name="submit" value="Directions">
</center>
</td>
</tr>
</table>
</form></tr>
</div>
</div>
</ul>
</div>
<br class="clear" />
</div>
<div id="mapWrap">
<div id="mapContainer">
<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">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var position = new google.maps.LatLng(32.794213,-96.618572);
var myOptions = {
zoom: 10,
center: position,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(
document.getElementById("map_canvas"),
myOptions);
var marker = new google.maps.Marker({
position: position,
map: map,
title:"Texcom Construction Office."
});
var contentString = '<p style="color:black;"><strong>Texcom Construction LLC</br>1426 Mariposa Dr.</br>Mesquite, TX 75150<br/><br/><a href="directions.php">Click For Directions</a></strong></p1>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
</script>
<html>
<body onLoad="initialize()">
<div id="footer">
<div class="box1">
<h2><center>About Texcom Construction LLC !</center></h2>
<img class="imgl" src="images/demo/imgl.gif" alt="" />
<p>Headquartered in North Texas, Texcom Construction LLC has and continues to provide expertly managed telecommunications technicians to serve the industry's largest wireless carriers. By challenging ourselves to build a positive reputation based on our " Customer First" philosophy and our commitment to exceeding current safety regulations, we have built a strong client base in domestic and international markets. We are ready to put this reputation to work for you. Controlled profitable growth can be achieved by using these core values to make daily decisions while constantly ursuing new oppurtunities. This dedication assures a high rate of return to all of our investors.</p>
</div>
<div class="box contactdetails">
<h2><center>Our Contact Details !</center></h2>
<ul>
<li>Texcom Construction LLC</li>
<li>1426 Mariposa Dr.</li>
<li>Mesquite, TX</li>
<li>75150</li>
<li>Tel: 214-775-0851</li>
<li>Fax: 888-888-888</li>
<li>Email: [email protected]</li>
<li class="last">LinkedIn: <a href="http://www.linkedin.com/pub/jt-cooper/10/873/8a5">JT-Cooper @ Linkedin!</a></li>
</ul>
</div>
<div class="box flickrbox">
<h2><center> <a href="directions.php">Directions To Our Office</a></center></h2>
<div class="wrap">
<div class="fix"></div>
<div id="map_canvas" style= "width:270px; height:400px"></div>
<div class="fix"></div>
</div>
</div>
<br class="clear" />
</div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper col5">
<div id="copyright">
<p class="center">Copyright © 2009 - All Rights Reserved - WWW.TEXCOMCONSTRUCTION.COM</a></p>
<br class="clear" />
</div>
</body>
</html>
</div>
</body>
</html>
[/code]
0.1.9 — BETA 5.25