Multiple Marker with Categories and Types

463 views
Skip to first unread message

Kishanth Mehra

unread,
Dec 10, 2011, 3:39:46 PM12/10/11
to google-map...@googlegroups.com
I'd like to create a map with multiple categories. Like this example. LINK
I cannot use json. I must use XML, like the example before.

My question is, it is possible to have multiple marker with categories wich have diffrent values.

For example: XML Code
<?xml version="1.0"?>
<markers>
  <marker name="McDonalds" address="good rd. 3" lng="8.4500025" lat="47.267387" category="Restaurant" />
  <marker name="Joe Swimming" address="juicerd. 3" lng="8.4500025" lat="47.267387" category="Swimmingpool" />
  <marker name="Bens Bed" address="bla rd. 5" lng="8.4500025" lat="47.267387" category="Dorm" />
  <marker name="BlueLagune Pub" address="hallo rd. 9" lng="8.4500025" lat="47.267387" category="Pub" />
  <marker name="Grand Hotel De Rozza" address="peep rd. 8" lng="8.4500025" lat="47.267387" category="Restaurant+Dorm+Swimmingpool" />
</markers>


We can see the Grand Hotel De Rozza has a place to eat (Restaurant). It has also a Swimmingpool and you can stay there for few nights. But it hasn't got a Pub!
So when I check the Restaurant category "McDonalds" and "Grand Hotel De Rozza" must be visible!
And when I check the Restaurant and Swimmingpool: "McDonalds" & "Joe Swimming and "Grand Hotel De Rozza" must be visible one time!

Does anyone have any idea or JS Sample?

Thanks in advance :-)

Andrew Leach

unread,
Dec 10, 2011, 5:46:24 PM12/10/11
to google-map...@googlegroups.com
On 10 December 2011 20:39, Kishanth Mehra <ikis...@gmail.com> wrote:
> We can see the Grand Hotel De Rozza has a place to eat (Restaurant). It has
> also a Swimmingpool and you can stay there for few nights. But it hasn't got
> a Pub!
> So when I check the Restaurant category "McDonalds" and "Grand Hotel De
> Rozza" must be visible!
> And when I check the Restaurant and Swimmingpool: "McDonalds" & "Joe
> Swimming and "Grand Hotel De Rozza" must be visible one time!
>
> Does anyone have any idea or JS Sample?

Normally when deciding which marker to display one might use
"switch/case". In this case when you are finding which markers to
show, you need to see whether the category attribute *contains* the
required string, rather than whether it *equals* the required string.
For that, use indexOf: for example, category.indexOf("Swimmingpool")
must be greater than -1 (Not greater than zero, because strings start
counting characters from zero). Of course, this will also find
matching categories where there is only value, eg Joe Swimming.

http://www.w3schools.com/jsref/jsref_indexof.asp

This should be a fairly straightforward extension of an XML example.
Not a maps question though.

Kishanth Mehra

unread,
Dec 14, 2011, 3:17:42 PM12/14/11
to google-map...@googlegroups.com, andrew....@gmail.com
okay thanks.. I'll try it :D
Reply all
Reply to author
Forward
0 new messages