Why use XML when drawing markers from a database?

100 views
Skip to first unread message

AlB

unread,
Oct 24, 2011, 10:07:45 AM10/24/11
to google-map...@googlegroups.com
I am trying to do the task described in the subject (plot markers on a map based upon an SQL database query)

Why in all the examples does Google recommend using an XML intermediary? The example (http://code.google.com/apis/maps/articles/phpsqlsearch_v3.html) says that if Javascript/PHP is used directly it can cause problems.

Is the XML method more suited to data which is unlikely to change regularly? Like a store locator. For my site the markers are likely to change everyday.

Maybe I have missed something but...

Googles method: SQL query > XML > Markers (each step requires a loop)

Simple method: SQL query > Markers (one less loop and no XML)

I have probably completely misunderstood the reason behind using XML - can someone explain why its use is recommended?

Thanks
Alb

Carlos Montelongo

unread,
Oct 24, 2011, 2:31:45 PM10/24/11
to google-map...@googlegroups.com, google-map...@googlegroups.com
My experience on this topic is:
When you use a SQL Query to draw markers in a JSP or HTML or maybe PHP, you are using Client's resources to draw the map.
When you use KML or XML to draw markers, GoogleMaps do the work.

Maybe some technical stuff is ommited, but that's how it works.

Regards,
Carlos Montelongo

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/ul-X3cxpPkUJ.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Rossko

unread,
Oct 24, 2011, 2:56:23 PM10/24/11
to Google Maps JavaScript API v3
> Googles method: SQL query > XML > Markers (each step requires a loop)
>
> Simple method: SQL query > Markers (one less loop and no XML)

If the user then goes on to search around another location, the AJAX
method can be used to fetch and display new data without reloading the
page.
The webpage itself can be cached, even though the data may change or
different sets of data may be fetched.

While the 'simple' method is simple i.e. its not an interactive page.
Sometimes that's fine, depends on your use.
Problems are likely to arise as complexity increases e.g. it would be
difficult to use this approach to allow a user to enter an address,
that is geocoded, then used for dbase searching, then results to be
plotted.

Bear in mind the examples are just that, examples. They are not
finished applications, you are not required to "do it this way".

xelawho

unread,
Oct 24, 2011, 10:45:45 PM10/24/11
to Google Maps JavaScript API v3
some more explanation behind google's thinking here:
http://code.google.com/apis/maps/articles/phpsqlajax_v3.html#outputxml

AlB

unread,
Oct 25, 2011, 2:39:49 AM10/25/11
to google-map...@googlegroups.com
Ok thanks for the replies guys. 

I see the point that if you want to refresh without reloading the page (e.g. search another location) this would lead to doing another page/ server request. In this case AJAX would be useful. But this is also the case with the XML method if the XML file is generated from a SQL query which changes with the users search location?

Thanks for the help anyway as has been said they are examples and I think for my specific project the AJAX method is more suited.

AlB


Reply all
Reply to author
Forward
0 new messages