Monday, November 10, 2008

Map Kitchen [part 3]

Marker categories is the basic trick of filtering markers. Groups of markers can be switched on and off and the groups have different icons. The classic switching by sidebar checkboxes was chosen.

Shall we load each category from a file of its own or shall we have a single file with category data. We shall provide both ways. The concepts can even be mixed.

First we create a SideBar() object, then we create the needed BarCategory() objects. A category will be created if it is specified in file loading options. Also one is created if a new category name is found from files category cell.

The category checkbox switches display of category entries and its markers. Also visibility of marker image on sidebar is switched making sidebar cleaner.

See the page, play with it and see its source.

11 comments:

Gabe said...

This is awesome, exactly the type of thing I was looking to do.

I was wondering about using this with the Earth API. When viewing the points in Earth view, there doesn't seem to be a way to turn off any of the points. I'm still working on my code skills. Is there an easy way to toggle the points in earth?

kmusser said...

Hi, I was looking at using your example and it works great in Firefox but not in IE - any ideas on what the problem would be?

aergenium said...

Hi,
this is great, thank you very much.
Two issues, though:
1) - I noticed that the script messes things up if you load a file with more than one category and the lines are not sorted (e.g. cat1, cat1, cat2,cat3,cat2,cat3,cat1, etc.).

2) - I am having problems with the special characters (ñ, á, é, etc.)
For some reason they don't show well. I tried with utf-8 encoding, then with iso-8859-1, but didn't work. It works in your site, though, I see there are some umlauts (ï, ë, etc). Any ideas about why this is happening?

Thanks a lot,

M.Heredia

link to my page

Placer said...

Hello and thanks for this great example!

I am using a csv file with separate categories for lat, lng, name, street address, city, state and zip code.

Because each field (city, state, zip, etc.) is separated by a comma on the csv file, each field prints on a separate line on the info window.

I am trying to figure out a way to show more than one field on the same row on the info window. I would like to keep street address, city, state and zip code as separate fields (as they are now now) but be able to show them on the same row on the info window. Any suggestions as to how I can do this? Thanks.

Placer said...

Hello and thanks for this great example!

I am using a csv file with separate categories for lat, lng, name, street address, city, state and zip code.

Because each field (city, state, zip, etc.) is separated by a comma on the csv file, each field prints on a separate line on the info window.

I am trying to figure out a way to show more than one field on the same row on the info window. I would like to keep street address, city, state and zip code as separate fields (as they are now now) but be able to show them on the same row on the info window. Any suggestions as to how I can do this? Thanks.

brmartinez said...

Great example. have you had the oppurtunity to use an xml file instead of CSV?

G said...

for those not getting info windows in ie6...the reason is the transparent gif used is 1 pixel by 1 pixel...so you have to be very lucky to click it.

change it for a 12 x 20 transparent gif and all works fine..

fantastic map btw..

Sarah said...

this is driving me crazy! I can't get it work with my own file. i can use the sample but when I make any changes to the lat/long all of my markers go to 1,0 and my map is in Antarctica. What gives? Most of my lat/long are around 45, -112. Is it because it's negative?

Esa said...

@G Transparent fixed. Thanks.

@Sarah. Are your coordinates in opposite order. The example uses lng,lat.

You can swap the order by option {lat:0, lng:1} or in your file ;)

See the current version. There was a bug in that option previously.

Sarah said...

Thanks! That fixed it!

One other hopefully quick question..
I am trying to do the example like this: http://gmaps-samples.googlecode.com/svn/trunk/staticmaps/multiplemarkers.html for my infowindow. How in the world do I incorporate this into the code? I have tried to put in iw-cell-i for rows in the html but to now avail... Any thoughts please? Would be so helpful.

Esa said...

Thanks for the idea. I added a simple driving directions link to createInfoWindow() function.