Wt: Wt::WGoogleMap Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Protected Member Functions
Wt::WGoogleMap Class Reference

A widget that displays a google map. More...

`#include <Wt/WGoogleMap>`

Inheritance diagram for Wt::WGoogleMap:
[legend]

List of all members.

## Classes
class | Coordinate
| A geographical coordinate (latitude/longitude) More...
## Public Types
enum | ApiVersion { Version2, Version3 }
| ApiVersion. More...
enum | MapTypeControl { NoControl, DefaultControl, MenuControl, HierarchicalControl, HorizontalBarControl }
| MapTypeControl. More...
## Public Member Functions
| WGoogleMap (ApiVersion version, WContainerWidget *parent=0)
| Creates a map widget with a version and optionally a parent argument.
| WGoogleMap (WContainerWidget *parent=0)
| Creates a map widget with optionally a parent argument.
virtual | ~WGoogleMap ()
| Destructor.
void | addMarker (const Coordinate &pos)
| Adds a marker overlay to the map.
void | addPolyline (const std::vector< Coordinate > &points, const WColor &color=WColor(red), int width=2, double opacity=1.0)
| Adds a polyline overlay to the map.
void | addCircle (const Coordinate &center, double radius, const WColor &strokeColor, int strokeWidth, const WColor &fillColor=WColor())
| Adds a circle to the map.
void | addIconMarker (const Coordinate &pos, const std::string &iconURL)
| Adds a icon marker overlay to the map.
void | clearOverlays ()
| Removes all overlays from the map.
void | openInfoWindow (const Coordinate &pos, const Wt::WString &myHtml)
| Opens a text bubble with html text at a specific location.
void | setCenter (const Coordinate &center)
| Sets the map view to the given center.
void | setCenter (const Coordinate &center, int zoom)
| Sets the map view to the given center and zoom level.
void | panTo (const Coordinate &center)
| Changes the center point of the map to the given point.
void | zoomWindow (const std::pair< Coordinate, Coordinate > &bbox)
| Zooms the map to a region defined by a bounding box.
void | zoomWindow (const Coordinate &topLeft, const Coordinate &bottomRight)
| Zooms the map to a region defined by a bounding box.
void | setZoom (int level)
| Sets the zoom level to the given new value.
void | zoomIn ()
| Increments zoom level by one.
void | zoomOut ()
| Decrements zoom level by one.
void | savePosition ()
| Stores the current map position and zoom level.
void | returnToSavedPosition ()
| Restores the map view that was saved by savePosition().
void | checkResize ()
| Notifies the map of a change of the size of its container.
void | enableDragging ()
| Enables the dragging of the map (enabled by default).
void | disableDragging ()
| Disables the dragging of the map.
void | enableDoubleClickZoom ()
| Enables double click to zoom in and out (enabled by default).
void | disableDoubleClickZoom ()
| Disables double click to zoom in and out.
void | enableGoogleBar ()
| Enables the GoogleBar, an integrated search control, on the map.
void | disableGoogleBar ()
| Disables the GoogleBar integrated search control.
void | enableScrollWheelZoom ()
| Enables zooming using a mouse's scroll wheel.
void | disableScrollWheelZoom ()
| Disables zooming using a mouse's scroll wheel.
void | setMapTypeControl (MapTypeControl type)
| Sets the map type control.
JSignal< Coordinate > & | clicked ()
| The click event.
JSignal< Coordinate > & | doubleClicked ()
| The double click event.
JSignal< Coordinate > & | mouseMoved ()
| This event is fired when the user moves the mouse inside the map.
ApiVersion | apiVersion ()
| Return the used Google Maps API version.
## Protected Member Functions
virtual void | render (WFlags< RenderFlag > flags)
| Renders the widget.
virtual void | doGmJavaScript (const std::string &jscode)
| Execute a piece of JavaScript that manipulates the map.

## Detailed Description

A widget that displays a google map.

This widget uses the online Google Maps server to display a map. It exposes a part of the google maps API.

This widget supports both version 2 and version 3 of the Google Maps API. The version 2 API is used by default, to enable the version 3 API, use the constructor's version argument.

