Hello All,
To preface this, I am a complete programming amateur so this may be
quite easily solved. As is though, it is frustrating me to no end.
Basically, I have a database of Venue Names with GLat and GLng (other
stuff too) that I am pulling down to my website based on a geolocated
search. The javascript that I have pulls in a formatted subset of the
database, dumps the glat and glng into an array and is supposed to
take those points and plot out several markers each with an info
window containing the details behind each marker. For some reason, the
marker geodata is not being populated and/or is not being passed. The
array is declared using [] and will not work when normally declared
using ().
It only brings up a map with the first value in the array and goes
blank if i try to manually input later entries. There is a large block
of commented out code relating to directions generation. That code
worked for some reason. If anyone can tell me what I am doing wrong in
rewriting it to map the markers and not give directions, please tell
me. Any help would be much appreciated.
var letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z'];
google.load("maps", "2", {"other_params":"sensor=true"}); var map
function initialize(){ window.map = new
google.maps.Map2(document.getElementById("map")); map.addControl(new
GLargeMapControl()); } google.setOnLoadCallback(initialize);
function getVenueResults(_zip, _num, _remove){ var rFlag = '';
if(_remove != null){ rFlag = "&removeId=" + _remove; } var url = 'ajax/
getVenues.php?zip=' + _zip + "&num=" + _num + rFlag;
new Ajax.Updater('resultsContainer', url, { onComplete:
processResults }); }
function processResults(){ window.map.clearOverlays(); var waypoints =
[]; var resultsList = $$('.resultWrapper'); var stepList = $$
('.resultDirections'); for(i=0; i
for(i=0; i<resultsList.length; i++){
var resultsElem = resultsList[i];
resultsElem.removeClassName('firstResult');
resultsElem.removeClassName('lastResult');
if(i == 0){
resultsElem.addClassName('firstResult');
}
if(i == resultsList.length - 1){
resultsElem.addClassName('lastResult');
}
var insertContent = '<div class="resultDirections"
id="resultDirections' + i + '"></div>';
Element.insert(resultsElem, { bottom : insertContent })
var num = resultsElem.getElementsByClassName('numHolder');
num[0].innerHTML = '<b>' + letters[i] + ".</b> ";
var geolat = resultsElem.getElementsByClassName('geolat')
[0].value;
var geolong = resultsElem.getElementsByClassName('geolong')
[0].value;
var point = new GLatLng(geolat, geolong);
waypoints[i] = point;
}
if(waypoints.length == 1){
map.setCenter(waypoints[0], 16);
map.addOverlay(new GMarker(waypoints[0]));
resultsElem.getElementsByClassName('numHolder')[0].innerHTML = '';
}else{
map.setCenter(waypoints[0], 16);
for(j=0; j< waypoints.length; j++) {
var vLoc = waypoints[j];
var vInfo =
resultsElem.getElementByClassName('resultBox[j]]').innerHTML;
//unfinished function to mine name out of div and make it
the marker title
//x = resultsElem.getElementsByTagName("b");
// for (i=0;i<x.length;i++)
//
//marker.value =
resultsElem.getElementBy('numHolder').innerHTML
var marker = createMarker(vLoc, vInfo);
map.addOverlay(marker);
}
}
function createMarker(vLoc, vInfo) {
var marker = (new GMarker(vLoc));
var cont = vInfo;
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(cont);
});
return marker;
}
//var directions = new GDirections(window.map,
document.getElementById('directionsPanel'));
//directions.loadFromWaypoints(waypoints, { travelMode:
G_TRAVEL_MODE_WALKING });
//GEvent.addListener(directions, "load" , function() {
// var numRoutes = directions.getNumRoutes();
// for(j=0; j< numRoutes; j++){
// var thisRoute = directions.getRoute(j);
// var routeText = '';
// for(k=0; k < thisRoute.getNumSteps(); k++){
// var thisStep = thisRoute.getStep(k);
// if(k != 0){ routeText += " || "; }
// routeText += thisStep.getDescriptionHtml();
// }
// $('resultDirections' + j).innerHTML = routeText;
// }
// $('resultDirections' + numRoutes).hide();
//});
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.