Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Loading InfoWindow with XML data
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ymcasatx@gmail.com  
View profile  
 More options Jul 6 2005, 5:21 pm
From: "ymcas...@gmail.com" <ymcas...@gmail.com>
Date: Wed, 06 Jul 2005 14:21:23 -0700
Local: Wed, Jul 6 2005 5:21 pm
Subject: Loading InfoWindow with XML data
Hi there, I've just started with the Google Maps API and I'm already
hitting walls, I'm successfully displaying my markers like I need them,
but when i'm trying to add an Info Window that is parsed from the XML
file it always fails.
I've looked on the forums for posts with the same topic, but haven't
found any that explained what I needed.

My XML File is Formatted as such :
<markers>
  <marker lat="29.431434" lng="-98.491051">
  <uri>http://www.ymcasatx.org/</uri>
  <name>Association Office</name>
  <address>1123 Navarro</address>
  <phone>210-246-9622</phone>
  </marker>
  <marker lat="29.536861" lng="-98.425538" desc="Northeast YMCA">
  <uri>http://www.ymcasatx.org/notheast</uri>
  <name>Northeast YMCA</name>
  <address>1123 Navarro</address>
  <phone>210-246-9622</phone>
  </marker>
</markers>

and my script that calls the XML file is as such:

    <script type="text/javascript">
// Center the map on Palo Alto
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-98.491051, 29.431434), 7);
// Create our "tiny" marker icon
var icon = new GIcon();
icon.image = "http://www.ymcasatx.org/images/map-icon.png";
icon.shadow = "http://www.ymcasatx.org/images/map-icon-shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);

var request = GXmlHttp.create();
request.open("GET", "data.xml", true);
request.onreadystatechange = function() {
  if (request.readyState == 4) {
    var xmlDoc = request.responseXML;
    var markers =
xmlDoc.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
      var point = new
GPoint(parseFloat(markers[i].getAttribute("lng")),

parseFloat(markers[i].getAttribute("lat")));

      var marker = new GMarker(point, icon);
      map.addOverlay(marker);
    }
  }

}

request.send(null);
    //]]>
    </script>

Now I dont know where to begin, I know I need to load the XML data into
a html variable, then call that variable with a listener event.

My question is can anyone point me to an already existing file where
this is done, or tell me how I can incorporate all this into my file...

Your help is GREATLY appreciated.

Thank you.

Chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
trancealot@gmail.com  
View profile  
 More options Jul 6 2005, 5:48 pm
From: "trancea...@gmail.com" <trancea...@gmail.com>
Date: Wed, 06 Jul 2005 21:48:35 -0000
Local: Wed, Jul 6 2005 5:48 pm
Subject: Re: Loading InfoWindow with XML data
you basically just need to call openInfoWindowHtml(htmlStr) on your
markers.  take a look at the code on my site at
http://www.seattlecityphotography.com/personal/diving .

it gets data from an xml file and puts it into the info window.  i'm
using attributes in my xml instead of child nodes, but its the same
thing.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sdaviswnec  
View profile  
 More options Jul 6 2005, 7:45 pm
From: "sdaviswnec" <sdavisw...@gmail.com>
Date: Wed, 06 Jul 2005 23:45:03 -0000
Local: Wed, Jul 6 2005 7:45 pm
Subject: Re: Loading InfoWindow with XML data
format your XML like this...
<markers>
  <marker
       lat="29.431434"
       lng="-98.491051"
       desc=""
       uri="http://www.ymcasatx.org/"
       name="Association Office"
       address="1123 Navarro"
       phone="210-246-9622"
  </marker>

  <marker
       lat="29.536861"
       lng="-98.425538"
       desc="Northeast YMCA"
       uri="http://www.ymcasatx.org/nothea­st"
       name="Northeast YMCA"
       address="1123 Navarro"
       phone="210-246-9622"
  </marker>
</markers>

Hope that helps!
send an email if it does not!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jef Poskanzer  
View profile  
 More options Jul 6 2005, 11:33 pm
From: "Jef Poskanzer" <jef.poskan...@gmail.com>
Date: Wed, 06 Jul 2005 20:33:00 -0700
Subject: Re: Loading InfoWindow with XML data
The old XML attributes vs. elements discussion, yeah.

I never really cared one way or the other.  I started out putting
everything in attributes, as sdaviswnec suggests.  However I was having
some problems with HTML entities such as &eacute; - I could get them
working right on Firefox and MSIE but not in Safari; or the reverse;
but I couldn't get it working in all three browsers with the same code.

Then I switched to using elements for string-like data, while still
using attributes for the numeric lat and lon.  Now it works right in
all the browsers.  This is probably a fixable bug, perhaps in Google's
code, but for now it's a valid argument in favor of elements.

As for how to read element strings into your JavaScript code, you can
copy from my app: http://www.acme.com/jef/paris_forts/  It's probably
not even close to the best way of doing this, it was just the first
thing I tried and it works.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ymcasatx@gmail.com  
View profile  
 More options Jul 7 2005, 10:05 am
From: "ymcas...@gmail.com" <ymcas...@gmail.com>
Date: Thu, 07 Jul 2005 07:05:52 -0700
Local: Thurs, Jul 7 2005 10:05 am
Subject: Re: Loading InfoWindow with XML data
Thanks for your help guys,

I've gotten this far with your advice, but i can't seem to figure out
why when i click on any of the markers it brings me to the last one on
the XML file

can you tell me how i can get the info window to be distinct to each
marker ?

var request = GXmlHttp.create();
request.open("GET", "data.xml", true);
request.onreadystatechange = function() {
  if (request.readyState == 4) {
    var xmlDoc = request.responseXML;
    var markers =
xmlDoc.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
          var html = "Branch Name <b>" + markers[i].getAttribute("desc") +
"</b>";
      var point = new
GPoint(parseFloat(markers[i].getAttribute("lng")),

parseFloat(markers[i].getAttribute("lat")));
      var marker = new GMarker(point, icon);
                GEvent.addListener(marker, "click", function() {
                        marker.openInfoWindowHtml(html);
                });
          map.addOverlay(marker);

    }
  }


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jef Poskanzer  
View profile  
 More options Jul 7 2005, 3:16 pm
From: "Jef Poskanzer" <jef.poskan...@gmail.com>
Date: Thu, 07 Jul 2005 12:16:26 -0700
Local: Thurs, Jul 7 2005 3:16 pm
Subject: Re: Loading InfoWindow with XML data

>when i click on any of the markers it brings me
>to the last one on the XML file

It's because you inlined the function-closure instead of putting it in
a separate  function.  Look at the examples, including my Paris Star
Forts one.  The function-closure must be created inside a separate
function or else it doesn't work properly.  Doesn't make sense but it's
a fact nevertheless.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
exxodus.sio4@gmail.com  
View profile  
 More options Jul 8 2005, 3:01 am
From: "exxodus.s...@gmail.com" <exxodus.s...@gmail.com>
Date: Fri, 08 Jul 2005 00:01:03 -0700
Local: Fri, Jul 8 2005 3:01 am
Subject: Re: Loading InfoWindow with XML data
Hello,

I'm also new in Google Gmail, and i've got a problem with Markers, it's
seems that in "SAT" mode, some of my markers simply doesn't show but If
i switch to the "MAP" mode, they all there .. so ? What wrong whith my
code ?

Page :
http://www.mustangpassion.com/Forum/user_map2.php

Xml:
http://www.mustangpassion.com/Forum/user_map_xml.php

Thanks to : Jef Poskanzer for the code.

Rem: My goal is to map my forum member on a world map, based on a
"huge" free lat/lng Database of all cities of the world.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google