| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Google Mapplet

This version was saved 15 years, 6 months ago View current version     Page history
Saved by Chris Kennedy
on October 19, 2008 at 11:39:19 pm
 
    var map = new GMap2(); //var point = new GLatLng(37.71859, 6.679688); //map.setCenter(point, 2); var url = "http://search.twitter.com/search.atom?q=%23votereport"; var geocoder = new GClientGeocoder(); function addMessage(message) { li = document.createElement("li"); li.innerHTML = message; _gel("message_list").appendChild(li); } _IG_FetchXmlContent(url, function(response) { var feed = response.getElementsByTagName("feed").item(0); var entries = response.getElementsByTagName("entry"); addMessage("Found "+ entries.length + " responses."); var title = document.createElement("h4"); _gel("title").innerHTML = response.getElementsByTagName("title").item(0).textContent; var data = []; var geocodeEntries = 0; for (var i = 0; i < entries.length; i++) { var entry = entries.item(i); var items = entry.childNodes; var title = "", id = ""; var author = {}; for (var itemNum = 0; itemNum < items.length; itemNum++) { var element = items.item(itemNum); if (element.nodeName == "title") { title = element.textContent; } if (element.nodeName == "id") { id = element.textContent; } if (element.nodeName == "author") { author = element; } } var raw_message = title; if (!raw_message) { continue; } var message = raw_message.replace(/#votereport/i, ""); if (message == "") { // Blank message. continue; } // Find all the hash tags in the message. var raw_tags = message.split("#"); var tags = []; if (raw_tags.length > 1) { for (var t = 0; t < raw_tags.length; t++) { var value = raw_tags[t]; if (value != "" && value != " ") { tags.push(value.replace(/ .*$/, '')); } } } // If there are no hash tags, skip this entry. if (tags.length == 0) { continue; } // Save the message without the hash tags in it. var remainder = message.replace(/#[w:]* ?/g, ""); // Anything after the first semicolon is a comment. var comment = message.replace(/^[^;]*;(.*)/, "$1"); // Find the location, either enclosed in brackets or as a zipcode. var location = remainder.match(/[(.+)]/); if (location) { location = location[1]; } else { // See if there is a 5 digit zip code, optionally a zip+4 code. location = remainder.match(/d{5}(-d{4})?/); if (location.length > 0) { // Only use the first match. location = location[0]; } } // addMessage(message); // addMessage("Tags: "+ tags.join(", ") + ". Zip: "+ zipcode + "."); // Quit if there's no location for now. if (location == "") { continue; } geocodeEntries++; entry = {"location": location, "tags" : tags, "comment" : comment, "message" : message, "author": author}; handleEntry(entry); } addMessage("Found " + geocodeEntries + " entries to geocode."); }); function handleEntry(entry) { // Geocode the zip code. geocoder.getLatLngAsync(entry.location + ", USA", function(latlng) { if (!latlng) { // Geocoding failed. addMessage("Geocoding failed."); } else { addMessage("Geocoding succeeded."); var options = { title: entry.author.firstChild.textContent }; var marker = new GMarker(latlng, options); map.addOverlay(marker); var html = document.createElement("div"); GEvent.addListener(marker, "click", function() { info = "Tags: "+ entry.tags.join(", ") + "
    " + "Location: "+ entry.location + "
    " + (entry.comment? "Comment: "+ entry.comment + "
    " : ""); marker.openInfoWindowHtml(info); }); } }); } /* // Add a marker to the center of the map //var marker = new GMarker(point); //map.addOverlay(marker); // Open a "Hello World" info window //var message = "Hello World!"; //marker.openInfoWindowHtml(message); // Creates a marker at the given point with the given name function createMarker(point, name) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(name); }); return marker; } */ ]]>

    Comments (0)

    You don't have permission to comment on this page.