Sie sind nicht angemeldet.

1

Dienstag, 24. August 2010, 12:32

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

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
	<plugin name="gmaps" 
		 	url="http://localhost/vtours/live/plugins/googlemaps.swf" 
		 	keep="true" 
		 	visible="true" enabled="true" handcursor="false" capture="true" children="true" 
		 	zorder="1000" alpha="1.00" blendmode="normal" 
		 	smoothing="true" origin="left" edge="" 
		 	x="0" y="0" width="245" height="475" 
		 	scale="1" onloaded="" onover="" onhover="" onout="" 
		 	ondown="" onup="" onclick="" 
		 	scrollwheel="true" dragging="true" maptype="SATELLITE" 
		 	zoom="14" 
			key="" 
		 	onmapready="updatespot(sp_1);" 
		 	>
			<radar alpha="0.25" 
			   	behindspots="true" 
			   	dragable="true" 
			   	fillalpha="1.0" 
			   	fillcolor="0x9999FF" 
			   	glow="true" 
		   		   glowcolor="0" 
			   	glowstrength="3" 
				   glowwidth="4" 
			   	linealpha="0.0" 
			   	linecolor="0xFFFFFF" 
			   	linewidth="0.0" 
			   	size="100" 
			   	visible="true" 
			   	/>
		<spot  	name="sp_1" heading="-90" 
				lat="17.4675902" lng="78.5565376" 
				onhover="showtext(Spot 1);" 
				/>

		<spot  	name="sp_3" heading="-90" 
				lat="17.4713563" lng="78.5632324" 
				onhover="showtext(Spot 3);" 
				/>

	</plugin>

With javascript i can add the google maps plugin as

Quellcode

1
2
3
4
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

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »srisa« (24. August 2010, 12:46)


2

Dienstag, 24. August 2010, 13:37

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)

Quellcode

1
2
3
4
5
6
7
8
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

3

Mittwoch, 25. August 2010, 16:05

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

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// this is for adding the map
			krp.call("addplugin(gmap)");
			krp.set("plugin[gmap].url", url);
			krp.set("plugin[gmap].lat", lat);
			krp.set("plugin[gmap].lng", lng);

// After a time out of few seconds, code for adding the spot and the radar
			krp.call("plugin[gmap].addspot(spot1, 60, 120, 90);");
			krp.call("plugin[gmap].updatespots();"); // this is important

			krp.set("plugin[gmap].radar.keep", true); 
			krp.set("plugin[gmap].radar.enabled", true);
			krp.set("plugin[gmap].radar.visible", true);

			krp.call("plugin[gmap].activatespot(spot1);"); 
			krp.call("plugin[gmap].pantospot(spot1);"); 

4

Donnerstag, 26. August 2010, 08:41

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.

Quellcode

1
2
3
4
5
6
7
8
9
...
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

5

Samstag, 4. September 2010, 14:06

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.

Quellcode

1
2
3
4
5
6
			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.

6

Mittwoch, 8. September 2010, 11:42

Hi,
Am i missing something?
yes, have a look at here - http://krpano.com/plugins/googlemaps/ - for updatecontrols(),

best regards,
Klaus

Ähnliche Themen