diff --git a/src/Wt/WGoogleMap b/src/Wt/WGoogleMap index bad7095bfe..7baa799164 100644 --- a/src/Wt/WGoogleMap +++ b/src/Wt/WGoogleMap @@ -129,7 +129,7 @@ public: /*! \brief Adds a marker overlay to the map. */ - void addMarker(const Coordinate &pos); + void addMarker(const Coordinate &pos, const WString &toolTip = WString()); /*! \brief Adds a polyline overlay to the map. * @@ -152,7 +152,7 @@ public: /*! \brief Adds a icon marker overlay to the map. */ - void addIconMarker(const Coordinate &pos, const std::string& iconURL); + void addIconMarker(const Coordinate &pos, const std::string& iconURL, const WString &toolTip = WString()); /*! \brief Removes all overlays from the map. */ diff --git a/src/Wt/WGoogleMap.C b/src/Wt/WGoogleMap.C index 6b71fe25d2..9d25cf4d85 100644 --- a/src/Wt/WGoogleMap.C +++ b/src/Wt/WGoogleMap.C @@ -301,7 +301,7 @@ void WGoogleMap::doGmJavaScript(const std::string& jscode) additions_.push_back(jscode); } -void WGoogleMap::addMarker(const Coordinate& pos) +void WGoogleMap::addMarker(const Coordinate& pos, const WString &toolTip) { std::stringstream strm; @@ -316,16 +316,19 @@ void WGoogleMap::addMarker(const Coordinate& pos) strm << ";" << "var marker = new google.maps.Marker({" << "position: position," - << "map: " << jsRef() << ".map" - << "});" - << jsRef() << ".map.overlays.push(marker);"; + << "map: " << jsRef() << ".map"; + if (!toolTip.empty()) + strm << ", title: " << WWebWidget::jsStringLiteral(toolTip); + + strm << "});" + << jsRef() << ".map.overlays.push(marker);"; } doGmJavaScript(strm.str()); } void WGoogleMap::addIconMarker(const Coordinate &pos, - const std::string& iconURL) + const std::string& iconURL, const WString &toolTip) { std::stringstream strm; @@ -339,10 +342,11 @@ void WGoogleMap::addIconMarker(const Coordinate &pos, << "var marker = new google.maps.Marker({" << "position: position," << "icon: \"" << iconURL << "\"," - << "map: " << jsRef() << ".map" - << "});" - - << jsRef() << ".map.overlays.push(marker);"; + << "map: " << jsRef() << ".map"; + if (!toolTip.empty()) + strm << ", title: " << WWebWidget::jsStringLiteral(toolTip); + strm << "});" + << jsRef() << ".map.overlays.push(marker);"; } doGmJavaScript(strm.str());