Maps plugin: how to use gmAPI?

  • Hi to everyone!

    I'd like to use the gmAPI object which is mentioned in this page of the documentation. This part of the documentation being rather obscure (unlike the rest of the documentation I should say), could anyone tell me how to use this gmAPI object? How to access it? Where is it?

    Greetings,

    Seb

  • Hi,

    here an example:

    Call in the 'onmapready' event a custom action:

    Code
    <plugin name="map"
        ...
        onmapready="gmapi_test();"
        />

    and in in that custom (Javascript) Action access the gmAPI object via the 'caller' object (that is the plugin[map] object):

    Code
    <action name="gmapi_test" type="Javascript"><![CDATA[
        var gmAPI = caller.gmAPI;
        if (gmAPI) // check if having the gmAPI
        {
            gmAPI.map.setOptions(...);
        }
    ]]></action>

    Best regards,
    Klaus

  • Thanks Klaus for the quick answer!

    How would I do (if doable) with external JS? I mean:

    In my vtourskin.xml:

    Code
    <layer name="skin_map_container" type="container" align="leftop" width="100%" height="100%" bgroundedge="get:skin_settings.design_bgroundedge" maskchildren="true">
      <layer name="skin_map" state="closed" url="" visible="false" align="lefttop" width="100%" height="50%" x="0" y="0" zorder="1" lat="0" lng="0" zoom="10" bgalpha="0" maptype="hybrid" onmapready="skin_addmapspots(); js(map());">
      							[...]
          						</layer>
    					</layer>

    Im my custom JS file:

    Code
    function googleMap() {
      // How to get gmAPI from here?
    }
  • Thanks again. Excuse my newbiness, but "plugin[map]" is null in my case. I edited the vtourskin.xml excerpt in my previous post to be more explicit.
    I can get layer[skin_map], but it has no gmAPI attribute :-/

  • Hi,

    the name 'plugin[map]' depends of course on the name that was used in the xml to load the maps plugin.

    And right for the vtourskin.xml this would be the 'layer[skin_map]'.

    When layer[skin_map].gmAPI is undefined there could be normally only these reasons:
    - you're trying to get gmAPI before the onmapsready event has been called/processed,
    - or the googlemaps.js is too old (it would need to be 1.19-pr9 or higher),
    - or you're using bing instead of google maps,
    - or you're using flash instead of html5.

    Try to check if one of these is true.

    Best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!