GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
Digital_Repository
Browse code
- Added "+" to unmappable string.
master
1 parent
1b602e6
commit
34b92017992446272fc98fcbecefe886090a1862
nstanger
authored
on 13 May 2006
Patch
Showing
1 changed file
Repositories/Maps/google_map.js
Ignore Space
Show notes
View
Repositories/Maps/google_map.js
function load( startMillis, numEntries ) { if ( GBrowserIsCompatible() ) { // Create new map. var map = new GMap2( document.getElementById( "map" ) ); map.addControl( new GSmallMapControl() ); map.addControl( new GMapTypeControl() ); map.setCenter( new GLatLng(10, 0), 2 ); // Creates a marker at the given point with a label // containing the other remaining arguments. function createMarker( point, city, abstracts, downloads ) { var marker = new GMarker( point ); GEvent.addListener( marker, "click", function() { marker.openInfoWindowHtml( "<strong>" + city + "</strong> (" + abstracts + " abstracts, " + downloads + " downloads)" ); } ); return marker; } // Download the data in google_map_data.xml and load it on the map. // The format we expect is: // <markers abs="200" dl="100" ips="27"> // <marker city="Timbuktu" lat="37.441" long="-122.141" abs="10" dl="0" /> // <marker city="West Bromwich" lat="37.322" long="-121.213" abs="22" dl="49" /> // </markers> GDownloadUrl( "google_map_generate_data.pl?top=" + numEntries, function( data, responseCode ) { var xml = GXml.parse( data ); var markerlist = xml.documentElement.getElementsByTagName( "marker" ); for ( var i = 0; i < markerlist.length; i++ ) { var point = new GLatLng( parseFloat( markerlist[i].getAttribute( "lat" ) ), parseFloat( markerlist[i].getAttribute( "long" ) ) ); map.addOverlay( createMarker( point, markerlist[i].getAttribute( "city" ), markerlist[i].getAttribute( "abs" ), markerlist[i].getAttribute( "dl" ) ) ); } // Grab finishing time. We have to do this here rather than in // the main part of the load() function because the map data // are loaded asynchronously. var endTime = new Date(); var numUA = xml.documentElement.getAttribute( "ua" ); var numUD = xml.documentElement.getAttribute( "ud" ); document.getElementById( "timer" ).innerHTML = '<span style="color:red;">' + xml.documentElement.getAttribute( "dl" ) + ' downloads' + ( ( numUD > 0 ) ? ( ' (+' + numUD + ' unmappable)' ) : '' ) + '</span> & <span style="color:blue;">' + xml.documentElement.getAttribute( "abs" ) + ' abstracts' + ( ( numUD > 0 ) ? ( ' (+' + numUA + ' unmappable)' ) : '' ) + '</span> from ' + markerlist.length + ' cities (' + xml.documentElement.getAttribute( "ips" ) + ' IP addresses), page generated in ' + ( endTime - startMillis ) + ' ms.'; } ); } }
function load( startMillis, numEntries ) { if ( GBrowserIsCompatible() ) { // Create new map. var map = new GMap2( document.getElementById( "map" ) ); map.addControl( new GSmallMapControl() ); map.addControl( new GMapTypeControl() ); map.setCenter( new GLatLng(10, 0), 2 ); // Creates a marker at the given point with a label // containing the other remaining arguments. function createMarker( point, city, abstracts, downloads ) { var marker = new GMarker( point ); GEvent.addListener( marker, "click", function() { marker.openInfoWindowHtml( "<strong>" + city + "</strong> (" + abstracts + " abstracts, " + downloads + " downloads)" ); } ); return marker; } // Download the data in google_map_data.xml and load it on the map. // The format we expect is: // <markers abs="200" dl="100" ips="27"> // <marker city="Timbuktu" lat="37.441" long="-122.141" abs="10" dl="0" /> // <marker city="West Bromwich" lat="37.322" long="-121.213" abs="22" dl="49" /> // </markers> GDownloadUrl( "google_map_generate_data.pl?top=" + numEntries, function( data, responseCode ) { var xml = GXml.parse( data ); var markerlist = xml.documentElement.getElementsByTagName( "marker" ); for ( var i = 0; i < markerlist.length; i++ ) { var point = new GLatLng( parseFloat( markerlist[i].getAttribute( "lat" ) ), parseFloat( markerlist[i].getAttribute( "long" ) ) ); map.addOverlay( createMarker( point, markerlist[i].getAttribute( "city" ), markerlist[i].getAttribute( "abs" ), markerlist[i].getAttribute( "dl" ) ) ); } // Grab finishing time. We have to do this here rather than in // the main part of the load() function because the map data // are loaded asynchronously. var endTime = new Date(); var numUA = xml.documentElement.getAttribute( "ua" ); var numUD = xml.documentElement.getAttribute( "ud" ); document.getElementById( "timer" ).innerHTML = '<span style="color:red;">' + xml.documentElement.getAttribute( "dl" ) + ' downloads' + ( ( numUD > 0 ) ? ( ' (' + numUD + ' unmappable)' ) : '' ) + '</span> & <span style="color:blue;">' + xml.documentElement.getAttribute( "abs" ) + ' abstracts' + ( ( numUD > 0 ) ? ( ' (' + numUA + ' unmappable)' ) : '' ) + '</span> from ' + markerlist.length + ' cities (' + xml.documentElement.getAttribute( "ips" ) + ' IP addresses), page generated in ' + ( endTime - startMillis ) + ' ms.'; } ); } }
Show line notes below