Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tooltip to GoogleMap Markers #150

Open
wants to merge 4 commits into
base: wt3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Wt/WGoogleMap
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*/
Expand Down
22 changes: 13 additions & 9 deletions src/Wt/WGoogleMap.C
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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());
Expand Down