app/django/contrib/gis/maps/google/__init__.py
changeset 323 ff1a9aa48cfd
equal deleted inserted replaced
322:6641e941ef1e 323:ff1a9aa48cfd
       
     1 """
       
     2   This module houses the GoogleMap object, used for generating
       
     3    the needed javascript to embed Google Maps in a webpage.
       
     4 
       
     5   Google(R) is a registered trademark of Google, Inc. of Mountain View, California.
       
     6 
       
     7   Example:
       
     8 
       
     9    * In the view:
       
    10       return render_to_response('template.html', {'google' : GoogleMap(key="abcdefg")})
       
    11 
       
    12    * In the template:
       
    13 
       
    14      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
    15      {{ google.xhtml }}
       
    16      <head>
       
    17        <title>Google Maps via GeoDjango</title>
       
    18        {{ google.style }}
       
    19        {{ google.scripts }}
       
    20      </head>
       
    21      {{ google.body }}
       
    22      <div id="{{ google.dom_id }}" style="width:600px;height:400px;"></div>
       
    23      </body>
       
    24      </html>
       
    25 
       
    26      Note:  If you want to be more explicit in your templates, the following are
       
    27       equivalent:
       
    28       {{ google.body }} => "<body {{ google.onload }} {{ google.onunload }}>"
       
    29       {{ google.xhtml }} => "<html xmlns="http://www.w3.org/1999/xhtml" {{ google.xmlns }}>"
       
    30       {{ google.style }} => "<style>{{ google.vml_css }}</style>"
       
    31 
       
    32   Explanation:
       
    33    - The `xhtml` property provides the correct XML namespace needed for 
       
    34      Google Maps to operate in IE using XHTML.  Google Maps on IE uses
       
    35      VML to draw polylines.  Returns, by default: 
       
    36      <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
       
    37        
       
    38    - The `style` property provides the correct style tag for the CSS
       
    39      properties required by Google Maps on IE:
       
    40      <style type="text/css">v\:* {behavior:url(#default#VML);}</style>
       
    41 
       
    42    - The `scripts` property provides the necessary <script> tags for 
       
    43      including the Google Maps javascript, as well as including the
       
    44      generated javascript.
       
    45 
       
    46    - The `body` property provides the correct attributes for the 
       
    47      body tag to load the generated javascript.  By default, returns:
       
    48      <body onload="gmap_load()" onunload="GUnload()">
       
    49 
       
    50    - The `dom_id` property returns the DOM id for the map.  Defaults to "map".
       
    51 
       
    52   The following attributes may be set or customized in your local settings:
       
    53    * GOOGLE_MAPS_API_KEY: String of your Google Maps API key.  These are tied to
       
    54       to a domain.  May be obtained from http://www.google.com/apis/maps/
       
    55    * GOOGLE_MAPS_API_VERSION (optional): Defaults to using "2.x"
       
    56    * GOOGLE_MAPS_URL (optional): Must have a substitution ('%s') for the API
       
    57       version.
       
    58 """
       
    59 from django.contrib.gis.maps.google.gmap import GoogleMap
       
    60 from django.contrib.gis.maps.google.overlays import GEvent, GMarker, GPolygon, GPolyline
       
    61 from django.contrib.gis.maps.google.zoom import GoogleZoom