I guess the description was rather complicated...
Anyway, the thing is: the "Map2" class from the Google Maps API,
apparently looks at the location and size of a <div> tag used as its
canvas, to do some setup at page load time. When the <div> it targets is
hidden, its size/position attributes are apparently not correct. Thus,
when the <div> becomes visible, the Map2 object has the incorrect
coordinates and size (calculated during the page load) and draws itself
in a messed up state.
I came across this because I had my map inside a pop-up dialog (from
JQueryUI) which is initially hidden and appears at the center of the
browser window when the user clicks a button.
Anyway, to have the Map2 control re-calculate and re-draw itself, you
need to call its "checkResize()" method. To do that, I needed a
reference to the JavaScript object holding the map. Since I was using
the module from wicket-stuff, I was looking for a way to get to that
javascript object (from my Java code), so that I may dynamically
generate JavaScript code that calls "checkResize()" when the dialog is
opened and becomes visible.
Anyway, the solution in my previous post was wrong. It was a way to get
to the <div> tag that is used as the map canvas. No point in calling
checkResize() on that. What I needed was the Map2 JavaScript object that
is used to control the map.
The correct answer (now that I got it working) is:
myJQueryDialog.setOpenEvent(JsScopeUiEvent
.quickScope("var mapCtrlId = $('.gmap').attr('id');\n"
+ "Wicket.maps[mapCtrlId].map.checkResize();\n"
));
The "Wicket.maps[]" object is managed by the code in "wicket-gmap.js"
from the wicket-stuff module for maps.
Reading back, I am not sure this explanation is simpler than my previous
one, but hey, it IS Sunday afternoon...
On 16/5/2010 16:16, Martin Funk wrote:
sorry my mind is in Sunday afternoon mode, and not able to wrap itself around
this...
could you come up with a Quickstart example?
mf
Am 16.05.2010 um 14:55 schrieb Alexandros Karypidis:
Hi,
I am unsing GMap2 from WicketStuff
(http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-contrib-gmap2) and
need to display a map in a pop-up dialog. I use JQuery for the dialog. When the
Dialog comes up, the map's viewport is offset in relation to the window and only
the cross-section of the map's position (starting outside the dialog window) and
the actual pop-up window is being drawn. For example, assume the map starts at
absolute position 0,0 with as size of 600,400 and the dialog is shown at absolute
position 300,200 with size 600,500: Only the region (300,200 -> 600,400) is
drawn.
This is probably because the dialog is not shown when the GMap2 javascript calculates its
position, so I need to call the "checkResize()" method on
http://code.google.com/apis/maps/documentation/reference.html#GMap2 that is created by
the WicketStuff control. Problem is, I can't get to the Javascript object underlying the
wicketstuff representation. I'm trying to do something like:
myDialog.setOpenEvent(JsScopeUiEvent
.quickScope(
"alert('fixing map size');\n" +
" $('#mapObjectId').checkResize();\n"
);
How can I get the proper "mapObjectId" value?
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]