To work with the map, any solution like this is going to require two
parts; one server-side and one client-side. Here's a walk through the
process:
STEP 1: The client-side (Javascript) portion clears the map of any
existing markers, harvests the viewport and zoom information from the
map, constructs a url for the server-side portion, including the
viewport and zoom information as parameters, dynamically creates a new
script element with the url as its src, and appends the script el to
the document head.
STEP 2: The server side component uses the viewport and zoom
parameters to retrieve relevant points from the database which have
been grouped by the lat and lng coordinates into boxes of a given
size. For instance, in one application that I have, I use the
following group by clause:
GROUP BY lat/.02*(grpThreshold-currentZoom),lng/.02*(grpThreshold-
currentZoom)
grpThreshold is the threshold beyond which I don't want the markers to
be grouped at all, and currentZoom represents the zoom level of the
map.
STEP 3: Once the points are retrieved, your server-side bit generates
a line of Javascript that will (a) call a globally-accessible client-
side callback function that can relay information back to the map and
(b) pass that callback function an array of javascript objects that
will define the lat, lng, and other information for the markers.
STEP 4: The client-side portion hears this information, uses it to
generate a series of Markers, and adds those Markers to the map.
Please note that, if you have other markers on the map, you're going
to want to stash these markers in an array somewhere so that you can
remove them when the viewport changes again.
Jeremy R. Geerdes
Effective website design & development
Des Moines, IA
For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgee...@mchsi.com
If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!