From GamingWiki
Jump to: navigation, search
Line 43: Line 43:
 
  * Add a marker to the map
 
  * Add a marker to the map
 
  */
 
  */
function addMarker(latlng, title, descId) {
+
function addMarker(latlng, title, id) {
 +
var descId = 'desc'+id;
 
var marker = new google.maps.Marker({position:latlng, map: map, title:title});
 
var marker = new google.maps.Marker({position:latlng, map: map, title:title});
 
google.maps.event.addListener(marker, "click", function() {  
 
google.maps.event.addListener(marker, "click", function() {  
Line 49: Line 50:
 
infowindow.open(map,marker);  
 
infowindow.open(map,marker);  
 
});
 
});
GMarkers[descId] = marker;
+
GMarkers[id] = marker;
 
}
 
}
 
/**
 
/**
 
  * Add a marker with a lat/lng pair
 
  * Add a marker with a lat/lng pair
 
  */
 
  */
function addMarkerByLatLng(lat, lng, title, descId) {
+
function addMarkerByLatLng(lat, lng, title, id) {
 
var latlng = new google.maps.LatLng(lat, lng);
 
var latlng = new google.maps.LatLng(lat, lng);
addMarker(latlng, title, descId);
+
addMarker(latlng, title, id);
 
}
 
}
  
Line 62: Line 63:
 
  * Add markers by address
 
  * Add markers by address
 
  */
 
  */
function addMarkerByAddress(address, title, descId) {
+
function addMarkerByAddress(address, title, id) {
 
if (geocoder) {
 
if (geocoder) {
 
geocoder.geocode({'address':address}, function(results, status) {
 
geocoder.geocode({'address':address}, function(results, status) {
 
if (status == google.maps.GeocoderStatus.OK) {
 
if (status == google.maps.GeocoderStatus.OK) {
 
var latlng = results[0].geometry.location;
 
var latlng = results[0].geometry.location;
addMarker(latlng, title, descId);
+
addMarker(latlng, title, id);
 
} else {
 
} else {
 
//alert(address + " not found: "+results[0]+"; "+status);
 
//alert(address + " not found: "+results[0]+"; "+status);
Line 83: Line 84:
 
if (typeof marker['lat'] === 'undefined' || marker['lat'] == ''  
 
if (typeof marker['lat'] === 'undefined' || marker['lat'] == ''  
 
|| typeof marker['lng'] === 'undefined' || marker['lng'] == '') {
 
|| typeof marker['lng'] === 'undefined' || marker['lng'] == '') {
addMarkerByAddress(marker['address'], marker['name'], marker['node']);
+
addMarkerByAddress(marker['address'], marker['name'], marker['id']);
 
} else {
 
} else {
addMarkerByLatLng(marker['lat'], marker['lng'], marker['name'], marker['node']);
+
addMarkerByLatLng(marker['lat'], marker['lng'], marker['name'], marker['id']);
 
}
 
}
 
}
 
}

Revision as of 19:46, 16 May 2011