/    Sign up×
Community /Pin to ProfileBookmark

Someone help me please.

Ive got codes that calculate the route & prices between distances upon entering data into two boxes lablled “to” and “from” using google maps. What I need is the route to be shown on the map. Ive tried the googlemap forums but they wont help me (they just direct me to the documentation which I dont really understand).
Anyway after trying to read and understand the code, I managed to get the map to display but when using the form to find postcodes, it stops working. If anyone can help me complete this small project (using google maps or any other mapping software) Ill paypal £20 ?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@stylishjmauthorJan 10.2010 — Also, when needed I can post up the source code
Copy linkTweet thisAlerts:
@KorJan 10.2010 — Also, when needed I can post up the source code[/QUOTE]
You should have done that from the fry beginning. A link to a test page could be event better.
Copy linkTweet thisAlerts:
@stylishjmauthorJan 10.2010 — was thinking this but cant find the edit post button. anyway the page im using at the moment is http://edgwarelocalcars.co.uk/Booking.html
Copy linkTweet thisAlerts:
@stylishjmauthorJan 10.2010 —  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

<meta name="robots" content="noindex,follow" />

<title>Booking</title>

<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAGfp-kB-ecQV76vLZmALX-hQdUYxVEnzxBzx6mQFItuyN1MdeGxT3dGnCvGBY6M1TUZfnpZMQc8q3-w" type="text/javascript"></script>

<!-- According to the Google Maps API Terms of Service you are required display a Google map when using the Google Maps API. see: http://code.google.com/apis/maps/terms.html -->

<script type="text/javascript">

var geocoder, location1, location2, gDir;

function initialize() {
geocoder = new GClientGeocoder();
gDir = new GDirections();
GEvent.addListener(gDir, "load", function() {
var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
var drivingDistanceMilesCost = drivingDistanceMiles + 5.5;


document.getElementById('resultsa').innerHTML = '<strong>From: </strong>' + location1.address + '<br /> ';
document.getElementById('resultsb').innerHTML = '<strong>To: </strong>' + location2.address + ' <br />' ;

document.getElementById('results2').innerHTML = '&#163;' + drivingDistanceMilesCost.toFixed(2);
});
}

function showLocation() {
geocoder.getLocations(document.forms[0].address1.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, please enter a valid postcode");
}
else
{
location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
geocoder.getLocations(document.forms[0].address2.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, please enter a valid postcode");
}
else
{
location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
gDir.load('from: ' + location1.address + ' to: ' + location2.address);
}
});
}
});
}

</script>
<style type="text/css">
a {
color: #800000;
}
.style2 {
text-align: left;
}
</style>

</head>

<body onload="initialize()" style="background-color: #DDDDDD">

<form action="#" onsubmit="showLocation(); return false;">
<div class="style2">
<p class="style2">
<input type="text" name="address1" onfocus="this.value=''" value="From" style="border: #800000 1px solid; width: 270px;" style="width: 272px" /></p>
<p><p id="resultsa"></p>
<input type="text" name="address2" onfocus="this.value=''" value="To" style="border: #800000 1px solid; width: 270px;" style="width: 272px" /></p>
<p><p id="resultsb"></p>
<input type="submit" style="border: #800000 1px solid; width: 178px;" value="Calculate Price" />
</p>
</div>
</form>
<p id="results"></p>

<p id="results2"></p>

</body>

</html>
[/quote]

Source
Copy linkTweet thisAlerts:
@stylishjmauthorJan 12.2010 — I have now completed the previous problem of getting the route on a map succesfully but now I am presented with a new problem.

I need to have auto-suggest when someone types in a vague address or a company that has multiple addresses (for example Hilton Hotel or a postcode / road name without a door number etc).

Anyway I was directed to http://econym.org.uk/gmap/ and tried implementing the parts of the source code with my source code http://www.edgwarelocalcars.co.uk/Booking.html but I havent got much knowlegde of javascript so Im finding the task near impossible.

Can anyone help me out please?
×

Success!

Help @stylishjm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...