today I've wrote ImageMap widget after reading request on GWT google groups.
I found following issue which I need to be solved somehow:
- once <map> tag is attached to root panel (or its descendant) everything is erased from view and it cannot be restored, e.g. by commenting lines which adds map tags,
I recreated that using HTMLPanel which accepts img + image map tags e.g. from that example page:
http://www.w3schools.com/tags/tag_map.asp
should it be escaped with isDesignTime() solution (which was not working for me when using my widget for some reason)?
Anyone already used image maps in gwt-based apps?
- Code: Select all
package com.mycompany.project.client;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.RootPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class ImageViewer {
private HTMLPanel panel;
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
String htmlString = "";
if (isDesignTime() == false) {
htmlString = "<img src=\"http://www.w3schools.com/tags/planets.gif\" "
+ "\r\nwidth=\"145\" height=\"126\"\r\nalt=\"Planets\" "
+ "\r\nusemap=\"#planetmap\" />\r\n\r\n<map id=\"planetmap\" "
+ "name=\"planetmap\">\r\n\r\n<area shape=\"rect\" "
+ "\r\ncoords=\"0,0,82,126\" \r\nalt=\"Sun\"\r\nhref=\"sun.htm\" "
+ "/>\r\n\r\n<area shape=\"circle\" \r\ncoords=\"90,58,3\" "
+ "\r\nalt=\"Mercury\"\r\nhref=\"mercur.htm\" "
+ "/>\r\n\r\n<area shape=\"circle\" "
+ "\r\ncoords=\"124,58,8\" "
+ "\r\nalt=\"Venus\"\r\nhref=\"venus.htm\" "
+ "/>\r\n\r\n</map>";
}
panel = new HTMLPanel(htmlString);
rootPanel.add(panel, 5, 5);
panel.setSize("300px", "300px");
//
}
private static final boolean isDesignTime() {
return false;
}
}
thanks,
regards,
Peter