Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    79
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Adding Google Maps with custom XML to this complex site

    Hi, I hope someone can help me with this. I am trying to implement a site that has 3 features.

    Enter a search term and:

    1) Google Blog Results show up
    2) Twitter Search Results show up
    3) Google Maps with custom xml data shows up

    I have accomplished the first 2 parts - http://www.justincener.com/xml

    I now want to add in Google Maps. The idea is to type in a athlete's name and have results come back from Google Blog Search (done), Twitter (done), and Google Maps. I only need to show 2-3 choices, so I want to create a custom Google Maps XML doc that corresponds to a few search terms. For example, when someone types in "Tom Brady", I want a Google Map to also come up along with the Google Blog and Twitter Results.

    On the map, I want to plot 4 points showing his 4 next games. I think I know how to create the custom XML for GMaps, but I don't know how to implement it so that when someone enters input, the GMaps will show up. Can anyone get me started in the right direction please?

    Here is the JS so far that handles Google Blog Results and Twitter Results:

    Code:
      
        var errorCount=0;   
        var twitter_link;
    
        function searchGoogle(query)
        {      
          var link = "http://blogsearch.google.com/?hl=en&q="+query+"&as_drrb=q&as_qdr=d&scoring=d&ie=utf-8&num=15";
          var feed = new google.feeds.Feed("http://blogsearch.google.com/blogsearch_feeds?hl=en&q="+query+"&as_drrb=q&as_qdr=d&scoring=d&ie=utf-8&num=15&output=rss"); 
          feed.setNumEntries(15);
          var container = document.getElementById("googlehere");//into googlehere div float left
    
          container.innerHTML = "<img style='padding-top:100px;padding-left:100px' src='loading.gif' alt='loading ...' border='0'/>";
    
          feed.load(function(result) {
              
            if (!result.error) {
              container = document.getElementById("googlehere");
              container.innerHTML = '';
              var tweet='';
              for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var div = document.createElement("div");
     
                var s = "<a href='"+entry.link+"' target='_blank'>"+entry.title+"</a><br/>";//each entry has a link and a title, call those
    
                tweet = entry.content;//each entry has a content, call it
    
                s+=tweet+"<br/><br/>";
    
                div.innerHTML = s;             
                container.appendChild(div);
              }
    
            } 
          });
        }
    
       function searchTwitter(query)
       {
         twitter_link="http://search.twitter.com/search?q="+query;
    
         var s ="http://search.twitter.com/search.json?q="+query+"&rpp=20";
    
         var container = document.getElementById("twitterhere");//twitter div here
         container.innerHTML = "<img style='padding-top:100px;padding-right:100px' src='loading.gif' alt='loading ...' border='0'/>";
    
         getTwitter(s+"&callback=results");//concat
         		
       }
    
        function results(t)
        {
           var v = t.results;
           var container = document.getElementById('twitterhere');
    
           if (v.length==0)
           {
             container.innerHTML="<div class='error'><strong>Have you watched the NFL lately? Try again!</strong></div>";//v.length represents length of result, if 0 then blank = no matching results, show error message   
           }
           else
           {
             var sText = "";  
             for (var i=0; i<v.length; i++)//loop for each entry result
             { 
               sText +=getEntry(v[i]);//see below
             }
    
        
             container.innerHTML=sText;//add to display
           } 
        }
    
       function getEntry(entry)
        {
    
               var sText ="<a style='text-decoration:none' href='http://www.twitter.com/"+entry.from_user+"' target='_blank'><img src='"+entry.profile_image_url+"' style='float:left;padding-right:7px' border='0' width='48' height='48'/></a>"; //link back to Twitter, show Twitter Profile Pic as thumbnail
    
    
               sText += proceedText(entry.text);
    
               sText += "<br/>";
              
               sText+=""+dateDiff(new Date(entry.created_at), new Date());
    
               sText+="<br/><br/><br/>";
    
               return sText;
        }
    
        function proceedText(text)
        {
            var tweet = text;
            var re = new RegExp("(([a-zA-Z]+:\/\/)([a-zA-Z][a-zA-Z0-9_\.-]*[a-zA-Z]{2,6})([a-zA-Z0-9~\#\/\._\?\&%-=]*[a-zA-Z0-9~\#\/_\?\&%-=]))", "g");
            tweet = tweet.replace(re, '<a style="' + 'text-decoration:none;" target="_new" href=$1/index.htm >$1</a>');
            re = new RegExp("@([a-zA-Z0-9_]+)", "g");
    		tweet = tweet.replace(re, '@<a style="' + 'text-decoration:none;" target="_new" href=http://twitter.com/$1>$1</a>');
            tweet = tweet.replace(/&/g, '&');
    
          return tweet;
        }
    
    
       function dateDiff(d1, d2) //I took this from an online tutorial
       {
         var diff  = new Date();
    
         diff.setTime(Math.abs(d1.getTime() - d2.getTime()));
    
         var timediff = diff.getTime();
    
         var weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
         timediff -= weeks * (1000 * 60 * 60 * 24 * 7);
    
         var days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
         timediff -= days * (1000 * 60 * 60 * 24);
    
         var hours = Math.floor(timediff / (1000 * 60 * 60)); 
         timediff -= hours * (1000 * 60 * 60);
    
         var mins = Math.floor(timediff / (1000 * 60)); 
         timediff -= mins * (1000 * 60);
    
         var secs = Math.floor(timediff / 1000); 
         timediff -= secs * 1000;
    
         var ans ="";
         if (weeks!=0) ans+=weeks+" weeks ";
    
         if (days!=0)  ans+=days+" days ";
    
         if (hours!=0) ans+=hours+" hours ";
         else
         {
           if (mins!=0)  ans+=mins+" mins ";   
           else
              ans += secs +" secs "    
         }
    
         return ans+"ago";
       }//end date script
       
    
    
    
       function search()
       {
          var s = document.forms['athlete'].q.value;//takes the user input and grabs the value!!!!!!!!!!
    
          if (s!='')//string is NOT blank
          {
            s= encodeURIComponent(s);
            
            errorCount=0;
            searchGoogle(s);
            searchTwitter(s);
          } 
    
          return false;
       }
    
    
        function getTwitter(query) //basis of the Twitter Results Search mechanism, found online
        {
          var cbscript = document.createElement("script");
          cbscript.src = query;
          cbscript.type = 'text/javascript';
          document.body.appendChild(cbscript);
        }

    Thanks!

  • #2
    New Coder
    Join Date
    May 2008
    Posts
    79
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Anyone please?

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    I dunno about everybody else, but I don't understand why you think you need XML to display data on a google map. I know I do it all with JavaScript calls, no XML involved.

    But I guess the first question is: How do you know *WHERE* the next 4 games for "Tom Brady" are?? You've got to do some sort of query to get that information, first, before you can even begin plotting points. I suppose the most sensible way to approach this might be to pre-compute the locations (latitude/longitude...easy to do with google maps or google geocoder) of all the NFL stadiums. Then all you have to do is get his team's schedule and find the next 4 stadiums. But this assumes that your example was a real example. And also seems a bit silly to put on a map if the next 4 games include (say) both Seattle and Miami locations. You'd have to just show a map of the entire USA.

    But whatever. Tell us how you will determine WHERE the next 4 games are and then whether or not this was a real example: Did you really mean to present only NFL players and NFL stadiums?

  • #4
    New Coder
    Join Date
    May 2008
    Posts
    79
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Yes this is a 100% real example. I created an external XML document for GMaps to get the Long/Lat data. I need to

    1) Get GMaps to plot the points relevant to each player
    2) Have the input the user gives decide which set of XML data to plot

    Here is my XML:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    
    
    <athlete id="Mark Brunell">
    	<stadium lat="42.209194" lng="-83.048401" />
    	<stadium lat="39.901696" lng="-75.167624" />
    	<stadium lat="40.816030" lng="-74.080225" />
    	<stadium lat="25.956419" lng="-80.238349" />
    	<stadium lat="33.754487" lng="-84.389663" />
    </athlete>
    
    <athlete id="Tom Brady">
    	<stadium lat="42.774342" lng="-78.786579" />
    	<stadium lat="40.816030" lng="-74.080225" />
    	<stadium lat="42.092578" lng="-71.267475" />
    	<stadium lat="39.276968" lng="-76.622723" />
    	<stadium lat="39.745978" lng="-105.021664" />
    </athlete>
    
    <athlete id="Torry Holt">
    	<stadium lat="39.759978" lng="-86.163731" />
    	<stadium lat="30.324392" lng="-81.638441" />
    	<stadium lat="29.685247" lng="-95.410318" />
    	<stadium lat="36.158887" lng="-86.782056" />
    	<stadium lat="47.595177" lng="-122.331935" />
    </athlete>

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Oh! Okay!

    Now I get it.

    Might I suggest an addition to that XML? The name of the city and/or stadium??

    Example:
    Code:
    <athlete id="Tom Brady">
    	<stadium name="Wembly, UK" lat="42.774342" lng="-78.786579" />
    ...
    (Just joking about the stadium name <grin/>.)

    Is there a reason you chose to use XML for this, instead of just (for example) a JSON or similar JavaScript structure?? You *might* be better off doing the XML parsing in your PHP code, instead of battling all the various browsers to get them to handle the XML correctly.

    For that matter, do you really care where the selection of the appropriate stadiums is done, in JS or PHP code? (Assuming you are using PHP, of course. Could equally be JSP or ASP or whatever.)

  • #6
    New Coder
    Join Date
    May 2008
    Posts
    79
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Thanks for replying again. I don't care how to accomplish this as long as it deals with JS or PHP (or JSON).

    My problems right now are:

    1) Can't get the points to plot

    Once they plot, then I need them to come up according to the search (i.e. only Tom Brady's points come up when "Tom Brady" is searched.

    Thanks!

  • #7
    New Coder
    Join Date
    May 2008
    Posts
    79
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Update: Got it a little further. I can now map each point from an XML doc.

    http://eden.rutgers.edu/~jcener/xml/final/

    New XML Doc:
    Code:
    <markers id="Mark Brunell">
    	<marker lat="42.209194" lng="-83.048401" html="marker 1" label="Mark Brunell 1"/>
    	<marker lat="39.901696" lng="-75.167624" html="marker 2" label="Label 1"/>
    	<marker lat="40.816030" lng="-74.080225" html="marker 3" label="Label 1"/>
    	<marker lat="25.956419" lng="-80.238349" html="marker 4" label="Label 1"/>
    	<marker lat="33.754487" lng="-84.389663" html="marker 5" label="Label 1"/>
    	
    	<marker lat="42.774342" lng="-78.786579" html="marker 2" label="Tom Brady 1" />
    	<marker lat="40.816030" lng="-74.080225" />
    	<marker lat="42.092578" lng="-71.267475" />
    	<marker lat="39.276968" lng="-76.622723" />
    	<marker lat="39.745978" lng="-105.021664" />
    	
    	<marker lat="39.759978" lng="-86.163731" html="marker 2" label="Torry Holt 1" />
    	<marker lat="30.324392" lng="-81.638441" />
    	<marker lat="29.685247" lng="-95.410318" />
    	<marker lat="36.158887" lng="-86.782056" />
    	<marker lat="47.595177" lng="-122.331935" />
    </markers>
    New JS Code:

    Code:
    	function searchMap(query)
    	{
    		 //<![CDATA[
    
        if (GBrowserIsCompatible()) {
          // this variable will collect the html which will eventually be placed in the side_bar
          var side_bar_html = "<h1 style='color: black\; text-decoration: none\;'>Hi there</h1>";
        
          // arrays to hold copies of the markers used by the side_bar
          // because the function closure trick doesnt work there
          var gmarkers = [];
    
          // A function to create the marker and set up the event window
          function createMarker(point,name,html) {
            var marker = new GMarker(point);
            GEvent.addListener(marker, "click", function() {
              marker.openInfoWindowHtml(html);
            });
            // save the info we need to use later for the side_bar
            gmarkers.push(marker);
            // add a line to the side_bar html
            side_bar_html += '<a href="javascript:myclick(' + (gmarkers.length-1) + ')">' + name + '<\/a><br>';
            return marker;
          }
    
    
          // This function picks up the click and opens the corresponding info window
          function myclick(i) {
            GEvent.trigger(gmarkers[i], "click");
          }
    
    
          // create the map
          var map = new GMap2(document.getElementById("map"));
          map.addControl(new GLargeMapControl());
          map.addControl(new GMapTypeControl());
          map.setCenter(new GLatLng( 40.48873742102281,-100.43450165214017), 4);
    
    
          // Read the data from example.xml
          GDownloadUrl("stadium.xml", function(doc) {
            var xmlDoc = GXml.parse(doc);
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
              
            for (var i = 0; i < markers.length; i++) {
              // obtain the attribues of each marker
              var lat = parseFloat(markers[i].getAttribute("lat"));
              var lng = parseFloat(markers[i].getAttribute("lng"));
              var point = new GLatLng(lat,lng);
              var html = markers[i].getAttribute("html");
              var label = markers[i].getAttribute("label");
              // create the marker
              var marker = createMarker(point,label,html);
              map.addOverlay(marker);
            }
            // put the assembled side_bar_html contents into the side_bar div
            
          });
        }

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Pretty good!

    So the only thing you need, now, is that ability to find ONLY the relevant <marker> tags.

    To do that, you need to FIRST find the correct <markers> tag (e.g., the one with <markers id="xxxx"> where "xxxx" is the person you are matching to).

    You do that by using an XPATH query, and I forget the form for an XPATH that is based on an attribute. Hold on a sec...Oh yeah, "@". Okay, so *PROBABLY* something like this:
    Code:
    // Read the data from example.xml
          GDownloadUrl("stadium.xml", function(doc) {
            var xmlDoc = GXml.parse(doc);
            var person = xmlDoc.documentElement.SelectSingleNode('//markers[@id="Jim Kelly"]');
            var markers = person.getElementsByTagName("marker");
            // rest of code same...  
            for (var i = 0; i < markers.length; i++) {
                ... etc. ...
    That may or may not be quite right and may or may not work in all browsers.

    Worst come to worst, you could do this:
    Code:
    // Read the data from example.xml
          GDownloadUrl("stadium.xml", function(doc) {
            var xmlDoc = GXml.parse(doc);
            var person = null;
            var temp = xmlDoc.documentElement.getElementsByTagName("markers");
            for ( var t = 0; t < temp.length; ++t )
            {
                 var p = temp[t];
                 if ( p.getAttribute("id") == "Jim Kelly" )
                 {
                      person = p;
                      break;
                 }
             }
             if ( person == null ) return; // ?? not found ??
             var markers = person.getElementsByTagName("marker");
             // rest of code same...  
             for (var i = 0; i < markers.length; i++) {
                ... etc. ...
    Naturally, in your actual code you will pass in a variable with the name to look for, instead of using the literal "Jim Kelly".

    Does that make sense?

    NOTE: If you want to allow partial name match (e.g., "Kelly" to match an id of "Jim Kelly"), then the second set of code there is of course better. Instead of looking for an == match on the id you could use indexOf or match or any other string matching you wanted.

  • #9
    New Coder
    Join Date
    May 2008
    Posts
    79
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Old Pendant - Thanks for all of your help. I understand the idea of the XPATH code, but I'm unsure of how and where to implement it. Does that get plugged into my JS file inside the SearchMaps function that calls the map in the first place?

    Also, when you say pass in a variable instead of using the literal, does that mean passing over the user's input from the input box (something like document.forms['athlete'].q.value)?

    UPDATE: The XML Doc isn't formatted with different markers, so when I changed it to have 3 sets of markers, each with a different ID (assigned to a name), it only displays the 1st set of markers. Here is the new XML

    Code:
    <markers id="Mark Brunell">
    	<marker lat="42.209194" lng="-83.048401" html="marker 1" label="Mark Brunell 1"/>
    	<marker lat="39.901696" lng="-75.167624" html="marker 2" label="Label 1"/>
    	<marker lat="40.816030" lng="-74.080225" html="marker 3" label="Label 1"/>
    	<marker lat="25.956419" lng="-80.238349" html="marker 4" label="Label 1"/>
    	<marker lat="33.754487" lng="-84.389663" html="marker 5" label="Label 1"/>
    </markers>
    
    <markers id="Tom Brady">
    	<marker lat="42.774342" lng="-78.786579" html="marker 2" label="Tom Brady 1" />
    	<marker lat="40.816030" lng="-74.080225" />
    	<marker lat="42.092578" lng="-71.267475" />
    	<marker lat="39.276968" lng="-76.622723" />
    	<marker lat="39.745978" lng="-105.021664" />
    </markers>
    
    <markers id="Torry Holt">	
    	<marker lat="39.759978" lng="-86.163731" html="marker 2" label="Torry Holt 1" />
    	<marker lat="30.324392" lng="-81.638441" />
    	<marker lat="29.685247" lng="-95.410318" />
    	<marker lat="36.158887" lng="-86.782056" />
    	<marker lat="47.595177" lng="-122.331935" />
    </markers>
    Thanks in advance!
    Last edited by aejacks8; 07-24-2009 at 06:52 PM.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    The *only* place the XPATH is used is that ONE LINE that I showed there:
    Code:
    var person = xmlDoc.documentElement.SelectSingleNode('//markers[@id="Jim Kelly"]');
    So, no, none of the code outside of that function is changed.

    As I said, this XPATH query may not work correctly in all browsers, so the second set of code is designed to *not* use XPATH. I can't see why it wouldn't work in all browser where the GXml.parse( ) call works.

    I assume that GXml and GDownloadUrl come from some library. Which one? Is that the google "jsapi"??

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Tell you what...try this. ONLY the code in red is new/changed from your existing "main.js" code:
    Code:
          ... up to here the same ...
    
          // Read the data from example.xml
          GDownloadUrl("stadium.xml", function(doc) {
            var xmlDoc = GXml.parse(doc);
            var person = null;
            var temp = xmlDoc.documentElement.getElementsByTagName("markers");
            for ( var t = 0; t < temp.length; ++t )
            {
                 var p = temp[t];
                 // an == test may be too strong...up to you
                 if ( p.getAttribute("id") == query )
                 {
                      person = p;
                      break;
                 }
             }
             if ( person == null ) return; // ?? not found ??
             var markers = person.getElementsByTagName("marker");
             // rest of code same...  
             for (var i = 0; i < markers.length; i++) {
    
                ... etc. ...

  • #12
    New Coder
    Join Date
    May 2008
    Posts
    79
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    The *only* place the XPATH is used is that ONE LINE that I showed there:
    Code:
    var person = xmlDoc.documentElement.SelectSingleNode('//markers[@id="Jim Kelly"]');
    So, no, none of the code outside of that function is changed.

    As I said, this XPATH query may not work correctly in all browsers, so the second set of code is designed to *not* use XPATH. I can't see why it wouldn't work in all browser where the GXml.parse( ) call works.

    I assume that GXml and GDownloadUrl come from some library. Which one? Is that the google "jsapi"??
    Thanks again! Yes, its Google JS Api.

    I understand your new coding I think - it looks for each set of coordinates which are classified as the tag markers in the XML. Then, it grabs the attribute out of each "markers" set and checks to see if its equal to query (is this the form input?).

    My original code looks at each "markers" and grabs the attribute lat and lang, but those attributes are inside "marker" not "markers" - does this matter? I made the changes you recommended, but nothing gets plotted.

    http://eden.rutgers.edu/~jcener/xml/final

    Did I do something wrong?

  • #13
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Your XML is invalid, so the parser is just dying.

    You *MUST* have some element that "encloses" all the other elements. It's not terribly important what it is. I just used <content>...</content> and it then parsed okay:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <content>
    
    <markers id="Mark Brunell">
    	<marker lat="42.209194" lng="-83.048401" html="marker 1" label="Mark Brunell 1"/>
    	<marker lat="39.901696" lng="-75.167624" html="marker 2" label="Label 1"/>
    	<marker lat="40.816030" lng="-74.080225" html="marker 3" label="Label 1"/>
    	<marker lat="25.956419" lng="-80.238349" html="marker 4" label="Label 1"/>
    	<marker lat="33.754487" lng="-84.389663" html="marker 5" label="Label 1"/>
    </markers>
    	
    <markers id="name">	
    	<marker lat="42.774342" lng="-78.786579" html="marker 2" label="Tom Brady 1" />
    
    	<marker lat="40.816030" lng="-74.080225" />
    	<marker lat="42.092578" lng="-71.267475" />
    	<marker lat="39.276968" lng="-76.622723" />
    	<marker lat="39.745978" lng="-105.021664" />
    </markers>
    	
    <markers id="tame">	
    	<marker lat="39.759978" lng="-86.163731" html="marker 2" label="Torry Holt 1" />
    	<marker lat="30.324392" lng="-81.638441" />
    	<marker lat="29.685247" lng="-95.410318" />
    	<marker lat="36.158887" lng="-86.782056" />
    
    	<marker lat="47.595177" lng="-122.331935" />
    </markers>
    </content>
    You should always check your XML by using FireFox to view it. FF will tell you if you have an error.

    Your XML, for example, gave this error in FireFox:
    XML Parsing Error: junk after document element
    Location: http://eden.rutgers.edu/~jcener/xml/final/stadium.xml
    Line Number 12, Column 1:
    <markers id="name">
    ^
    Basically, it was treating the first <markers> tag as the main document element and so the second such tag indeed qualifies as "junk". By adding the <content>...</content> tags, *they* become the main document element.

    And notice the URL there: You really can display an XML file directly in FF, just by using its actual URL location.

    Okay?
    Last edited by Old Pedant; 07-27-2009 at 08:03 PM.

  • Users who have thanked Old Pedant for this post:

    aejacks8 (07-27-2009)

  • #14
    New Coder
    Join Date
    May 2008
    Posts
    79
    Thanks
    12
    Thanked 0 Times in 0 Posts
    You were right, it wasn't formatted correctly. Unfortunately, its still not plotting points on the map.

    I changed the == query to == "Mark Brunell" and it still didn't plot the points.

    I'm still lost, but want to again thank you for your help.
    Last edited by aejacks8; 07-27-2009 at 10:59 PM.

  • #15
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts

    Well, my test says it's not the parsing...

    Here's a simple minded little test, based on your code, that shows that *MY* code *DOES* get the right data.

    So after that, it's your task to put it onto the map properly:
    Code:
    <html>
    <head>
    <script type="text/javascript" 
    
    src="http://www.google.com/jsapi?key=ABQIAAAA1t9VUh6g7aBz6lv5WHwyORRtessGmtGtex2qhjpbTjTwtha6gRQG4Hub-sZwMsNV69Ki5NC9mU-XVQ"></script
    
    >
    <script 
    
    src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAA1t9VUh6g7aBz6lv5WHwyORRtessGmtGtex2qhjpbTjTwtha6gR
    
    QG4Hub-sZwMsNV69Ki5NC9mU-XVQ" type="text/javascript"></script>
    
    <script>
    nameToFind = null;
    function test(query)
    {
       nameToFind = query;
       // Read the data from example.xml and call the XML handling code:
       GDownloadUrl(
              "http://eden.rutgers.edu/~jcener/xml/final/stadium.xml", 
              handleHTML 
          );
    }
    
    function handleHTML(doc)
    {
        var xmlDoc = GXml.parse(doc);
        var person = null;
        var temp = xmlDoc.documentElement.getElementsByTagName("markers");
        for ( var t = 0; t < temp.length; ++t )
        {
            var p = temp[t];
            // an == test may be too strong...up to you
            if ( p.getAttribute("id") == nameToFind )
            {
                 person = p;
                 break;
            }
        }
        if ( person == null ) 
        {
            alert("Unable to find data for " + nameToFind);
            return;
        }
        var markers = person.getElementsByTagName("marker");
        for ( var i = 0; i < markers.length; ++i )
        {
             var curm = markers[i];
             // obtain the attribues of each marker
    	 var lat = parseFloat(curm.getAttribute("lat"));
             var lng = parseFloat(curm.getAttribute("lng"));
             var html = curm.getAttribute("html");
             var label = curm.getAttribute("label");
             alert( "Lat/Long: " + lat + "/" + lng +
                    "\nHTML: " + html+
                    "\nlabel: " + label );
        }
    }
    </script>
    </head>
    <body>
    Testing...
    <form>
    <select onchange="test(this.options[this.selectedIndex].text);">
       <option>--choose one--</option>
       <option>Mark Brunell</option>
       <option>Torry Holt</option>
       <option>Tom Brady</option>
       <option>Joe Nobody</option>
    </select>
    </form>
    </body>
    </html>
    </body>
    </html>


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •