problem using setCenter() method with ZK Google Maps

asked 2014-05-06 21:04:52 +0800

Antoc gravatar image Antoc
21 4

I have created a ZK application that uses the Zk Google Maps library. In this application I would like a button that, once clicked, should prompt the map to be displayed with the specific marker in the center. I have created a method that handles the event of the click of the 'centerMarkerButton' button:

public void onClick$centerMarkerButton(event evt){
    myMap.setCenter(marker.getLat(), marker.getLng());

However when clicked, the map doesn't do anything. The following method, which put the marker in the center of the map whenever the map is moved, contains the same code and fully works:

public void onMapMoved$myMap(event evt){
    myMap.setCenter(marker.getLat(), marker.getLng());

Can someone explain me why the first method doesn't work and what a possible solution to this problem can be? THANKS IN ADVANCE

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-05-07 03:18:27 +0800

RaymondChao gravatar image RaymondChao
386 1 4

updated 2014-05-07 03:21:15 +0800


Sorry, it seems gmaps did not update center attribute when map moved. The workaround is to update gmaps center attribute manually when map moved, for example:

<gmaps id="map">
    <attribute name="onMapMove">
        map.setCenter(event.getLat(), event.getLng());

I've created the issue here. If the workaround does not solve your problem, please tell us. Thanks.

link publish delete flag offensive edit
Your answer
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

1 follower



Asked: 2014-05-06 21:04:52 +0800

Seen: 14 times

Last updated: May 07 '14

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