Google Maps API Tutorial© 2008, 2009 Mike Williams
|Translate this page:|
GLayersAPI v2.130 introduces GLayers, which can be used for displaying the Wikipedia and Panoramio layers to your map.
Google themselves don't (yet) supply a control for allowing users to switch layers on and off, so I wrote this example
IDs and LMCsThe documented way to specify a particular layer is by using its ID. The official list of IDs is at spreadsheets.google.com/pub?key=p9pdwsai2hDN-cAocTLhnag
In addition to the official list, there are also "com.panoramio.popular", which omits the Panoramio elements that have the small icons, and there's "com.youtube.all" which displays the YouTube layer, and there are a few other Wikipedia languages. I don't intend to test all possible Wikipedia languages: If your favourite language is supported by Wikipedia but isn't in the official GLayers list, try it anyway.
There's also an undocumented way to specify a particular layer, by using its LMC. E.g. map.addOverlay(new GLayer("lmc:panoramio/0")) is the same as map.addOverlay(new GLayer("com.panoramio.popular")).
You can only use IDs that the particular release of the main API code knows about, because the main API code needs to know how to translate the ID into an LMC. In v2.130, the known IDs are "com.panoramio.all", "com.panoramio.popular" and "org.wikipedia.*".
When you use an LMC, the main API code doesn't need to translate it for you, so you can use any LMC for which there is a service.
At the moment, the only LMC that I know about that has service but no ID is "lmc:panoramio/1", which displays the unpopular Panoramio entries and omits the popular ones.
Viewing the source of maps.google.com reveals the existence of "lmc:youtube", but the API has no service for it at the moment.
hide() and show()GLayers support .hide(), .show() and .isHidden().