close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Driving directions to either of two addresses

Thread began 3/01/2010 4:50 am by gwh362692 | Last modified 3/15/2010 4:46 pm by gwh362692 | 1857 views | 14 replies

gwh362692

When the map loads it's showing the default location but it's only marked with a flag icon. You have to click the icon to get the window to show. The empty form that the users fill in to get directions to either of the two locations also loads when the map loads.

The following is the code in the wagmp_map_1.php file

function WAMapRef(mapObj)  {
this.obj = mapObj;
this.directions = false;
this.icons = [];
this.markers = [];
this.addresses = [];
this.points = [];
this.getPointByAddress = getPointByAddressFunc;
this.addressFailed = true;
return this;
}

function WAMapPoint(theMarker, theAddress, theIcon) {
this.icon = theIcon;
this.marker = theMarker;
this.address = theAddress;
return this;
}

function getPointByAddressFunc(value,attname) {
if (!attname) attname = "street";
for (var x=0; x < this.addresses.length; x++) {
if (eval("this.addresses[x]."+attname) == value) {
return WAMapPoint(this.markers[x],this.addresses[x],this.icons[x]);
}
}
return false;
}

function getHTTPObject(){
if (window.ActiveXObject)
return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest)
return new XMLHttpRequest();
else {
return null;
}
}

function searchCache(searchStr, zip) {
var xmlDoc = null;
if (window.ActiveXObject) {//IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
} else if(navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('webkit') >= 0) { //webkit (Safari, Chrome)
var coordinates = '';
xmlDoc = getHTTPObject();
if(xmlDoc) {
xmlDoc.onreadystatechange = function() {
if(xmlDoc.readyState == 4) {
var x = xmlDoc.responseXML.getElementsByTagName("geocode_entry");
var geocode, id;
searchStr = searchStr.replace(/,/g, ''); //remove commas
for (i=0; i < x.length; i++) {
id = x[i].getAttribute("ID");
if (id == searchStr) {
coordinates = x[i].getElementsByTagName("geocode")[0].childNodes[0].nodeValue;
return coordinates;
}
}
}
};
xmlDoc.open("GET", "_promaps_cache/_promaps_geocache.xml", false);
xmlDoc.send(null);
}

return coordinates;
} else if (document.implementation.createDocument) {//gecko (Mozilla, Firefox, Opera)
xmlDoc=document.implementation.createDocument("","",null);
} else {
return '';
}
if (xmlDoc != null) {
xmlDoc.async=false;
try {
if(xmlDoc.load("_promaps_cache/_promaps_geocache.xml")) {
var x=xmlDoc.getElementsByTagName("geocode_entry");
var geocode, id;
searchStr = searchStr.replace(/,/g, ''); //remove commas
for (i=0; i < x.length; i++) {
id = x[i].getAttribute("ID");
if (id == searchStr) {
return x[i].getElementsByTagName("geocode")[0].childNodes[0].nodeValue;
}
}
}
}
catch(err) {
return '';
}
}
return '';
}

function addToCache(fullAddress,zip, geocode){
httpObject = getHTTPObject();
if (httpObject != null) {
httpObject.open("POST", "google_javascript/promaps_geocache_php.php", true);
httpObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var entryId = fullAddress.replace(/,/g, '');
if (zip != '') {
fullAddress = fullAddress.replace(zip+',', '');
}
entryId = escape(entryId);
fullAddress = escape(fullAddress);
geocode = escape(geocode);
httpObject.send("sender=promapsforgoogle&action=add&entryId="+entryId+"&address="
+fullAddress+"&geocode="+geocode);
}
}


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

var fromAddress = {
enabled: true,
street: '<?php echo str_replace("'", "\'", "".((isset($_POST["address1"]))?$_POST["address1"]:"") .""); ?>',
city: '<?php echo str_replace("'", "\'", "".((isset($_POST["suburb"]))?$_POST["suburb"]:"") .""); ?>',
state: '<?php echo str_replace("'", "\'", "".((isset($_POST["state"]))?$_POST["state"]:"") .""); ?>',
zip: '<?php echo str_replace("'", "\'", "".((isset($_POST["postcode"]))?$_POST["postcode"]:"") .""); ?>',
country: '<?php echo str_replace("'", "\'", "".((isset($_POST["country"]))?$_POST["country"]:"") .""); ?>',
full: '<?php echo str_replace("'", "\'", "".((isset($_POST["address1"]))?$_POST["address1"]:"") .""); ?>, <?php echo str_replace("'", "\'", "".((isset($_POST["suburb"]))?$_POST["suburb"]:"") .""); ?>, <?php echo str_replace("'", "\'", "".((isset($_POST["state"]))?$_POST["state"]:"") .""); ?>, <?php echo str_replace("'", "\'", "".((isset($_POST["postcode"]))?$_POST["postcode"]:"") .""); ?>, <?php echo str_replace("'", "\'", "".((isset($_POST["country"]))?$_POST["country"]:"") .""); ?>'
};

