var GeoInfo = null; var Map = null; function load() { if (GBrowserIsCompatible()) { Map = new GMap2(document.getElementById("map")); Map.setCenter(new GLatLng(19.97, 13.71), 2); Map.addControl (new GLargeMapControl()); // Map.addControl (new GOverviewMapControl()); Map.enableScrollWheelZoom(); /* Just instantiating new gkbhndlr is good enough; keyboard events will happen. */ var kk = new GKeyboardHandler (Map); /* var m = new GMarker(new GLatLng (33.6, -117.7)); Map.addOverlay (m); */ } } function get_geoinfo() { Map.clearOverlays(); HTTP.getText ("http://www.tlg.uci.edu/demo/g2", function (response) { GeoInfo = eval ('(' + response + ')'); var GCoder = new GClientGeocoder(); for (var i = 0; i < GeoInfo.length; ++i) { if (GeoInfo[i].latitude != "") { var instPt = new GMarker (new GLatLng (parseFloat (GeoInfo[i].latitude), parseFloat (GeoInfo[i].longitude))); var instInfo = '' + GeoInfo[i].inst_name + ''; Map.addOverlay (instPt); var instFn = (function () { var inf = instInfo; var pt = instPt; return function () { pt.openInfoWindowHtml (inf); }; })(); GEvent.addListener (instPt, "click", instFn); } else { var address = GeoInfo[i].city + ", " + GeoInfo[i].region + ", " + GeoInfo[i].country; var ip = GeoInfo[i].ip; var inst_name = GeoInfo[i].inst_name; var infoHTML = ''; infoHTML += inst_name == '' ? '' : '' + inst_name + '
'; infoHTML += GeoInfo[i].city + (GeoInfo[i].region == GeoInfo[i].city ? '' : ', ' + GeoInfo[i].region) + '
' + GeoInfo[i].country; var f = (function () { var info = infoHTML; var addr = address; return function (pt) { if (pt != null) { var m = new GMarker (pt); Map.addOverlay (m); GEvent.addListener (m, "click", function () {m.openInfoWindowHtml (info);}); } else { // if (console != undefined && console.log != undefined) console.log ('problem for ' + addr); } }; })(); GCoder.getLatLng (address, f); } } /* for */ }); /* getText */ // for (var i = 0; i < k1.length; ++i) console.log(k1[i]()); }