-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi there!
Just another problem that is becoming me a bit crazy! :)
I want to add markers to a Gmaps map. And I want them to have multiline information on their tooltip, so I use setTooltip(popup) instead of setTooltiptext(string).
These markers depend on information stored in database, so I need to add them from Java code.
Thing is:
- If I do this directly in the .zul view it works perfectly
<gmaps id="map" width="610px" height="550px" scrollWheelZoom="true" showTypeCtrl="true" showLargeCtrl="true"> <gmarker tooltip="myPopup" lat="40" lng="-3"/> </gmaps> <popup id="myPopup"> <html> <attribute name="content"> <![CDATA[YOUR HTML <b>MULTILINE</b> CONTENT HERE]]> </attribute> </html> </popup>
- If I do this it doesn't work! Marker is shown but no tooltip appears
Gmarker marker = MapUtil.geolocate(anAddress); Popup popup = new Popup(); Html html = new Html("Your html <b>multiline</b> content here"); popup.appendChild(html); marker.setTooltip(popup);
All classes used are from org.zkoss.zul package.
So I can't arrive to understand why this is happening! :S I had months ago same problem, but in this case i could solve it using a workaround directly in the zul (same as above) because it was only one tooltip. But now i can't because I manage an indeterminate number of tooltips like now (one each marker)
Thanks in advance for your help.
Rafa
Rafa,
You might consider doing it this way:
<zk> <window id="win" height="100%"> <script src="http://www.google.com/jsapi?key=Your Google Maps Key"></script> <gmaps id="gm" height="100%" width="100%" showSmallCtrl="true" lat="40" lng="-3" zoom="17" mapType="satellite" scrollWheelZoom="true" showTypeCtrl="true"/> <zscript> Gmarker gmarker = new Gmarker(); gmarker.setLat(40); gmarker.setLng(-3); Popup popup = new Popup(); win.appendChild(popup); Vlayout vlayout = new Vlayout(); Label labelLine1 = new Label("Your Multi-line"); Label labelLine2 = new Label("popup content goes here"); vlayout.appendChild(labelLine1); vlayout.appendChild(labelLine2); popup.appendChild(vlayout); gmarker.setTooltip(popup); gm.appendChild(gmarker); </zscript> </window> </zk>
Of course the <zscript> block is only to allow the example to run in a stand-alone manner - you would be better off having this code in your composer.
Hope that helps,
Todd
How could i be so blind!!!!!!!
Todd many thanks, your solution is working! :)
But.... mine too!! :S
Let me tell you how silly I was:
win.appendChild(popup);
Without that line i could dream to have the popup shown in the win! :P
Sorry to disturb you with such a stupid problem, but believe me, you were very helpful!
Regards,
Rafa
Asked: 2011-04-05 02:55:36 +0800
Seen: 727 times
Last updated: Apr 06 '11