-
FEATURED COMPONENTS
First time here? Check out the FAQ!
click on the map to draw the lines
<div apply="org.zkoss.reference.component.diagrams.DrawLineComposer">
<button id="clear" label="Clear Lines"/>
<gmaps id="map4draw" width="50%" height="500px" />
</div>
package org.zkoss.reference.component.diagrams;
import org.zkoss.gmaps.*;
import org.zkoss.gmaps.event.MapMouseEvent;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.*;
import java.util.*;
public class DrawLineComposer extends SelectorComposer {
@Wire
private Gmaps map4draw;
private List<LatLng> clickedPoints = new LinkedList();
private Gpolyline currentPolyline = new Gpolyline();
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
map4draw.appendChild(currentPolyline);
}
@Listen("onMapClick = #map4draw")
public void recordDraw(MapMouseEvent event){
clickedPoints.add(event.getLatLng());
drawPolylines();
}
@Listen("onClick = #clear")
public void clearPoints(){
clickedPoints.clear();
currentPolyline.setPath(new LinkedList<>(clickedPoints));
}
private void drawPolylines() {
if (clickedPoints.size() > 1) {
currentPolyline.setPath(new LinkedList<>(clickedPoints));
}
}
}
Hey there,
Running with ZK 9.6.4, ZK Gmaps 4.0.0, I've tested the sample with the following operations:
In all zoom levels, I haven't seen the lines disapearing.
Could you post the steps required to reproduce? Additionally, when the line disappear, do you see any console error in the client-side JS console?
Asked: 2023-10-11 01:46:28 +0800
Seen: 7 times
Last updated: Oct 19