To use the map on a public server you will need to obtain a key. The widget will look for this key as the configuration property `"google_api_key"`. If this configuration property has not been set, it will use a key that is suitable for localhost.

### CSS

Styling through CSS is not applicable.

Contributed by: Richard Ulrich.

## Member Enumeration Documentation

enum Wt::WGoogleMap::ApiVersion

ApiVersion.

Enumerator:

  Version2 | API Version 2.x.
  Version3 | API Version 3.x.

enum Wt::WGoogleMap::MapTypeControl

MapTypeControl.

Enumerator:

  NoControl | Show no maptype control.
  DefaultControl | Show the default maptype control.
  MenuControl | Show the dropdown menu maptype control.
  HierarchicalControl | Show the hierarchical maptype control.
  HorizontalBarControl | Show the horizontal bar maptype control.

## Member Function Documentation

void Wt::WGoogleMap::addCircle | ( | const Coordinate & | center,
|  | double | radius,
|  | const WColor & | strokeColor,
|  | int | strokeWidth,
|  | const WColor & | fillColor = `WColor()`
| ) |  |

Adds a circle to the map.

The stroke and fill opacity can be configured respectively in the strokeColor and fillColor. This feature is only supported by the Google Maps API version 3.

void Wt::WGoogleMap::addPolyline | ( | const std::vector< Coordinate > & | points,
|  | const WColor & | color = `WColor(red)`,
|  | int | width = `2`,
|  | double | opacity = `1.0`
| ) |  |

Adds a polyline overlay to the map.

Specify a value between 0.0 and 1.0 for the opacity or set the alpha value in the color.

void Wt::WGoogleMap::checkResize | ( |  | ) |

Notifies the map of a change of the size of its container.

Call this method after the size of the container DOM object has changed, so that the map can adjust itself to fit the new size.

Deprecated:
  the map is resized automatically when necessary

JSignal<Coordinate>& Wt::WGoogleMap::clicked | ( |  | ) |

The click event.

This event is fired when the user clicks on the map with the mouse.

void Wt::WGoogleMap::disableGoogleBar | ( |  | ) |

Disables the GoogleBar integrated search control.

When disabled, the default Powered by Google logo occupies the position formerly containing this control. Note that this control is already disabled by default.

Note:
  This functionality is no longer available in the Google Maps API v3.

void Wt::WGoogleMap::disableScrollWheelZoom | ( |  | ) |

Disables zooming using a mouse's scroll wheel.

Scroll wheel zoom is disabled by default.

void Wt::WGoogleMap::doGmJavaScript | ( | const std::string & | jscode | ) | `[protected, virtual]`

Execute a piece of JavaScript that manipulates the map.

This is like doJavaScript() but delays the javascript until the map has been loaded.

JSignal<Coordinate>& Wt::WGoogleMap::doubleClicked | ( |  | ) |

The double click event.

This event is fired when a double click is done on the map.

void Wt::WGoogleMap::enableGoogleBar | ( |  | ) |

Enables the GoogleBar, an integrated search control, on the map.

When enabled, this control takes the place of the default Powered By Google logo.

This control is initially disabled.

Note:
  This functionality is no longer available in the Google Maps API v3.

void Wt::WGoogleMap::enableScrollWheelZoom | ( |  | ) |

Enables zooming using a mouse's scroll wheel.

Scroll wheel zoom is disabled by default.

void Wt::WGoogleMap::panTo | ( | const Coordinate & | center | ) |

Changes the center point of the map to the given point.

If the point is already visible in the current map view, change the center in a smooth animation.

void Wt::WGoogleMap::render | ( | WFlags< RenderFlag > | flags | ) | `[protected, virtual]`

Renders the widget.

This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

Reimplemented from Wt::WCompositeWidget.

void Wt::WGoogleMap::savePosition | ( |  | ) |

Stores the current map position and zoom level.

You can later restore this position using returnToSavedPosition().

void Wt::WGoogleMap::setMapTypeControl | ( | MapTypeControl | type | ) |

Sets the map type control.

The control allows selecting and switching between supported map types via buttons.

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator