Saturday, April 30, 2011

[Google Maps API v2] Re: Getting center and zoom of a map from an XML file

> So the code I'd like to get from an external file is
>
> map.setCenter(new GLatLng(-22, 147), 5); [lat - lng - zoom]
>
> and
>
> show("Accommodation"); [show or hide]
> show("Activities"); [show or hide]

You don't get "code" for your markers from the XML file, you parse out
data items like lat, long, image url etc. and then use those in your
code.
Seems to me it would make sense to follow a similar process.
You can put what you like in XML format ; why not consider adding an
element like
<mapstyle zoom="5" lat="22.5" lng="134.2" cat1="show"
cat2="hide" ... >
and adapting your parser to interpret it.

It might actually be a bit more versatile to do something like
<mapstyle zoom="5" lat="22.5" lng="134.2" />
<category name="Travel Guides" initial="show" />
<category name="Accommodation" initial="hide" />
etc.
That allows more flexibility in category names without rewriting code,
future extensions to supply marker icons per category, and so on.
It's probably smart to code defensively so that some default actions
are taken, if your special elements are not found in the XML.

--
You received this message because you are subscribed to the Google Groups "Google Maps API V2" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate