currentPolyline = polyline;
GWT.log("hashCode: currentPolyline=" + currentPolyline.hashCode());
GWT.log("hashCode: polyline=" + polyline.hashCode());
//Window.alert("TagMap: PolylineEndLineHandler currentPolyline getVertexCount=" + currentPolyline.getVertexCount());
LatLng points[] = new LatLng[currentPolyline.getVertexCount()];
for (int i = 0; i < currentPolyline.getVertexCount(); i++) {
LatLng v = currentPolyline.getVertex(i);
LatLng p = LatLng.newInstance(v.getLatitude(), v.getLongitude());
points[i] = p;
}
final TagPolyline p = new TagPolyline(points);
p.setRoadDetailsId(currentPolyline.getRoadDetailsId());
// remove the temporary poly from the map
/*
* This is a workaround, and not a good one. It
* removes the line from the map while the user
* gives it a name, a tag, and clicks save.
*/
//map.removeOverlay(polyline);
eventBus.fireEvent(new EndEditPolyLineEvent(p));
}
});
} else {
/**
* Send a copy of the TagPolyline to RoadListing
*/
polyline.addPolylineLineUpdatedHandler(new PolylineLineUpdatedHandler() {
public void onUpdate(PolylineLineUpdatedEvent event) {
/*
* If a line is being edited, it is the current line
*/
currentPolyline = polyline;
/*
* Copy the currentPolyline into a new TagPolyline
* in order to send it across the wire.
*/
//Window.alert("TagMap: PolylineLineUpdatedEvent currentPolyline getVertexCount=" + currentPolyline.getVertexCount());
LatLng points[] = new LatLng[currentPolyline.getVertexCount()];
for (int i = 0; i < currentPolyline.getVertexCount(); i++) {
LatLng v = currentPolyline.getVertex(i);
LatLng p = LatLng.newInstance(v.getLatitude(), v.getLongitude());
points[i] = p;
}
final TagPolyline p = new TagPolyline(points);
p.setRoadDetailsId(currentPolyline.getRoadDetailsId());
eventBus.fireEvent(new BindPolyLineToRoadEvent(p));
}
});
polyline.addPolylineCancelLineHandler(new PolylineCancelLineHandler() {