def test_format_LatLng(self): self.assertEqual(_format_LatLng(45.123456, -80.987654, 6), 'new google.maps.LatLng(45.123456, -80.987654)') self.assertEqual(_format_LatLng(45.123456, -80.987654, 4), 'new google.maps.LatLng(45.1235, -80.9877)') self.assertEqual(_format_LatLng(45.1, -80.9, 3), 'new google.maps.LatLng(45.100, -80.900)')
def __init__(self, lat, lng, zoom, precision, **kwargs): ''' Args: lat (float): Latitude of the center of the map. lng (float): Longitude of the center of the map. zoom (int): `Zoom level`_, where 0 is fully zoomed out. precision (int): Number of digits after the decimal to round to for the lat/lng center. Optional: Args: map_type (str): `Map type`_. map_styles ([dict]): `Map styles`_. Requires `Maps JavaScript API`_. tilt (int): `Tilt`_ of the map upon zooming in. scale_control (bool): Whether or not to display the `scale control`_. fit_bounds (dict): Fit the map to contain the given bounds, as a dict of the form ``{'north': float, 'south': float, 'east': float, 'west': float}``. .. _Zoom level: https://developers.google.com/maps/documentation/javascript/tutorial#zoom-levels .. _Map type: https://developers.google.com/maps/documentation/javascript/maptypes .. _Map styles: https://developers.google.com/maps/documentation/javascript/style-reference .. _Maps JavaScript API: https://console.cloud.google.com/marketplace/details/google/maps-backend.googleapis.com .. _Tilt: https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.tilt .. _scale control: https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.scaleControl ''' self._center = _format_LatLng(lat, lng, precision) self._zoom = zoom self._map_type = kwargs.get('map_type') self._map_styles = kwargs.get('map_styles') self._tilt = kwargs.get('tilt') self._scale_control = kwargs.get('scale_control') self._fit_bounds = kwargs.get('fit_bounds')
def __init__(self, lat, lng, radius, **kwargs): ''' Args: lat (float): Latitude of the center of the circle. lng (float): Longitude of the center of the circle. radius (int): Radius of the circle, in meters. Optional: Args: color/c/edge_color/ec (str): Color of the circle's edge. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). Defaults to black. alpha/edge_alpha/ea (float): Opacity of the circle's edge, ranging from 0 to 1. Defaults to 1.0. edge_width/ew (int): Width of the circle's edge, in pixels. Defaults to 1. color/c/face_color/fc (str): Color of the circle's face. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). Defaults to black. alpha/face_alpha/fa (float): Opacity of the circle's face, ranging from 0 to 1. Defaults to 0.5. precision (int): Number of digits after the decimal to round to for lat/lng values. Defaults to 6. ''' precision = _get_value(kwargs, ['precision'], 6) self._center = _format_LatLng(lat, lng, precision) self._radius = radius self._edge_color = _get_hex_color(_get_value(kwargs, ['color', 'c', 'edge_color', 'ec'], 'black')) self._edge_alpha = _get_value(kwargs, ['alpha', 'edge_alpha', 'ea'], 1.0) self._edge_width = _get_value(kwargs, ['edge_width', 'ew'], 1) self._face_color = _get_hex_color(_get_value(kwargs, ['color', 'c', 'face_color', 'fc'], 'black')) self._face_alpha = _get_value(kwargs, ['alpha', 'face_alpha', 'fa'], 0.5)
def __init__(self, lat, lng, radius, precision, **kwargs): ''' Args: lat (float): Latitude of the center of the circle. lng (float): Longitude of the center of the circle. radius (int): Radius of the circle, in meters. precision (int): Number of digits after the decimal to round to for lat/lng values. Optional: Args: edge_color (str): Color of the circle's edge. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). edge_alpha (float): Opacity of the circle's edge, ranging from 0 to 1. edge_width (int): Width of the circle's edge, in pixels. face_color (str): Color of the circle's face. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). face_alpha (float): Opacity of the circle's face, ranging from 0 to 1. ''' self._center = _format_LatLng(lat, lng, precision) self._radius = radius edge_color = kwargs.get('edge_color') self._edge_color = _get_hex_color( edge_color) if edge_color is not None else None self._edge_alpha = kwargs.get('edge_alpha') self._edge_width = kwargs.get('edge_width') face_color = kwargs.get('face_color') self._face_color = _get_hex_color( face_color) if face_color is not None else None self._face_alpha = kwargs.get('face_alpha')
def __init__(self, lats, lngs, precision, **kwargs): ''' Args: lats ([float]): Latitudes. lngs ([float]): Longitudes. precision (int): Number of digits after the decimal to round to for lat/lng values. Optional: Args: edge_color (str): Color of the polygon's edge. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). edge_alpha (float): Opacity of the polygon's edge, ranging from 0 to 1. edge_width (int): Width of the polygon's edge, in pixels. face_color (str): Color of the polygon's face. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). face_alpha (float): Opacity of the polygon's face, ranging from 0 to 1. ''' self._points = [ _format_LatLng(lat, lng, precision) for lat, lng in zip(lats, lngs) ] edge_color = kwargs.get('edge_color') self._edge_color = _get_hex_color( edge_color) if edge_color is not None else None self._edge_alpha = kwargs.get('edge_alpha') self._edge_width = kwargs.get('edge_width') face_color = kwargs.get('face_color') self._face_color = _get_hex_color( face_color) if face_color is not None else None self._face_alpha = kwargs.get('face_alpha')
def __init__(self, lats, lngs, **kwargs): ''' Args: lats ([float]): Latitudes. lngs ([float]): Longitudes. Optional: Args: radius (int): Radius of influence for each data point, in pixels. Defaults to 10. gradient ([(int, int, int, float)]): Color gradient of the heatmap, as a list of `RGBA`_ colors. The color order defines the gradient moving towards the center of a point. opacity (float): Opacity of the heatmap, ranging from 0 to 1. Defaults to 0.6. max_intensity (int): Maximum intensity of the heatmap. Defaults to 1. dissipating (bool): True to dissipate the heatmap on zooming, False to disable dissipation. Defaults to True. precision (int): Number of digits after the decimal to round to for lat/lng values. Defaults to 6. weights ([float]): List of weights corresponding to each data point. Each point has a weight of 1 by default. Specifying a weight of N is equivalent to plotting the same point N times. .. _RGBA: https://www.w3.org/TR/css-color-3/#rgba-color ''' self._radius = _get_value(kwargs, ['radius'], 10) self._gradient = _get_value(kwargs, ['gradient'], []) self._opacity = _get_value(kwargs, ['opacity'], 0.6) self._max_intensity = _get_value(kwargs, ['max_intensity'], 1) self._dissipating = _get_value(kwargs, ['dissipating'], True) precision = _get_value(kwargs, ['precision'], 6) weights = _get_value(kwargs, ['weights'], [self._DEFAULT_WEIGHT] * len(lats)) self._points = [ self._Point(_format_LatLng(lat, lng, precision), weight) for lat, lng, weight in zip(lats, lngs, weights) ]
def __init__(self, lat, lng, **kwargs): ''' Args: lat (float): Latitude of the marker. lng (float): Longitude of the marker. Optional: Args: color/c/face_color/fc (str): Marker color. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). Defaults to red. title (str): Hover-over title of the marker. label (str): Label displayed on the marker. info_window (str): HTML content to be displayed in a pop-up `info window`_. draggable (bool): Whether or not the marker is `draggable`_. Defaults to False. precision (int): Number of digits after the decimal to round to for lat/lng values. Defaults to 6. .. _info window: https://developers.google.com/maps/documentation/javascript/infowindows .. _draggable: https://developers.google.com/maps/documentation/javascript/markers#draggable ''' color = _get_hex_color( _get_value(kwargs, ['color', 'c', 'face_color', 'fc'], 'red', pop=True)) self._marker_icon = _MarkerIcon(color) self._info_window = _get_value(kwargs, ['info_window'], pop=True) if self._info_window is not None: self._marker_info_window = _MarkerInfoWindow(self._info_window) precision = _get_value(kwargs, ['precision'], 6, pop=True) self._raw_marker = _RawMarker(_format_LatLng(lat, lng, precision), self._marker_icon.get_name(), **kwargs)
def __init__(self, lat, lng, color, precision, **kwargs): ''' Args: lat (float): Latitude of the marker. lng (float): Longitude of the marker. color (str): Marker color. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). precision (int): Number of digits after the decimal to round to for lat/lng values. Optional: Args: title (str): Hover-over title of the marker. label (str): Label displayed on the marker. info_window (str): HTML content to be displayed in a pop-up `info window`_. draggable (bool): Whether or not the marker is `draggable`_. .. _info window: https://developers.google.com/maps/documentation/javascript/infowindows .. _draggable: https://developers.google.com/maps/documentation/javascript/markers#draggable ''' self._marker_icon = _MarkerIcon(color) info_window = kwargs.pop('info_window', None) self._marker_info_window = _MarkerInfoWindow( info_window) if info_window is not None else None self._raw_marker = _RawMarker(_format_LatLng(lat, lng, precision), self._marker_icon.get_name(), **kwargs)
def __init__(self, lats, lngs, **kwargs): ''' Args: lats ([float]): Latitudes. lngs ([float]): Longitudes. Optional: Args: color/c/edge_color/ec (str): Color of the polyline. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). Defaults to black. alpha/edge_alpha/ea (float): Opacity of the polyline, ranging from 0 to 1. Defaults to 1.0. edge_width/ew (int): Width of the polyline, in pixels. Defaults to 1. precision (int): Number of digits after the decimal to round to for lat/lng values. Defaults to 6. ''' self._color = _get_hex_color( _get_value(kwargs, ['color', 'c', 'edge_color', 'ec'], 'black')) self._edge_alpha = _get_value(kwargs, ['alpha', 'edge_alpha', 'ea'], 1.0) self._edge_width = _get_value(kwargs, ['edge_width', 'ew'], 1) precision = _get_value(kwargs, ['precision'], 6) self._points = [ _format_LatLng(lat, lng, precision) for lat, lng in zip(lats, lngs) ]
def __init__(self, origin, destination, precision, **kwargs): ''' Args: origin ((float, float)): Origin, as a latitude/longitude tuple. destination ((float, float)): Destination, as a latitude/longitude tuple. precision (int): Number of digits after the decimal to round to for lat/lng values. Optional: Args: travel_mode (str): Travel mode. waypoints ([(float, float)]): Waypoints. ''' self._origin = _format_LatLng(*origin, precision=precision) self._destination = _format_LatLng(*destination, precision=precision) self._travel_mode = kwargs.get('travel_mode') self._waypoints = [_format_LatLng(*waypoint, precision=precision) for waypoint in _get(kwargs, ['waypoints'], [])]
def __init__(self, origin, destination, **kwargs): ''' Args: origin ((float, float)): Origin, as a latitude/longitude tuple. destination ((float, float)): Destination, as a latitude/longitude tuple. Optional: Args: travel_mode (str): Travel mode. Defaults to 'DRIVING'. waypoints ([(float, float)]): Waypoints. precision (int): Number of digits after the decimal to round to for lat/lng values. Defaults to 6. ''' precision = _get_value(kwargs, ['precision'], 6) self._origin = _format_LatLng(*origin, precision=precision) self._destination = _format_LatLng(*destination, precision=precision) self._travel_mode = _get_value(kwargs, ['travel_mode'], 'DRIVING').upper() self._waypoints = [ _format_LatLng(*waypoint, precision=precision) for waypoint in _get_value(kwargs, ['waypoints'], []) ]
def __init__(self, lat, lng, text, precision, **kwargs): ''' Args: lat (float): Latitude of the text label. lng (float): Longitude of the text label. text (str): Text to display. precision (int): Number of digits after the decimal to round to for lat/lng values. Optional: Args: color (str): Text color. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). ''' self._position = _format_LatLng(lat, lng, precision) self._text = text color = kwargs.get('color') self._color = _get_hex_color(color) if color is not None else None self._icon = _get_embeddable_image(_COLOR_ICON_PATH % 'clear')
def __init__(self, lat, lng, text, **kwargs): ''' Args: lat (float): Latitude of the text label. lng (float): Longitude of the text label. text (str): Text to display. Optional: Args: color/c (str): Text color. Can be hex ('#00FFFF'), named ('cyan'), or matplotlib-like ('c'). Defaults to black. precision (int): Number of digits after the decimal to round to for lat/lng values. Defaults to 6. ''' precision = _get_value(kwargs, ['precision'], 6) self._position = _format_LatLng(lat, lng, precision) self._text = text self._color = _get_hex_color( _get_value(kwargs, ['color', 'c'], 'black')) self._icon = _get_embeddable_image(_COLOR_ICON_PATH % 'clear')