@Tag(value="google-map")
@JsModule(value="@flowingcode/google-map/google-map.js")
@NpmPackage(value="@flowingcode/google-map",
version="3.0.1")
public class GoogleMap
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasSize
| Modifier and Type | Class and Description |
|---|---|
static class |
GoogleMap.MapType
Base map types supported by Google Maps.
|
| Constructor and Description |
|---|
GoogleMap(String apiKey,
String clientId,
String language)
Initiates a new GoogleMap object with default settings from the
state object. |
| Modifier and Type | Method and Description |
|---|---|
void |
addMarker(GoogleMapMarker marker)
Adds a marker to the map.
|
GoogleMapMarker |
addMarker(String caption,
LatLon position,
boolean draggable,
String iconUrl)
Adds a new marker to the map.
|
void |
addPolygon(GoogleMapPolygon polygon) |
GoogleMapPolygon |
addPolygon(List<GoogleMapPoint> points) |
LatLon |
getCenter()
Returns the current position of the center of the map.
|
Double |
getLatitude() |
Double |
getLongitude() |
GoogleMap.MapType |
getMapType()
Returns the current type of the base map.
|
int |
getMaxZoom()
Returns the current maximum amount of zoom.
|
int |
getMinZoom()
Returns the current minimum amount of zoom.
|
int |
getZoom()
Returns the current zoom of the map.
|
boolean |
isDraggable()
Checks if the map is currently draggable.
|
void |
removeMarker(GoogleMapMarker marker) |
void |
removePolygon(GoogleMapPolygon polygon) |
void |
setCenter(LatLon center)
Sets the center of the map to the given coordinates.
|
void |
setDraggable(boolean draggable)
Enables/disables dragging of the map.
|
void |
setMapType(GoogleMap.MapType type)
Sets the type of the base map.
|
void |
setMaxZoom(int maxZoom)
Sets the maximum allowed amount of zoom (default 21.0).
|
void |
setMinZoom(int minZoom)
Sets the minimum allowed amount of zoom (default 0.0).
|
void |
setZoom(int zoom)
Zooms the map to the given value.
|
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic GoogleMap(String apiKey, String clientId, String language)
state object.apiKey - The Maps API key from Google. Not required when developing in
localhost or when using a client id. Use null or empty string
to disable.clientId - Google Maps API for Work client ID. Use this instead of API
key if available. Use null or empty string to disable.language - The language to use with maps. See
https://developers.google.com/maps/faq#languagesupport for
the list of the supported languages. Use null or empty string
to disable.@Synchronize(value="google-map-idle") public Double getLatitude()
@Synchronize(value="google-map-idle") public Double getLongitude()
public void setCenter(LatLon center)
center - The new coordinates of the center.public LatLon getCenter()
public void setZoom(int zoom)
zoom - New amount of the zoom.@Synchronize(value="google-map-idle") public int getZoom()
public GoogleMapMarker addMarker(String caption, LatLon position, boolean draggable, String iconUrl)
caption - Caption of the marker shown when the marker is hovered.position - Coordinates of the marker on the map.draggable - Set true to enable dragging of the marker.iconUrl - The url of the icon of the marker.public GoogleMapPolygon addPolygon(List<GoogleMapPoint> points)
public void addPolygon(GoogleMapPolygon polygon)
public void removePolygon(GoogleMapPolygon polygon)
public void addMarker(GoogleMapMarker marker)
marker - The marker to add.public void removeMarker(GoogleMapMarker marker)
public void setMapType(GoogleMap.MapType type)
type - The new MapType to use.public GoogleMap.MapType getMapType()
public boolean isDraggable()
public void setDraggable(boolean draggable)
draggable - Set to true to enable dragging.public void setMaxZoom(int maxZoom)
maxZoom - The maximum amount for zoom.public int getMaxZoom()
public void setMinZoom(int minZoom)
minZoom - The minimum amount for zoom.public int getMinZoom()
Copyright © 2020 Flowing Code. All rights reserved.