Is the idea that people will be editing these XML files by hand? That's the
impression I got, but I must be misunderstanding you. How will your data be
generated and maintained?

For flexibility and ease of use in your JavaScript code, I would consider
JSON instead of XML.

In JSON format your data would look like this:

{
    "markers": [
        {
            "name": "Arbor House Restaurant",
            "address": "103 West Wagner Street Talent OR 97540",
            "lat": 42.2425,
            "lng": -122.788,
            "comments": "blah blah",
            "type": "restaurant",
            "connections": "blah",
            "image": "hello<img src='./images/mtn_pic_thumb.jpg'>hello"
        },
        {
            ...another marker...
        }
    ]
}

And this code that processes the data:

    GDownloadUrl("marker2.xml", function(data) {
        var xml = GXml.parse(data);
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var label = markers[i].getAttribute("label");
            var address = markers[i].getAttribute("address");
            var comments = markers[i].getAttribute("comments");
            var type = markers[i].getAttribute("type");
            var image = markers[i].getAttribute("image");
            var connections = markers[i].getAttribute("connections");
            var point = new
GLatLng(parseFloat(markers[i].getAttribute("lat")),
            parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, name, address, type, comments,
connections, image);
            map.addOverlay(marker);
        }
    });

would be reduced to:

    GDownloadUrl( 'marker2.json', function( data ) {
        data = eval( '(' + data + ')' ), markers = data.markers;
        for( var m, i = -1;  m = markers[++i]; ) {
            var point = new GLatLng( m.lat, m.lng );
            var marker = createMarker( point, m.name, m.address, m.type,
m.comments, m.connections, m.image);
            map.addOverlay( marker );
        }
    });

As you can see, JSON is much easier to work with in your JavaScript code.
Also, it would be easy to do that connection linking you mentioned. But
before getting into that, we'd better find out how the data will be
maintained - maybe you can tell us a bit more about that? JSON is no easier
than XML for manual editing, but at least it's probably no worse. :-)

-Mike

On Tue, Aug 3, 2010 at 4:58 PM, shadrack <[email protected]> wrote:

> Hi,
>
> I have a site that is displaying Google Maps API markers (http://
> www.julieshad.com/so_or_ag/map.html utilizing
> http://www.julieshad.com/so_or_ag/marker2.xml)
> by accessing data from XML, parsing it and displaying it. Right now
> I'm using attributes, which I'm finding to be somewhat limiting, and I
> will be expanding my number of markers so I need to decide on a data
> structure. First, in order to put HTML within the attribute (i.e. img
> sr to display a picture), I'm having to use some unorthodox coding to
> place "<", etc. This won't work because I want it to be easy to update/
> change the XML content for people who are novices at HTML.
>
> Additionally, a goal of mine is to be able to reference data in the
> XML through other attributes in the XML. For instance, if an attribute
> of one marker has a word that is the name of another marker, I want to
> be able to link to that marker. If you click on the green marker at
> the top, it displays "Amuse" and "Arbor House". These are the
> "connections" attribute of the marker named "Brian's Green Thumb...".
> Since "Amuse" is the exact name of another marker, I'd like to access
> the attributes of "Amuse" through a link or something. Is this making
> sense? And is it possible?
>
> So, in general I'd like to find a better and easier way to organize my
> data for display. Mysql may be nice, but I want to avoid setting up a
> database and maintaining that if possible. Will a more robust
> application of xml be better, like using more elements vs. a lot of
> attributes? Or maybe just a comma-separated value .txt file may be
> better, but hard to believe. I'm not an expert coder so I need
> something that works with Google Maps fairly well. Thanks for any
> time, and I'll gladly help explain further if questions,
>
> Shad
>
> --
> 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]<google-maps-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-api?hl=en.
>
>

-- 
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