var icon_0 = new GIcon();
icon_0.image = 'google_javascript/images/flag_pacifica.png';
icon_0.shadow = 'google_javascript/images/flag_shadow.png';
icon_0.iconSize = new GSize(31,35);
icon_0.shadowSize = new GSize(31,35);
icon_0.iconAnchor = new GPoint(4,27);
icon_0.infoWindowAnchor = new GPoint(8,3);
icon_0.printImage = 'google_javascript/images/flag_pacifica.gif';
icon_0.mozPrintImage = 'google_javascript/images/flag_pacifica_mozprint.png';
icon_0.printShadow = 'google_javascript/images/flag_shadow.gif';
icon_0.transparent = 'google_javascript/images/flag_pacifica_transparent.png';

<?php $rstDestination_id = 0; ?>
<?php do { ?>
var address_0_<?php echo $rstDestination_id; ?> = {
street: '<?php echo str_replace("'", "\'", "".$row_rstDestination['street'] .""); ?>',
city: '<?php echo str_replace("'", "\'", "".$row_rstDestination['suburb'] .""); ?>',
state: '<?php echo str_replace("'", "\'", "".$row_rstDestination['state'] .""); ?>',
zip: '<?php echo str_replace("'", "\'", "".$row_rstDestination['postcode'] .""); ?>',
country: '<?php echo str_replace("'", "\'", "".$row_rstDestination['Country'] .""); ?>',
infowindow: 'custom',
infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><?php echo str_replace("'", "\'", "<strong>Kelly Country Head Office</strong><br />".$row_rstDestination['street'] ."<br />".$row_rstDestination['suburb'] .", ".$row_rstDestination['state'] ." ".$row_rstDestination['postcode'] ." ".$row_rstDestination['Country'] .""); ?></span>',
full: '<?php echo str_replace("'", "\'", "".$row_rstDestination['street'] .""); ?>, <?php echo str_replace("'", "\'", "".$row_rstDestination['suburb'] .""); ?>, <?php echo str_replace("'", "\'", "".$row_rstDestination['state'] .""); ?>, <?php echo str_replace("'", "\'", "".$row_rstDestination['postcode'] .""); ?>, <?php echo str_replace("'", "\'", "".$row_rstDestination['Country'] .""); ?>',
isdefault: true,
addressType: 'address',
loop: 'rstDestination',
latitude: '',
longitude: '',
markerStyle: 'Flag',
markerColor: 'Pacifica'
};

if (address_0_<?php echo $rstDestination_id; ?>.addressType == "coordinates") {
var cacheReturn = '';
} else {
var cacheReturn = searchCache(address_0_<?php echo $rstDestination_id; ?>.full, address_0_<?php echo $rstDestination_id; ?>.zip);
}
if (cacheReturn != "" || (address_0_<?php echo $rstDestination_id; ?>.addressType == "coordinates")) {
if(address_0_<?php echo $rstDestination_id; ?>.addressType == "coordinates") {
var latitude = address_0_<?php echo $rstDestination_id; ?>.latitude;
var longitude = address_0_<?php echo $rstDestination_id; ?>.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_1_obj.addressFailed = false;
var marker_0_<?php echo $rstDestination_id; ?> = new GMarker(point, icon_0);
GEvent.addListener(marker_0_<?php echo $rstDestination_id; ?>, 'click', function() {
marker_0_<?php echo $rstDestination_id; ?>.openInfoWindowHtml(address_0_<?php echo $rstDestination_id; ?>.infowindowtext);
});
if(!fromAddress.enabled || 'address_0_<?php echo $rstDestination_id; ?>' != 'address_0_0') {
if('address_0_<?php echo $rstDestination_id; ?>' == 'address_0_0')
map.setCenter(point, 13);
map.addOverlay(marker_0_<?php echo $rstDestination_id; ?>);
}
wagmp_map_1_obj.markers.push(marker_0_<?php echo $rstDestination_id; ?>);
wagmp_map_1_obj.addresses.push(address_0_<?php echo $rstDestination_id; ?>);

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...