You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

mathew

Beginner

  • "mathew" started this thread

Posts: 8

Location: Italy

  • Send private message

1

Tuesday, June 9th 2020, 10:00pm

gmAPI and JSON customization

Hi,
I'm trying to customize a google maps using gmAPI of Google Maps Plugin and JSON instructions, but I have no effect.

Source code

1
<action name="gmapi_test" type="Javascript"><![CDATA[	    var gmAPI = caller.gmAPI;	    if (gmAPI)	    {	        gmAPI.map.setOptions({ 			styles: stylers			});	    }		var stylers = [{		  "stylers": [, { ... }]		}];]]></action>



What am I doing wrong?

Thank you!
Matteo

jeromebg

Professional

Posts: 849

Location: Angers - France

Occupation: Photographer

  • Send private message

2

Tuesday, June 9th 2020, 10:38pm

How do you call your gmapi_test action ?

mathew

Beginner

  • "mathew" started this thread

Posts: 8

Location: Italy

  • Send private message

3

Tuesday, June 9th 2020, 11:46pm

Hi,
I call it in a <plugin> and it works:

Source code

1
2
3
4
5
<plugin name="map"
...
onmapready="gmapi_test();"
>
</plugin>


I can load a map and se Lat and Long, for example:

Source code

1
2
3
4
5
6
7
8
9
10
11
<action name="gmapi_test" type="Javascript">
<![CDATA[	
var gmAPI = caller.gmAPI;	
if (gmAPI){	
gmAPI.map.setOptions({
center: new google.maps.LatLng(45.433651, 12.339663),
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP
});}
]]>
</action>


but it doesn't work if I try to set the variable with JSON options:

Source code

1
2
3
4
5
6
7
8
9
10
11
<action name="gmapi_test" type="Javascript">
<![CDATA[	
 var gmAPI = caller.gmAPI;	
 if (gmAPI){	
 gmAPI.map.setOptions({ styles: stylers });}
 	
var stylers = [{
 "stylers": [{ ... }] 
 }];
]]>
</action>


Thank you!

jeromebg

Professional

Posts: 849

Location: Angers - France

Occupation: Photographer

  • Send private message

4

Wednesday, June 10th 2020, 11:40am

try this :

Source code

1
2
3
4
5
6
<action name="gmapi_test" type="Javascript">
<![CDATA[	
 var gmAPI = caller.gmAPI;	
 if (gmAPI){	
 gmAPI.map.setOptions({ styles: [{ ... }] });}
]]> </action>

mathew

Beginner

  • "mathew" started this thread

Posts: 8

Location: Italy

  • Send private message

5

Wednesday, June 10th 2020, 2:25pm

No way *sad*

Lat, lng, zoom, maptype are ok, but no style...

Source code

1
2
3
4
5
6
gmAPI.map.setOptions({
center: {lat: 45.433651, lng: 12.339663},
zoom: 12,
mapTypeId: 'roadmap',
styles: [{elementType: 'geometry', stylers: [{color: '#242f3e'}]}] 
});

jeromebg

Professional

Posts: 849

Location: Angers - France

Occupation: Photographer

  • Send private message

6

Wednesday, June 10th 2020, 5:27pm

do you have a paid account at Google ?
I think custom designs works only for paid accounts now...

mathew

Beginner

  • "mathew" started this thread

Posts: 8

Location: Italy

  • Send private message

7

Thursday, June 11th 2020, 12:34am

Yes!
You're right, it doesn't works in developer mode, but with the right API key it works.

Thank you,
Matteo

Similar threads