0

Issue with multiline tooltips (popup used)

asked 2011-04-05 02:55:36 +0800

rafilla80 gravatar image rafilla80
18

updated 2011-04-05 05:38:59 +0800

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

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-04-05 10:34:16 +0800

twiegand gravatar image twiegand
1807 3

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

link publish delete flag offensive edit

answered 2011-04-06 02:05:38 +0800

rafilla80 gravatar image rafilla80
18

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

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-04-05 02:55:36 +0800

Seen: 727 times

Last updated: Apr 06 '11

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