Adding google maps plugin with javascript

  • Hello,

    I have had some experience add plugins etc with javascript. I am stumped with google maps though; radar and spot are added as children of the google maps plugin. When i say children, i mean that they enclosed within the plugin tag of the google maps.
    In the xml file that i write xml for google maps is like this


    With javascript i can add the google maps plugin as

    Code
    krpano().get().call("addplugin(gmaps);");
    krpano().get().call("set(plugin[gmaps].lat, 12);");
    krpano().get().call("set(plugin[gmaps].lng, 121);");
    .....


    That will add the google map and the radar. How do i go about adding the spot so that it will appear as mentioned in the xml above? That is, how do i add the radar and spot sub-nodes to the google maps plugin with javascript?

    Thanks

    Edited once, last by srisa (August 24, 2010 at 12:46 PM).

  • Hi,

    That will add the google map and the radar. How do i go about adding the spot so that it will appear as mentioned in the xml above? That is, how do i add the radar and spot sub-nodes to the google maps plugin with javascript?

    for adding spots you would need to call the googlemaps addspot function,
    and the radar must just set,

    e.g. (btw - your code was a bit wrong, here's a corrected and a bit improved one)

    Code
    var krp = krpano();
    krp.call("addplugin(gmaps);");
    krp.set("plugin[gmaps].lat", 12);
    krp.set("plugin[gmaps].lng", 121);
    krp.call("plugin[gmaps].addspot(spot1,12,121);");
    krp.call("plugin[gmaps].addspot(spot2,13,122);");
    krp.call("plugin[gmaps].addspot(spot3,14,123);");
    krp.set("plugin[gmaps].radar.visible", true);

    best regards,
    Klaus

  • Thanks Klaus, that set me on the path.

    The spot is appearing only if there is a gap of few seconds after the addition of the map. Also, i had to activate the spot to make the radar visible. This is the code that i have

  • Hi,

    The spot is appearing only if there is a gap of few seconds after the addition of the map.

    right, sorry, I forgot, it needs a bit time until the googlemaps functions (like addspot,...) are added,
    but you could use the "onmapready" event for that,
    e.g.

    Code
    ...
    krp.set("plugin[gmap].onmapready", "js( krpano_googlemaps_ready() )" );
    
    
    function krpano_googlemaps_ready()
    {
      krp.call("plugin[gmap].addspot(spot1, 60, 120, 90);");
      krp.call("plugin[gmap].updatespots();"); // this is important
      // ...
    }

    best regards,
    Klaus

  • Hello,

    Is it possible to add the zoomcontrol with to google maps with javascript? I have tried the following code but the zoom controls don't show up.

    Code
    krp.set("plugin[gmap].zoomcontrol.visible", true);
    			krp.set("plugin[gmap].zoomcontrol.keep", true);
    			krp.set("plugin[gmap].zoomcontrol.enabled", true); 
    			krp.set("plugin[gmap].zoomcontrol.anchor", "bottomright");
    			krp.set("plugin[gmap].zoomcontrol.x", 5);
    			krp.set("plugin[gmap].zoomcontrol.y", 5);


    Am i missing something?

    Thank you.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!