PageRenderTime 112ms CodeModel.GetById 96ms RepoModel.GetById 0ms app.codeStats 0ms

/django/contrib/gis/maps/google/__init__.py

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