toggle multiple map layers with markers from database

611 views
Skip to first unread message

thindery

unread,
Jul 31, 2011, 9:17:01 PM7/31/11
to google-map...@googlegroups.com
I wasn't able to find a tutorial for what I was wanting to do so I thought maybe someone here could point me in a direction and I could figure it out with some input.  I have an internal database of businesses with lat and long coords.  What I am trying to do is give the user an option to check a box and show all the corresponding business.  For example, user checks "bank' and all the banks pop up, user checks "clothing stores" and all the clothing stores locations in my db will show up in addition with the banks still staying on there.  if the user unchecks a box, those options go away.

Since this is a nationwide prject with thousands of options I didn't know if KML was a good option or not.  It sounded like KML is a specific file for a specific location, and since every user is different and dynamic, I figured it would need to be accomplished by a query as shown in this google example:


My other concern is it possible to run these different business check options in the background so that when the user clicks them it already has ran the query and won't have to run the query onclick, but just reveal some hidden layer?  It may not be necessary to do this.  I'm just trying to reduce map load times.


geoco...@gmail.com

unread,
Aug 1, 2011, 12:22:30 AM8/1/11
to Google Maps JavaScript API v3
On Jul 31, 6:17 pm, thindery <thind...@gmail.com> wrote:
> I wasn't able to find a tutorial for what I was wanting to do so I thought
> maybe someone here could point me in a direction and I could figure it out
> with some input.  I have an internal database of businesses with lat and
> long coords.  What I am trying to do is give the user an option to check a
> box and show all the corresponding business.  For example, user checks
> "bank' and all the banks pop up, user checks "clothing stores" and all the
> clothing stores locations in my db will show up in addition with the banks
> still staying on there.  if the user unchecks a box, those options go away.

Sounds like "categories" per this page of Mike Williams' (v2)
tutorial:
http://econym.org.uk/gmap/categories.htm

his example translated to v3:
http://www.geocodezip.com/v3_MW_example_categories.html

>
> Since this is a nationwide prject with thousands of options I didn't know if
> KML was a good option or not.  It sounded like KML is a specific file for a
> specific location, and since every user is different and dynamic, I figured
> it would need to be accomplished by a query as shown in this google example:http://code.google.com/apis/maps/articles/phpsqlsearch_v3.html

The advantage of KmlLayer, is that google's server generates tiles
from the kml, which improves the performance with lots of markers.

Another option you could investigate is using FusionTables as your
database and using a FusionTablesLayer.

-- Larry

thindery

unread,
Aug 1, 2011, 9:28:28 AM8/1/11
to google-map...@googlegroups.com
Larry,

Thanks for the update.  How many markers does it take for KML to see performance improvements?  I don't anticipate showing anymore than probably 20 markers if all boxes were ticked.

geoco...@gmail.com

unread,
Aug 1, 2011, 11:50:20 AM8/1/11
to Google Maps JavaScript API v3
On Aug 1, 6:28 am, thindery <thind...@gmail.com> wrote:
> Larry,
>
> Thanks for the update.  How many markers does it take for KML to see
> performance improvements?  

Hundreds.

> I don't anticipate showing anymore than probably
> 20 markers if all boxes were ticked.

That should be fine using the "categories" examples (try them I think
they have that number)

-- Larry
Reply all
Reply to author
Forward
0 new messages