0

Accessing GMap in javascript

asked 2011-06-01 07:31:50 +0800

viegas gravatar image viegas
3

updated 2011-06-01 07:34:14 +0800

Hi there,

I'm struggling a bit to access the gmap object in javascript, and I'd appreciate some help.

In my .zul file I have

<gmaps id="gmap" blah blah></gmaps>


So far so good, and I'm able to use every functionality defined in ZK's gmap wrapper. What I'm trying to do now is to directly access the GMap2 in javascript, to perform functionalities that aren't available in gmaps.wpd. For example, let's say that I wanted to use the map's setCenter function directly without using ZK, I could define a function as such:
<script type="text/javascript"><![CDATA[
function Example() {
var mapExample = ? and here is my problem...
// how to get the GMap2 object? something like new GMap2(document.getElementById("gmap")) ?
mapExample.setCenter(new GLatLng(0, 0), 13);
} ]]></script>


As you can see above, my problem is getting the reference to the GMap2 object that ZK created... I'd really appreciate some help on this, thanks!

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2011-06-14 03:10:57 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

There is a ZK client widget that wrap the google GMap2 object. You have to read the gmapsz javascript source code.

link publish delete flag offensive edit

answered 2012-10-30 15:00:42 +0800

InfoSec812 gravatar image InfoSec812
96

henrichen, I have looked at the JavaScript object, but I am still unclear on how to set a new center.... I tried:

var gMaps = zk.Widget.$('$mainMap');
gMaps._gmaps.center = [0.0, 0.0];

and various other combinations to manipulate the widget, but no luck so far. Could you elaborate?

Thanks in advance!

Deven

link publish delete flag offensive edit

answered 2012-10-31 01:21:16 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

updated 2012-10-31 01:23:39 +0800

@InfoSec812,

try if setCenter() works. However, calling directly in browser side might cause data inconsistency risk between browser and server side.

link publish delete flag offensive edit

answered 2012-11-02 14:04:15 +0800

InfoSec812 gravatar image InfoSec812
96

Actually, after MUCH searching, the proper method to call on the Gmaps object in JavaScript is the "panTo([lat,long])" method. The problem I have now is that I have yet to be able to grab the object script-wise and manipulate it... I can manipulate it from Chrome's JavaScript console, but not from my ZK scripts.

link publish delete flag offensive edit

answered 2013-10-28 10:28:00 +0800

alexonline84 gravatar image alexonline84
1

How did you solve your problem? I have the same too...

link publish delete flag offensive edit

answered 2014-01-23 15:21:57 +0800

InfoSec812 gravatar image InfoSec812
96

I never did find an answer.

link publish delete flag offensive edit

answered 2014-07-04 13:29:16 +0800

ssuplik gravatar image ssuplik
1

I found the answer, if u want how to access to google api over zkoss, contact me at [email protected] :)

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-06-01 07:31:50 +0800

Seen: 440 times

Last updated: Jul 04 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More