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.
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
How do you call your gmapi_test action ?
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!
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>
|
No way
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'}]}]
});
|
do you have a paid account at Google ?
I think custom designs works only for paid accounts now...
Yes!
You're right, it doesn't works in developer mode, but with the right API key it works.
Thank you,
Matteo