I'm developing a web application using Apache Wicket 6 and WicketStuff GMap3, along with Sven Meier's wicketdnd. On the main page I have a table of items and an instance of the GMap3 widget.
I would like to be able to drag an item from the table and place it on the GMap3 widget. I can drag an item from the table onto another Ajax panel on the page (the dragged item turns from red to blue when its over a drop target) but when the same item is dragged over the GMap3 widget it stays red.
I added a DragSource to the table like this:
DefaultDataTable dataTable = new DefaultDataTable(ID_CUSTOM_TABLE, columns, new CustomDataProvider(), 5) {
@Override
protected Item newRowItem(String id, int index, IModel model) {
Item item = super.newRowItem(id, index, model);
item.setOutputMarkupId(true);
return item;
}
};
dataTable.add(new WebTheme());
dataTable.add(new DragSource(Operation.COPY) {
public void onBeforeDrop(AjaxRequestTarget target, Transfer transfer) {
logger.info("We are before the DROP");
}
public void onAfterDrop(AjaxRequestTarget target, Transfer transfer) {
logger.info("we are after the DROP");
}
}.drag("tr"));
final MarkupContainer ajaxPanel = new WebMarkupContainer(ID_AJAX_FORM_PANEL);
ajaxPanel.setOutputMarkupId(true);
ajaxPanel.add(dataTable);
and a Drop target to the GMap3 widget like this:
GMap map = new GMap(ID_GMAP, GMAP_TOKEN);
map.setCenter(new GLatLng(51.209096,-1.5238051));
map.setMapType(GMapType.ROADMAP);
map.setZoom(10);
map.setStreetViewControlEnabled(false);
map.setScrollWheelZoomEnabled(false);
map.setZoomControlEnabled(false);
map.setScaleControlEnabled(false);
map.setOutputMarkupId(true);
map.add(new DropTarget(Operation.COPY) {
@Override
public void onDrag(AjaxRequestTarget target, Location location) {
logger.info("Map got drag event.");
}
@Override
public void onDrop(AjaxRequestTarget target, Transfer transfer, Location location) throws Reject {
logger.info("Map got drop event.");
}
}.dropCenter("div"));
final MarkupContainer ajaxMapPanel = new WebMarkupContainer(ID_AJAX_MAP_PANEL);
ajaxMapPanel.add(map);
The HTML fragment for the map is below:
<div wicket:id="map.ajaxpanel" style="width:1580px;height:680px;background:white">
<div id="map" wicket:id="map" style="width:1580px;height:680px;background:white"/>
</div>
Has anyone solved this problem and if so, how did you do it?
Many thanks.