diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index 5d1fa5e1ff937680024cdf481e2301d4dddb9566..1f244dd5b732697c5431fdfc71d35fa78c541e3f 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -407,6 +407,7 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) { + if (!wpExists(coordinate)){ // Create waypoint name QString str; @@ -425,6 +426,8 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) { tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle); } + + mc->layer("Waypoints")->addGeometry(tempCirclePoint); Point* tempPoint = new Point(coordinate.x(), coordinate.y(),str); @@ -436,11 +439,22 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) // Refresh the screen mc->updateRequestNew(); + } //// // emit signal mouse was clicked // emit captureMapCoordinateClick(coordinate); } +int MapWidget::wpExists(const QPointF coordinate){ + for (int i = 0; i < wps.size(); i++){ + if (wps.at(i)->latitude() == coordinate.y() && + wps.at(i)->longitude()== coordinate.x()){ + return 1; + } + } + return 0; +} + void MapWidget::captureGeometryClick(Geometry* geom, QPoint point) { diff --git a/src/ui/MapWidget.h b/src/ui/MapWidget.h index dd941909a6b9a8a2844acd4ecdf1a1c88408b6af..66125a4ae33cbad8c550aff2007c3e2527a669fe 100644 --- a/src/ui/MapWidget.h +++ b/src/ui/MapWidget.h @@ -144,7 +144,7 @@ private: QHash wpIndex; qmapcontrol::LineString* path; QPen* pointPen; - + int wpExists(const QPointF coordinate); bool waypointIsDrag;