| 25 | | def __init__(self, key=None, api_url=None, version=None, |
|---|
| 26 | | center=None, center_lat=0.0, center_lon=0.0, |
|---|
| 27 | | zoom=None, dom_id='map', load_func='gmap_load', |
|---|
| | 21 | def __init__(self, key=None, api_url=None, version=None, |
|---|
| | 22 | center=None, zoom=None, dom_id='map', load_func='gmap_load', |
|---|
| 78 | | # Automatically determining the zoom level if there are |
|---|
| 79 | | # GPolygon and/or GPolyline overlays. |
|---|
| 80 | | if (self.polygons or self.polylines) and zoom is None: |
|---|
| 81 | | envelopes = [p.envelope for p in self.polygons] |
|---|
| 82 | | envelopes.extend([p.envelope for p in self.polylines]) |
|---|
| 83 | | # Creating a MultiPolygon of all the envelopes, this will |
|---|
| 84 | | # be used in determining the zoom level. |
|---|
| 85 | | zoom = geos.MultiPolygon(envelopes) |
|---|
| 86 | | zoom.srid = 4326 |
|---|
| 87 | | |
|---|
| 88 | | # If a GEOSGeometry object is passed in for the `zoom` keyword |
|---|
| 89 | | # argument, then try to automatically determine an appropriate |
|---|
| 90 | | # zoom level. |
|---|
| 91 | | if isinstance(zoom, geos.GEOSGeometry): |
|---|
| 92 | | self.zoom = GZOOM.get_zoom(zoom) |
|---|
| 93 | | else: |
|---|
| 94 | | self.zoom = zoom |
|---|
| 95 | | |
|---|
| 96 | | # The map center coordinate -- the `center_lon` and `center_lat` keyword |
|---|
| 97 | | # are deprecated. |
|---|
| 98 | | if not center: |
|---|
| 99 | | center = (center_lon, center_lat) |
|---|
| | 73 | # If GPolygons and/or GPolylines are used the zoom will be automatically |
|---|
| | 74 | # calculated via the Google Maps API. If both a zoom level and a |
|---|
| | 75 | # center coordinate are provided with polygons/polylines, no automatic |
|---|
| | 76 | # determination will occur. |
|---|
| | 77 | self.calc_zoom = False |
|---|
| | 78 | if self.polygons or self.polylines: |
|---|
| | 79 | if center is None or zoom is None: |
|---|
| | 80 | self.calc_zoom = True |
|---|
| | 81 | |
|---|
| | 82 | # Defaults for the zoom level and center coordinates if the zoom |
|---|
| | 83 | # is not automatically calculated. |
|---|
| | 84 | if zoom is None: zoom = 4 |
|---|
| | 85 | self.zoom = zoom |
|---|
| | 86 | if center is None: center = (0, 0) |
|---|