View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Driving Directions Not Showing With Destination Address as Coordinates

Thread began 10/13/2009 11:47 am by BGordon | Last modified 10/13/2009 4:38 pm by BGordon | 1655 views | 1 replies

BGordon

Driving Directions Not Showing With Destination Address as Coordinates

I am using lat/long to show the destination and using the visitor's city,province/state and country from their IP to be the default 'from' address. If I pass a street address as the destination, it gives driving directions but when I provide lat/long, the point on the map is exact but the driving directions don't render...

Is there any way to show driving directions to a lat/long when the origin is a city/state/country (with the option for a user to input their street address)?

** NOTE: WHEN VAR ADDRESS_0 IS POPULATED THE DIRECTIONS WORK FINE BUT THE PIN IS NOT EXACT... WHICH IS WHY I USE LAT/LONG FOR MY RURAL ADDRESSES... IF I BLANK OUT THESE VALUES, THE MAPPING IS PERFECT BUT NO DRIVING DIRECTIONS APPEAR

Below is my section of code that I think is pertinent:

function wagmp_map_3() {
if(GBrowserIsCompatible()) {
if(!document.getElementById('wagmp_map_3')) return false;
var map = new GMap2(document.getElementById('wagmp_map_3'));
wagmp_map_3_obj = new WAMapRef(map);
map.enableContinuousZoom();
map.enableDoubleClickZoom();
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
var geocoder = new GClientGeocoder();

var fromAddress = {
enabled: true,
street: '<?php echo str_replace("'", "\'", "".$_SESSION['mystreet'] .""); ?>',
city: '<?php echo str_replace("'", "\'", "".$_SESSION['mycity'] .""); ?>',
state: '<?php echo str_replace("'", "\'", "".$_SESSION['myprovince'] .""); ?>',
zip: '',
country: '<?php echo str_replace("'", "\'", "".$_SESSION["country"] .""); ?>',
full: '<?php echo $_SESSION['mystreet'].",".$_SESSION['mycity'].",".$_SESSION['myprovince'].",".$_SESSION["country"]; ?>'
};

var icon_0 = new GIcon();
icon_0.image = 'google_javascript/images/traditionalflat_pacifica.png';
icon_0.shadow = 'google_javascript/images/traditionalflat_shadow.png';
icon_0.iconSize = new GSize(34,35);
icon_0.shadowSize = new GSize(34,35);
icon_0.iconAnchor = new GPoint(9,33);
icon_0.infoWindowAnchor = new GPoint(19,0);
icon_0.printImage = 'google_javascript/images/traditionalflat_pacifica.gif';
icon_0.mozPrintImage = 'google_javascript/images/traditionalflat_pacifica_mozprint.png';
icon_0.printShadow = 'google_javascript/images/traditionalflat_shadow.gif';
icon_0.transparent = 'google_javascript/images/traditionalflat_pacifica_transparent.png';

var address_0 = {
street: '',
city: '',
state: '',
zip: '',
country: '',
infowindow: 'custom',
infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><?php echo str_replace("'", "\'", "<strong>Address:</strong><br />".$row_dealermap['street_address'] ."<br />".$row_dealermap['city'] .", ".$row_dealermap['province'] ." ".$row_dealermap['country'] .""); ?></span>',
full: '<?php echo str_replace("'", "\'", "".$row_dealermap['street_address'] .""); ?>, <?php echo str_replace("'", "\'", "".$row_dealermap['city'] .""); ?>, <?php echo str_replace("'", "\'", "".$row_dealermap['province'] .""); ?>, <?php echo str_replace("'", "\'", "".$row_dealermap['country'] .""); ?>',

isdefault: true,
addressType: 'coordinates',
loop: '',
latitude: '<?php echo $row_dealermap['latitude']; ?>',
longitude: '<?php echo $row_dealermap['longitude']; ?>',
markerStyle: 'Google Traditional (flat)',
markerColor: 'Pacifica'
};

if (address_0.addressType == "coordinates") {
var cacheReturn = '';
} else {
var cacheReturn = searchCache(address_0.full, address_0.zip);
}
if (cacheReturn != "" || (address_0.addressType == "coordinates")) {
if(address_0.addressType == "coordinates") {
var latitude = address_0.latitude;
var longitude = address_0.longitude;
} else {
var latitude = cacheReturn.substring(1,cacheReturn.indexOf(",")-1);
var longitude = cacheReturn.substring(cacheReturn.indexOf(",")+1,(cacheReturn.length)-1);
}
var point = new GLatLng(latitude, longitude);
if (point && !isNaN(latitude)) {
wagmp_map_3_obj.addressFailed = false;
var marker_0 = new GMarker(point, icon_0);
GEvent.addListener(marker_0, 'click', function() {
marker_0.openInfoWindowHtml(address_0.infowindowtext);
});
if(!fromAddress.enabled || 'address_0' != 'address_0') {
map.setCenter(point, 13);
map.addOverlay(marker_0);
}
wagmp_map_3_obj.markers.push(marker_0);
wagmp_map_3_obj.addresses.push(address_0);
wagmp_map_3_obj.icons.push(icon_0);
wagmp_map_3_obj.points.push(point);
} else {
if (wagmp_map_3_obj.addressFailed) {
map.setCenter(new GLatLng(30, -98), 3);
}
wagmp_map_3_obj.addressFailed = true;
}
} else if (address_0.addressType == "address") {
geocoder.getLatLng (
address_0.full,
function(point) {
if(point) {
this.addressFailed = false;
addToCache(address_0.full, '', point);
var marker_0 = new GMarker(point, icon_0);
GEvent.addListener(marker_0, 'click', function() {
marker_0.openInfoWindowHtml(address_0.infowindowtext);
});
if(!fromAddress.enabled || 'address_0' != 'address_0') {
map.setCenter(point, 13);
map.addOverlay(marker_0);
}
} else {
var noZipAddress = address_0.full.replace((address_0.zip+','), '');
geocoder.getLatLng (noZipAddress,
function(point) {
if(point) {
wagmp_map_3_obj.addressFailed = false;
addToCache(address_0.full, address_0.zip, point);
var marker_0 = new GMarker(point, icon_0);
GEvent.addListener(marker_0, 'click', function() {
marker_0.openInfoWindowHtml(address_0.infowindowtext);
});
if (!fromAddress.enabled || 'address_0' != 'address_0') {
map.setCenter(point, 13);
map.addOverlay(marker_0);
}
} else {
if (wagmp_map_3_obj.addressFailed) {
map.setCenter(new GLatLng(30, -98), 3);
}
wagmp_map_3_obj.addressFailed = true;
}
}
);
}
}
);
}

directions = new GDirections(map, document.getElementById('wagmp_directions_3'));
GEvent.addListener(directions, "error", function() {
map.setCenter(wagmp_map_3_obj.points[0], 13);
map.addOverlay(wagmp_map_3_obj.markers[0]);
});
directions.load('from: ' + fromAddress.full + ' to: ' + address_0.full);
wagmp_map_3_obj.directions = directions;

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...