Can you modify the script that generates the xml?

Instead of outputting a single tag named 'description' which contains
all the information can it instead produce tags named 'name',
'address1', 'address2', 'website', 'number'?

Then you can use those tags rather than attempting to parse the single
description tag into separate tags within your javascript:

function createMarker(point, name, address1, address2, website,
number) {
 var marker = new GMarker(point);
 var myHtml='<div><h3>'+names+'</h3><br /><h4>BUILD THE REST OF YOUR
STYLED HTML USING THE OTHER FUNCTION ARGUMENTS HERE</h4></div>';
 GEvent.addListener(marker, "click", function() {
  marker.openInfoWindowHtml(myHtml);
 });
 return marker;
}

var request = GXmlHttp.create();
request.open("GET", "g_maps_xml.ashx", true);
request.onreadystatechange = function() {
 if (request.readyState == 4) {
  var xmlDoc = request.responseXML;

  // var descriptions = xmlDoc.documentElement.getElementsByTagName
("description");

  var names = xmlDoc.documentElement.getElementsByTagName("name");
  var address1s = xmlDoc.documentElement.getElementsByTagName
("address1");
  var address2s = xmlDoc.documentElement.getElementsByTagName
("address2");
  var websites = xmlDoc.documentElement.getElementsByTagName
("website");
  var numbers = xmlDoc.documentElement.getElementsByTagName("number");


  var parks = xmlDoc.documentElement.getElementsByTagName("park");
  var points = xmlDoc.documentElement.getElementsByTagName("point");

  for (var i = 0; i < parks.length; i++) {
   var point = new GLatLng(parseFloat(points[i].getAttribute("lat")),
parseFloat(points[i].getAttribute("lng")));
   var marker = createMarker(point, names[i], address1s[i], address2s
[i], websites[i], numbers[i]);
   map.addOverlay(marker);
  }
 }
}

Martin.


On 8 July, 22:04, simonDev88 <[email protected]> wrote:
> Hey,
>
> I am at the stage of a nervous breakdown with google maps at the
> moment.
> I have spent a solid 4 months trying to do ONE thing and i cant do it.
> Its way waaay to complex for me.
>
> I have my google maps all setup and the xml is pulling out the
> information intended.
> I now need that information to be displayed in a similiar way that
> google maps displays its marker info window information.
>
> PLEASE dont point me towards the econym tutorials because i've read
> them solidly.
> I just need a simple solution.
> I hardly understand javascript as it is. And i dont have time to
> learn. So most of my work has been trial and error and/or copy and
> paste with some modifications.
>
> How do i format the information that is displayed?
>
> I currently have this:
>
>  //  SET UP MARKER POSITIONS
>                 function createMarker(point, description) {
>                     var marker = new GMarker(point);
>                     GEvent.addListener(marker, "click", function() {
>                         marker.openInfoWindowHtml(description);
>                     });
>                     return marker;
>                 }
>
>                 var request = GXmlHttp.create();
>                 request.open("GET", "g_maps_xml.ashx", true);
>                 request.onreadystatechange = function() {
>                     if (request.readyState == 4) {
>                         var xmlDoc = request.responseXML;
>                         var descriptions =
> xmlDoc.documentElement.getElementsByTagName("description");
>                         var parks =
> xmlDoc.documentElement.getElementsByTagName("park");
>                         var points =
> xmlDoc.documentElement.getElementsByTagName("point");
>
>                         for (var i = 0; i < parks.length; i++) {
>                             var point = new GLatLng(parseFloat(points
> [i].getAttribute("lat")), parseFloat(points[i].getAttribute("lng")));
>                             var marker = createMarker(point,
> descriptions[i]);
>                             map.addOverlay(marker);
>                         }
>                     }
>                 }
>
> ---------------------------------------------
> Inside description is <name><address1><address2><website><number>
> nodes.
> So a marker will have each instance of description outputted. and it
> needs to be formatted properly to look nice.
>
> I apologise for the bluntness and frustration of this post but I am in
> a serious situation now and i cannot cope.
>
> Thankyou for reading over.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to