java.lang.Object
com.dlsc.gmapsfx.javascript.JavascriptObject
com.dlsc.gmapsfx.javascript.object.GoogleMap
- Direct Known Subclasses:
ClusteredGoogleMap
public class GoogleMap extends JavascriptObject
- Author:
- Rob Terpilowski
-
Property Summary
Properties Type Property Description javafx.beans.property.ReadOnlyObjectProperty<LatLongBounds>boundsA property tied to the map, updated when the idle state event is fired.javafx.beans.property.ReadOnlyObjectProperty<LatLong>centerjavafx.beans.property.IntegerPropertyzoom -
Field Summary
Fields Modifier and Type Field Description protected static StringdivArgprotected MapOptionsoptionsFields inherited from class com.dlsc.gmapsfx.javascript.JavascriptObject
jsObject, objectCounter, peerRegistry, runtime, variableName -
Constructor Summary
Constructors Constructor Description GoogleMap()GoogleMap(MapOptions mapOptions) -
Method Summary
Modifier and Type Method Description voidaddMapShape(MapShape shape)voidaddMarker(Marker marker)Adds the supplied marker to the map.voidaddMarkers(Collection<Marker> col)Adds all of the markers in the supplied collection to the map.voidaddMarkers(Collection<Marker> col, UIEventType type, javafx.util.Callback<Marker,UIEventHandler> h)voidaddMouseEventHandler(UIEventType type, MouseEventHandler h)Adds a handler for a mouse type event and returns an object that does not require interaction with the underlying Javascript API.voidaddStateEventHandler(MapStateEventType type, StateEventHandler h)Adds a handler for a state type event on the map.voidaddUIEventHandler(UIEventType type, UIEventHandler h)Adds a handler for a mouse type event on the map.voidaddUIEventHandler(JavascriptObject obj, UIEventType type, UIEventHandler h)Adds a handler for a mouse type event on the map.protected voidaddUIHandler(JavascriptObject obj, UIEventType type, GFXEventHandler h)javafx.beans.property.ReadOnlyObjectProperty<LatLongBounds>boundsProperty()A property tied to the map, updated when the idle state event is fired.javafx.beans.property.ReadOnlyObjectProperty<LatLong>centerProperty()voidclearMarkers()Removes all of the markers from the map.voidfitBounds(LatLongBounds bounds)Moves the map to ensure the given bounds fit within the viewport.javafx.geometry.Point2DfromLatLngToPoint(LatLong loc)Returns the screen point for the provided LatLong.LatLongBoundsgetBounds()Returns the LatLongBounds of the visual area.LatLonggetCenter()Gets the value of the property center.doublegetHeading()ProjectiongetProjection()intgetZoom()Gets the value of the property zoom.voidhideDirectionsPane()protected voidinitialize()voidpanBy(double x, double y)Pans the map by the supplied values.voidpanTo(LatLong latLong)Pans the map to the specified latitude and longitude.voidpanToBounds(LatLongBounds bounds)voidremoveMapShape(MapShape shape)voidremoveMarker(Marker marker)Removes the supplied marker from the map.voidremoveMarkers(Collection<Marker> col)Removes the markers in the supplied collection from the map.voidsetCenter(LatLong latLong)Sets the value of the property center.voidsetHeading(double heading)voidsetMapType(MapTypeIdEnum type)Sets the map type.voidsetZoom(int zoom)Sets the value of the property zoom.voidshowDirectionsPane()javafx.beans.property.IntegerPropertyzoomProperty()Methods inherited from class com.dlsc.gmapsfx.javascript.JavascriptObject
checkBoolean, checkInteger, checkUndefined, getJSObject, getNextVariableName, getProperty, getProperty, getVariableName, invokeJavascript, invokeJavascript, invokeJavascriptReturnValue, invokeJavascriptReturnValue, isMemberDefined, setProperty, setProperty, setProperty
-
Property Details
-
zoom
public javafx.beans.property.IntegerProperty zoomProperty- See Also:
getZoom(),setZoom(int)
-
center
- See Also:
getCenter(),setCenter(LatLong)
-
bounds
A property tied to the map, updated when the idle state event is fired.- See Also:
getBounds()
-
-
Field Details
-
Constructor Details
-
Method Details
-
initialize
protected void initialize() -
setZoom
public void setZoom(int zoom)Sets the value of the property zoom.- Property description:
-
getZoom
public int getZoom()Gets the value of the property zoom.- Property description:
-
showDirectionsPane
public void showDirectionsPane() -
hideDirectionsPane
public void hideDirectionsPane() -
zoomProperty
public javafx.beans.property.IntegerProperty zoomProperty()- See Also:
getZoom(),setZoom(int)
-
centerProperty
- See Also:
getCenter(),setCenter(LatLong)
-
getCenter
Gets the value of the property center.- Property description:
-
setCenter
Sets the value of the property center.- Property description:
-
getBounds
Returns the LatLongBounds of the visual area. Note: on zoom changes the bounds are reset after the zoom event is fired, which can cause unexpected results.- Returns:
-
fitBounds
Moves the map to ensure the given bounds fit within the viewport.Note that the Google Maps API will add a buffer around this value, so assuming you can store this and use it to later restore the view will give incorrect results. Calling map.fitBounds(map.getBounds()); will result in the map gradually zooming outward.
- Parameters:
bounds-
-
panToBounds
-
boundsProperty
A property tied to the map, updated when the idle state event is fired.- See Also:
getBounds()
-
setHeading
public void setHeading(double heading) -
getHeading
public double getHeading() -
addMarker
Adds the supplied marker to the map.- Parameters:
marker-
-
removeMarker
Removes the supplied marker from the map.- Parameters:
marker-
-
clearMarkers
public void clearMarkers()Removes all of the markers from the map. -
addMarkers
Adds all of the markers in the supplied collection to the map. Existing markers, if any, are retained.- Parameters:
col-
-
addMarkers
public void addMarkers(Collection<Marker> col, UIEventType type, javafx.util.Callback<Marker,UIEventHandler> h) -
removeMarkers
Removes the markers in the supplied collection from the map.- Parameters:
col-
-
setMapType
Sets the map type. This is equivalent to the javascript method setMapTypeId.- Parameters:
type-
-
addMapShape
-
removeMapShape
-
getProjection
-
panBy
public void panBy(double x, double y)Pans the map by the supplied values.- Parameters:
x- delta x value in pixels.y- delta y value in pixels.
-
panTo
Pans the map to the specified latitude and longitude.- Parameters:
latLong-
-
fromLatLngToPoint
Returns the screen point for the provided LatLong. Note: Unexpected results can be obtained if this method is called as a result of a zoom change, as the zoom event is fired before the bounds are updated, and bounds need to be used to obtain the answer!One workaround is to only operate off bounds_changed events.
- Parameters:
loc-- Returns:
-
addUIEventHandler
Adds a handler for a mouse type event on the map.- Parameters:
type- Type of the event to register against.h- Handler that will be called when the event occurs.
-
addUIEventHandler
Adds a handler for a mouse type event on the map.- Parameters:
obj- The object that the event should be registered on.type- Type of the event to register against.h- Handler that will be called when the event occurs.
-
addMouseEventHandler
Adds a handler for a mouse type event and returns an object that does not require interaction with the underlying Javascript API.- Parameters:
type- The type of event to listen forh- The MouseEventHandler that will handle the event.
-
addUIHandler
-
addStateEventHandler
Adds a handler for a state type event on the map.We could allow this to handle any state event by adding a parameter JavascriptObject obj, but we would then need to loosen up the event type and either accept a String value, or fill an enum with all potential state events.
- Parameters:
type- Type of the event to register against.h- Handler that will be called when the event occurs.
-