Class GoogleMap

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 Details

  • 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

      public final javafx.beans.property.ReadOnlyObjectProperty<LatLong> centerProperty()
      See Also:
      getCenter(), setCenter(LatLong)
    • getCenter

      public LatLong getCenter()
      Gets the value of the property center.
      Property description:
    • setCenter

      public void setCenter​(LatLong latLong)
      Sets the value of the property center.
      Property description:
    • getBounds

      public LatLongBounds 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

      public void fitBounds​(LatLongBounds bounds)
      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

      public void panToBounds​(LatLongBounds bounds)
    • boundsProperty

      public final javafx.beans.property.ReadOnlyObjectProperty<LatLongBounds> 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

      public void addMarker​(Marker marker)
      Adds the supplied marker to the map.
      Parameters:
      marker -
    • removeMarker

      public void removeMarker​(Marker marker)
      Removes the supplied marker from the map.
      Parameters:
      marker -
    • clearMarkers

      public void clearMarkers()
      Removes all of the markers from the map.
    • addMarkers

      public void addMarkers​(Collection<Marker> col)
      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

      public void removeMarkers​(Collection<Marker> col)
      Removes the markers in the supplied collection from the map.
      Parameters:
      col -
    • setMapType

      public void setMapType​(MapTypeIdEnum type)
      Sets the map type. This is equivalent to the javascript method setMapTypeId.
      Parameters:
      type -
    • addMapShape

      public void addMapShape​(MapShape shape)
    • removeMapShape

      public void removeMapShape​(MapShape shape)
    • getProjection

      public Projection 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

      public void panTo​(LatLong latLong)
      Pans the map to the specified latitude and longitude.
      Parameters:
      latLong -
    • fromLatLngToPoint

      public javafx.geometry.Point2D fromLatLngToPoint​(LatLong loc)
      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

      public void addUIEventHandler​(UIEventType type, UIEventHandler h)
      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

      public void addUIEventHandler​(JavascriptObject obj, UIEventType type, UIEventHandler h)
      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

      public void addMouseEventHandler​(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.
      Parameters:
      type - The type of event to listen for
      h - The MouseEventHandler that will handle the event.
    • addUIHandler

      protected void addUIHandler​(JavascriptObject obj, UIEventType type, GFXEventHandler h)
    • addStateEventHandler

      public void addStateEventHandler​(MapStateEventType type, StateEventHandler h)
      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.