Im trying to pass strings with the label parameter to the directions renderer. with no luck. It seem to ignore any string parameters I try to pass through my array. I know I could use something other then the array. But I prefer it because it make it easy for me to update it.
function include(filename)
{
var head = document.getElementsByTagName('head')[0];
script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
head.appendChild(script)
}
include('geoxml3.js');
include('v3_epoly.js');
var geoXml = null;
var map = null;
var geocoder = null;
var toggleState = 1;
var infowindow = null;
var marker = null;
var Ploc = null;
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
//Voting Locations: Array element id = voting pct!
var Vloc = new Array();
Vloc[1] = '3790 S Houston St Kaufman tx 75142 (Kaufman County Library)';
Vloc[2] = '6787 FM 741 Hartland tx 75126 (community center)';
Vloc[3] = '7865 W Lewis FM 3039 Crandall tx 75114(School admin)';
Vloc[4] = '678 fm 1895 kemp 75147 (Billlock church)';
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
geocoder = new google.maps.Geocoder();
infowindow = new google.maps.InfoWindow({size: new google.maps.Size(150,50)});
var latlng = new google.maps.LatLng(32.5890, -96.308871);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('directionsPanel'));
geoXml = new geoXML3.parser({
map: map,
suppressInfoWindows: true,
polygonOptions: {clickable: false}
});
geoXml.parse('qvote.kml');
// exml = new EGeoXml({map: map, singleInfoWindow: true, createpolygon: createPoly});
}
function showAddress(address) {
var contentString = '';
Ploc = null;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var point = results[0].geometry.location;
map.setCenter(point);
if (marker && marker.setMap) marker.setMap(null);
marker = new google.maps.Marker({
map: map,
position: point,
});
for (var i=0; i<geoXml.docs[0].gpolygons.length; i++) {
if (geoXml.docs[0].gpolygons[i].Contains(point)) {
contentString = address+'<br>'+geoXml.docs[0].placemarks[i].name;
// contentString += '<br>'+point+'<br>polygon#'+i;
Ploc = geoXml.docs[0].placemarks[i].name;
i = 999;
}
}
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
if (Ploc) calcRoute(address);
});
google.maps.event.trigger(marker,'click');
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
function calcRoute(addy) {
var start = addy;
var end = Vloc[parseInt(Ploc)];
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
google.setOnLoadCallback(initialize);