<s> from django . conf import settings <EOL> from django . contrib . gis import geos <EOL> from django . template . loader import render_to_string <EOL> from django . utils . safestring import mark_safe <EOL> class GoogleMapException ( Exception ) : pass <EOL> from django . contrib . gis . maps . google . overlays import GPolygon , GPolyline , GMarker <EOL> GOOGLE_MAPS_URL = '<STR_LIT>' <EOL> class GoogleMap ( object ) : <EOL> "<STR_LIT>" <EOL> onunload = mark_safe ( '<STR_LIT>' ) <EOL> vml_css = mark_safe ( '<STR_LIT>' ) <EOL> xmlns = mark_safe ( '<STR_LIT>' ) <EOL> def __init__ ( self , key = None , api_url = None , version = None , <EOL> center = None , zoom = None , dom_id = '<STR_LIT>' , load_func = '<STR_LIT>' , <EOL> kml_urls = [ ] , polygons = [ ] , polylines = [ ] , markers = [ ] , <EOL> template = '<STR_LIT>' , <EOL> extra_context = { } ) : <EOL> if not key : <EOL> try : <EOL> self . key = settings . GOOGLE_MAPS_API_KEY <EOL> except AttributeError : <EOL> raise GoogleMapException ( '<STR_LIT>' ) <EOL> else : <EOL> self . key = key <EOL> if not version : <EOL> self . version = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> self . version = version <EOL> if not api_url : <EOL> self . api_url = mark_safe ( getattr ( settings , '<STR_LIT>' , GOOGLE_MAPS_URL ) % self . version ) <EOL> else : <EOL> self . api_url = api_url <EOL> self . dom_id = dom_id <EOL> self . load_func = load_func <EOL> self . template = template <EOL> self . kml_urls = kml_urls <EOL> self . polygons , self . polylines , self . markers = [ ] , [ ] , [ ] <EOL> if markers : <EOL> for point in markers : <EOL> if isinstance ( point , GMarker ) : <EOL> self . markers . append ( point ) <EOL> else : <EOL> self . markers . append ( GMarker ( point ) ) <EOL> if polygons : <EOL> for poly in polygons : <EOL> if isinstance ( poly , GPolygon ) : <EOL> self . polygons . append ( poly ) <EOL> else : <EOL> self . polygons . append ( GPolygon ( poly ) ) <EOL> if polylines : <EOL> for pline in polylines : <EOL> if isinstance ( pline , GPolyline ) : <EOL> self . polylines . append ( pline ) <EOL> else : <EOL> self . polylines . append ( GPolyline ( pline ) ) <EOL> self . calc_zoom = False <EOL> if self . polygons or self . polylines or self . markers : <EOL> if center is None or zoom is None : <EOL> self . calc_zoom = True <EOL> if zoom is None : zoom = <NUM_LIT:4> <EOL> self . zoom = zoom <EOL> if center is None : center = ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . center = center <EOL> params = { '<STR_LIT>' : self . calc_zoom , <EOL> '<STR_LIT>' : self . center , <EOL> '<STR_LIT>' : self . dom_id , <EOL> '<STR_LIT>' : self . kml_urls , <EOL> '<STR_LIT>' : self . load_func , <EOL> '<STR_LIT>' : self . zoom , <EOL> '<STR_LIT>' : self . polygons , <EOL> '<STR_LIT>' : self . polylines , <EOL> '<STR_LIT>' : self . markers , <EOL> } <EOL> params . update ( extra_context ) <EOL> self . js = render_to_string ( self . template , params ) <EOL> @ property <EOL> def body ( self ) : <EOL> "<STR_LIT>" <EOL> return mark_safe ( '<STR_LIT>' % ( self . onload , self . onunload ) ) <EOL> @ property <EOL> def onload ( self ) : <EOL> "<STR_LIT>" <EOL> return mark_safe ( '<STR_LIT>' % self . load_func ) <EOL> @ property <EOL> def api_script ( self ) : <EOL> "<STR_LIT>" <EOL> return mark_safe ( '<STR_LIT>' % ( self . api_url , self . key ) ) <EOL> @ property <EOL> def scripts ( self ) : <EOL> "<STR_LIT>" <EOL> return mark_safe ( '<STR_LIT>' % ( self . api_script , self . js ) ) <EOL> @ property <EOL> def style ( self ) : <EOL> "<STR_LIT>" <EOL> return mark_safe ( '<STR_LIT>' % self . vml_css ) <EOL> @ property <EOL> def xhtml ( self ) : <EOL> "<STR_LIT>" <EOL> return mark_safe ( '<STR_LIT>' % self . xmlns ) </s>
