Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
5a51b449
Kaydet (Commit)
5a51b449
authored
Eyl 15, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26697 -- Removed contrib.gis.maps.
üst
727d7ce6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
4 additions
and
595 deletions
+4
-595
__init__.py
django/contrib/gis/maps/__init__.py
+0
-0
__init__.py
django/contrib/gis/maps/google/__init__.py
+0
-69
gmap.py
django/contrib/gis/maps/google/gmap.py
+0
-244
overlays.py
django/contrib/gis/maps/google/overlays.py
+0
-0
zoom.py
django/contrib/gis/maps/google/zoom.py
+0
-166
__init__.py
django/contrib/gis/maps/openlayers/__init__.py
+0
-0
google-map.html
django/contrib/gis/templates/gis/google/google-map.html
+0
-12
google-map.js
django/contrib/gis/templates/gis/google/google-map.js
+0
-37
google-multi.js
django/contrib/gis/templates/gis/google/google-multi.js
+0
-8
google-single.js
django/contrib/gis/templates/gis/google/google-single.js
+0
-2
1.11.txt
docs/releases/1.11.txt
+4
-0
tests.py
tests/gis_tests/maps/tests.py
+0
-57
No files found.
django/contrib/gis/maps/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
django/contrib/gis/maps/google/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
"""
This module houses the GoogleMap object, used for generating
the needed javascript to embed Google Maps in a Web page.
Google(R) is a registered trademark of Google, Inc. of Mountain View, California.
Example:
* In the view:
return render(request, 'template.html', {'google': GoogleMap(key="abcdefg")})
* In the template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{{ google.xhtml }}
<head>
<title>Google Maps via GeoDjango</title>
{{ google.style }}
{{ google.scripts }}
</head>
{{ google.body }}
<div id="{{ google.dom_id }}" style="width:600px;height:400px;"></div>
</body>
</html>
Note: If you want to be more explicit in your templates, the following are
equivalent:
{{ google.body }} => "<body {{ google.onload }} {{ google.onunload }}>"
{{ google.xhtml }} => "<html xmlns="http://www.w3.org/1999/xhtml" {{ google.xmlns }}>"
{{ google.style }} => "<style>{{ google.vml_css }}</style>"
Explanation:
- The `xhtml` property provides the correct XML namespace needed for
Google Maps to operate in IE using XHTML. Google Maps on IE uses
VML to draw polylines. Returns, by default:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
- The `style` property provides the correct style tag for the CSS
properties required by Google Maps on IE:
<style type="text/css">v
\
:* {behavior:url(#default#VML);}</style>
- The `scripts` property provides the necessary <script> tags for
including the Google Maps javascript, as well as including the
generated javascript.
- The `body` property provides the correct attributes for the
body tag to load the generated javascript. By default, returns:
<body onload="gmap_load()" onunload="GUnload()">
- The `dom_id` property returns the DOM id for the map. Defaults to "map".
The following attributes may be set or customized in your local settings:
* GOOGLE_MAPS_API_KEY: String of your Google Maps API key. These are tied
to a domain. May be obtained from https://developers.google.com/maps/
* GOOGLE_MAPS_API_VERSION (optional): Defaults to using "2.x"
* GOOGLE_MAPS_URL (optional): Must have a substitution ('
%
s') for the API
version.
"""
from
django.contrib.gis.maps.google.gmap
import
GoogleMap
,
GoogleMapSet
from
django.contrib.gis.maps.google.overlays
import
(
GEvent
,
GIcon
,
GMarker
,
GPolygon
,
GPolyline
,
)
from
django.contrib.gis.maps.google.zoom
import
GoogleZoom
__all__
=
[
'GoogleMap'
,
'GoogleMapSet'
,
'GEvent'
,
'GIcon'
,
'GMarker'
,
'GPolygon'
,
'GPolyline'
,
'GoogleZoom'
,
]
django/contrib/gis/maps/google/gmap.py
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
from
__future__
import
unicode_literals
from
django.conf
import
settings
from
django.contrib.gis.maps.google.overlays
import
(
GMarker
,
GPolygon
,
GPolyline
,
)
from
django.template.loader
import
render_to_string
from
django.utils.html
import
format_html
from
django.utils.safestring
import
mark_safe
from
django.utils.six.moves
import
range
class
GoogleMapException
(
Exception
):
pass
# The default Google Maps URL (for the API javascript)
# TODO: Internationalize for Japan, UK, etc.
GOOGLE_MAPS_URL
=
'http://maps.google.com/maps?file=api&v=
%
s&key='
class
GoogleMap
(
object
):
"A class for generating Google Maps JavaScript."
# String constants
onunload
=
mark_safe
(
'onunload="GUnload()"'
)
# Cleans up after Google Maps
vml_css
=
mark_safe
(
'v
\
:* {behavior:url(#default#VML);}'
)
# CSS for IE VML
xmlns
=
mark_safe
(
'xmlns:v="urn:schemas-microsoft-com:vml"'
)
# XML Namespace (for IE VML).
def
__init__
(
self
,
key
=
None
,
api_url
=
None
,
version
=
None
,
center
=
None
,
zoom
=
None
,
dom_id
=
'map'
,
kml_urls
=
[],
polylines
=
None
,
polygons
=
None
,
markers
=
None
,
template
=
'gis/google/google-map.js'
,
js_module
=
'geodjango'
,
extra_context
=
{}):
# The Google Maps API Key defined in the settings will be used
# if not passed in as a parameter. The use of an API key is
# _required_.
if
not
key
:
try
:
self
.
key
=
settings
.
GOOGLE_MAPS_API_KEY
except
AttributeError
:
raise
GoogleMapException
(
'Google Maps API Key not found (try adding '
'GOOGLE_MAPS_API_KEY to your settings).'
)
else
:
self
.
key
=
key
# Getting the Google Maps API version, defaults to using the latest ("2.x"),
# this is not necessarily the most stable.
if
not
version
:
self
.
version
=
getattr
(
settings
,
'GOOGLE_MAPS_API_VERSION'
,
'2.x'
)
else
:
self
.
version
=
version
# Can specify the API URL in the `api_url` keyword.
if
not
api_url
:
self
.
api_url
=
getattr
(
settings
,
'GOOGLE_MAPS_URL'
,
GOOGLE_MAPS_URL
)
%
self
.
version
else
:
self
.
api_url
=
api_url
# Setting the DOM id of the map, the load function, the JavaScript
# template, and the KML URLs array.
self
.
dom_id
=
dom_id
self
.
extra_context
=
extra_context
self
.
js_module
=
js_module
self
.
template
=
template
self
.
kml_urls
=
kml_urls
# Does the user want any GMarker, GPolygon, and/or GPolyline overlays?
overlay_info
=
[[
GMarker
,
markers
,
'markers'
],
[
GPolygon
,
polygons
,
'polygons'
],
[
GPolyline
,
polylines
,
'polylines'
]]
for
overlay_class
,
overlay_list
,
varname
in
overlay_info
:
setattr
(
self
,
varname
,
[])
if
overlay_list
:
for
overlay
in
overlay_list
:
if
isinstance
(
overlay
,
overlay_class
):
getattr
(
self
,
varname
)
.
append
(
overlay
)
else
:
getattr
(
self
,
varname
)
.
append
(
overlay_class
(
overlay
))
# If GMarker, GPolygons, and/or GPolylines are used the zoom will be
# automatically calculated via the Google Maps API. If both a zoom
# level and a center coordinate are provided with polygons/polylines,
# no automatic determination will occur.
self
.
calc_zoom
=
False
if
self
.
polygons
or
self
.
polylines
or
self
.
markers
:
if
center
is
None
or
zoom
is
None
:
self
.
calc_zoom
=
True
# Defaults for the zoom level and center coordinates if the zoom
# is not automatically calculated.
if
zoom
is
None
:
zoom
=
4
self
.
zoom
=
zoom
if
center
is
None
:
center
=
(
0
,
0
)
self
.
center
=
center
def
render
(
self
):
"""
Generates the JavaScript necessary for displaying this Google Map.
"""
params
=
{
'calc_zoom'
:
self
.
calc_zoom
,
'center'
:
self
.
center
,
'dom_id'
:
self
.
dom_id
,
'js_module'
:
self
.
js_module
,
'kml_urls'
:
self
.
kml_urls
,
'zoom'
:
self
.
zoom
,
'polygons'
:
self
.
polygons
,
'polylines'
:
self
.
polylines
,
'icons'
:
self
.
icons
,
'markers'
:
self
.
markers
,
}
params
.
update
(
self
.
extra_context
)
return
render_to_string
(
self
.
template
,
params
)
@property
def
body
(
self
):
"Returns HTML body tag for loading and unloading Google Maps javascript."
return
format_html
(
'<body {} {}>'
,
self
.
onload
,
self
.
onunload
)
@property
def
onload
(
self
):
"Returns the `onload` HTML <body> attribute."
return
format_html
(
'onload="{}.{}_load()"'
,
self
.
js_module
,
self
.
dom_id
)
@property
def
api_script
(
self
):
"Returns the <script> tag for the Google Maps API javascript."
return
format_html
(
'<script src="{}{}" type="text/javascript"></script>'
,
self
.
api_url
,
self
.
key
)
@property
def
js
(
self
):
"Returns only the generated Google Maps JavaScript (no <script> tags)."
return
self
.
render
()
@property
def
scripts
(
self
):
"Returns all <script></script> tags required with Google Maps JavaScript."
return
format_html
(
'{}
\n
<script type="text/javascript">
\n
//<![CDATA[
\n
{}//]]>
\n
</script>'
,
self
.
api_script
,
mark_safe
(
self
.
js
))
@property
def
style
(
self
):
"Returns additional CSS styling needed for Google Maps on IE."
return
format_html
(
'<style type="text/css">{}</style>'
,
self
.
vml_css
)
@property
def
xhtml
(
self
):
"Returns XHTML information needed for IE VML overlays."
return
format_html
(
'<html xmlns="http://www.w3.org/1999/xhtml" {}>'
,
self
.
xmlns
)
@property
def
icons
(
self
):
"Returns a sequence of GIcon objects in this map."
return
set
(
marker
.
icon
for
marker
in
self
.
markers
if
marker
.
icon
)
class
GoogleMapSet
(
GoogleMap
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
"""
A class for generating sets of Google Maps that will be shown on the
same page together.
Example:
gmapset = GoogleMapSet( GoogleMap( ... ), GoogleMap( ... ) )
gmapset = GoogleMapSet( [ gmap1, gmap2] )
"""
# The `google-multi.js` template is used instead of `google-single.js`
# by default.
template
=
kwargs
.
pop
(
'template'
,
'gis/google/google-multi.js'
)
# This is the template used to generate the GMap load JavaScript for
# each map in the set.
self
.
map_template
=
kwargs
.
pop
(
'map_template'
,
'gis/google/google-single.js'
)
# Running GoogleMap.__init__(), and resetting the template
# value with default obtained above.
super
(
GoogleMapSet
,
self
)
.
__init__
(
**
kwargs
)
self
.
template
=
template
# If a tuple/list passed in as first element of args, then assume
if
isinstance
(
args
[
0
],
(
tuple
,
list
)):
self
.
maps
=
args
[
0
]
else
:
self
.
maps
=
args
# Generating DOM ids for each of the maps in the set.
self
.
dom_ids
=
[
'map
%
d'
%
i
for
i
in
range
(
len
(
self
.
maps
))]
def
load_map_js
(
self
):
"""
Returns JavaScript containing all of the loading routines for each
map in this set.
"""
result
=
[]
for
dom_id
,
gmap
in
zip
(
self
.
dom_ids
,
self
.
maps
):
# Backup copies the GoogleMap DOM id and template attributes.
# They are overridden on each GoogleMap instance in the set so
# that only the loading JavaScript (and not the header variables)
# is used with the generated DOM ids.
tmp
=
(
gmap
.
template
,
gmap
.
dom_id
)
gmap
.
template
=
self
.
map_template
gmap
.
dom_id
=
dom_id
result
.
append
(
gmap
.
js
)
# Restoring the backup values.
gmap
.
template
,
gmap
.
dom_id
=
tmp
return
mark_safe
(
''
.
join
(
result
))
def
render
(
self
):
"""
Generates the JavaScript for the collection of Google Maps in
this set.
"""
params
=
{
'js_module'
:
self
.
js_module
,
'dom_ids'
:
self
.
dom_ids
,
'load_map_js'
:
self
.
load_map_js
(),
'icons'
:
self
.
icons
,
}
params
.
update
(
self
.
extra_context
)
return
render_to_string
(
self
.
template
,
params
)
@property
def
onload
(
self
):
"Returns the `onload` HTML <body> attribute."
# Overloaded to use the `load` function defined in the
# `google-multi.js`, which calls the load routines for
# each one of the individual maps in the set.
return
mark_safe
(
'onload="
%
s.load()"'
%
self
.
js_module
)
@property
def
icons
(
self
):
"Returns a sequence of all icons in each map of the set."
icons
=
set
()
for
map
in
self
.
maps
:
icons
|=
map
.
icons
return
icons
django/contrib/gis/maps/google/overlays.py
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
This diff is collapsed.
Click to expand it.
django/contrib/gis/maps/google/zoom.py
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
from
__future__
import
unicode_literals
from
math
import
atan
,
exp
,
log
,
pi
,
sin
from
django.contrib.gis.geos
import
GEOSGeometry
,
LinearRing
,
Point
,
Polygon
from
django.contrib.gis.maps.google.gmap
import
GoogleMapException
from
django.utils.six.moves
import
range
# Constants used for degree to radian conversion, and vice-versa.
DTOR
=
pi
/
180.
RTOD
=
180.
/
pi
class
GoogleZoom
(
object
):
"""
GoogleZoom is a utility for performing operations related to the zoom
levels on Google Maps.
This class is inspired by the OpenStreetMap Mapnik tile generation routine
`generate_tiles.py`, and the article "How Big Is the World" (Hack #16) in
"Google Maps Hacks" by Rich Gibson and Schuyler Erle.
`generate_tiles.py` may be found at:
http://trac.openstreetmap.org/browser/applications/rendering/mapnik/generate_tiles.py
"Google Maps Hacks" may be found at http://safari.oreilly.com/0596101619
"""
def
__init__
(
self
,
num_zoom
=
19
,
tilesize
=
256
):
"Initializes the Google Zoom object."
# Google's tilesize is 256x256, square tiles are assumed.
self
.
_tilesize
=
tilesize
# The number of zoom levels
self
.
_nzoom
=
num_zoom
# Initializing arrays to hold the parameters for each one of the
# zoom levels.
self
.
_degpp
=
[]
# Degrees per pixel
self
.
_radpp
=
[]
# Radians per pixel
self
.
_npix
=
[]
# 1/2 the number of pixels for a tile at the given zoom level
# Incrementing through the zoom levels and populating the parameter arrays.
z
=
tilesize
# The number of pixels per zoom level.
for
i
in
range
(
num_zoom
):
# Getting the degrees and radians per pixel, and the 1/2 the number of
# for every zoom level.
self
.
_degpp
.
append
(
z
/
360.
)
# degrees per pixel
self
.
_radpp
.
append
(
z
/
(
2
*
pi
))
# radians per pixel
self
.
_npix
.
append
(
z
/
2
)
# number of pixels to center of tile
# Multiplying `z` by 2 for the next iteration.
z
*=
2
def
__len__
(
self
):
"Returns the number of zoom levels."
return
self
.
_nzoom
def
get_lon_lat
(
self
,
lonlat
):
"Unpacks longitude, latitude from GEOS Points and 2-tuples."
if
isinstance
(
lonlat
,
Point
):
lon
,
lat
=
lonlat
.
coords
else
:
lon
,
lat
=
lonlat
return
lon
,
lat
def
lonlat_to_pixel
(
self
,
lonlat
,
zoom
):
"Converts a longitude, latitude coordinate pair for the given zoom level."
# Setting up, unpacking the longitude, latitude values and getting the
# number of pixels for the given zoom level.
lon
,
lat
=
self
.
get_lon_lat
(
lonlat
)
npix
=
self
.
_npix
[
zoom
]
# Calculating the pixel x coordinate by multiplying the longitude value
# with the number of degrees/pixel at the given zoom level.
px_x
=
round
(
npix
+
(
lon
*
self
.
_degpp
[
zoom
]))
# Creating the factor, and ensuring that 1 or -1 is not passed in as the
# base to the logarithm. Here's why:
# if fac = -1, we'll get log(0) which is undefined;
# if fac = 1, our logarithm base will be divided by 0, also undefined.
fac
=
min
(
max
(
sin
(
DTOR
*
lat
),
-
0.9999
),
0.9999
)
# Calculating the pixel y coordinate.
px_y
=
round
(
npix
+
(
0.5
*
log
((
1
+
fac
)
/
(
1
-
fac
))
*
(
-
1.0
*
self
.
_radpp
[
zoom
])))
# Returning the pixel x, y to the caller of the function.
return
(
px_x
,
px_y
)
def
pixel_to_lonlat
(
self
,
px
,
zoom
):
"Converts a pixel to a longitude, latitude pair at the given zoom level."
if
len
(
px
)
!=
2
:
raise
TypeError
(
'Pixel should be a sequence of two elements.'
)
# Getting the number of pixels for the given zoom level.
npix
=
self
.
_npix
[
zoom
]
# Calculating the longitude value, using the degrees per pixel.
lon
=
(
px
[
0
]
-
npix
)
/
self
.
_degpp
[
zoom
]
# Calculating the latitude value.
lat
=
RTOD
*
(
2
*
atan
(
exp
((
px
[
1
]
-
npix
)
/
(
-
1.0
*
self
.
_radpp
[
zoom
])))
-
0.5
*
pi
)
# Returning the longitude, latitude coordinate pair.
return
(
lon
,
lat
)
def
tile
(
self
,
lonlat
,
zoom
):
"""
Returns a Polygon corresponding to the region represented by a fictional
Google Tile for the given longitude/latitude pair and zoom level. This
tile is used to determine the size of a tile at the given point.
"""
# The given lonlat is the center of the tile.
delta
=
self
.
_tilesize
/
2
# Getting the pixel coordinates corresponding to the
# the longitude/latitude.
px
=
self
.
lonlat_to_pixel
(
lonlat
,
zoom
)
# Getting the lower-left and upper-right lat/lon coordinates
# for the bounding box of the tile.
ll
=
self
.
pixel_to_lonlat
((
px
[
0
]
-
delta
,
px
[
1
]
-
delta
),
zoom
)
ur
=
self
.
pixel_to_lonlat
((
px
[
0
]
+
delta
,
px
[
1
]
+
delta
),
zoom
)
# Constructing the Polygon, representing the tile and returning.
return
Polygon
(
LinearRing
(
ll
,
(
ll
[
0
],
ur
[
1
]),
ur
,
(
ur
[
0
],
ll
[
1
]),
ll
),
srid
=
4326
)
def
get_zoom
(
self
,
geom
):
"Returns the optimal Zoom level for the given geometry."
# Checking the input type.
if
not
isinstance
(
geom
,
GEOSGeometry
)
or
geom
.
srid
!=
4326
:
raise
TypeError
(
'get_zoom() expects a GEOS Geometry with an SRID of 4326.'
)
# Getting the envelope for the geometry, and its associated width, height
# and centroid.
env
=
geom
.
envelope
env_w
,
env_h
=
self
.
get_width_height
(
env
.
extent
)
center
=
env
.
centroid
for
z
in
range
(
self
.
_nzoom
):
# Getting the tile at the zoom level.
tile_w
,
tile_h
=
self
.
get_width_height
(
self
.
tile
(
center
,
z
)
.
extent
)
# When we span more than one tile, this is an approximately good
# zoom level.
if
(
env_w
>
tile_w
)
or
(
env_h
>
tile_h
):
if
z
==
0
:
raise
GoogleMapException
(
'Geometry width and height should not exceed that of the Earth.'
)
return
z
-
1
# Otherwise, we've zoomed in to the max.
return
self
.
_nzoom
-
1
def
get_width_height
(
self
,
extent
):
"""
Returns the width and height for the given extent.
"""
# Getting the lower-left, upper-left, and upper-right
# coordinates from the extent.
ll
=
Point
(
extent
[:
2
])
ul
=
Point
(
extent
[
0
],
extent
[
3
])
ur
=
Point
(
extent
[
2
:])
# Calculating the width and height.
height
=
ll
.
distance
(
ul
)
width
=
ul
.
distance
(
ur
)
return
width
,
height
django/contrib/gis/maps/openlayers/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
django/contrib/gis/templates/gis/google/google-map.html
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
{% load i18n %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
{{
gmap
.
xmlns
}}
>
<head>
<title>
{% block title %}{% trans "Google Maps via GeoDjango" %}{% endblock %}
</title>
{{ gmap.style }}
{{ gmap.scripts }}
</head>
<body
{{
gmap
.
onload
}}
{{
gmap
.
onunload
}}
>
{% if gmap.dom_ids %}{% for dom_id in gmap.dom_ids %}
<div
id=
"{{ dom_id }}"
style=
"width:600px;height:400px;"
></div>
{% endfor %}
{% else %}
<div
id=
"{{ gmap.dom_id }}"
style=
"width:600px;height:400px;"
></div>
{% endif %}
</body>
</html>
django/contrib/gis/templates/gis/google/google-map.js
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
{
%
load
l10n
%
}
{
%
autoescape
off
%
}
{
%
localize
off
%
}
{
%
block
vars
%
}
var
geodjango
=
{};{
%
for
icon
in
icons
%
}
var
{{
icon
.
varname
}}
=
new
GIcon
(
G_DEFAULT_ICON
);
{
%
if
icon
.
image
%
}{{
icon
.
varname
}}.
image
=
"{{ icon.image }}"
;{
%
endif
%
}
{
%
if
icon
.
shadow
%
}{{
icon
.
varname
}}.
shadow
=
"{{ icon.shadow }}"
;{
%
endif
%
}
{
%
if
icon
.
shadowsize
%
}{{
icon
.
varname
}}.
shadowSize
=
new
GSize
({{
icon
.
shadowsize
.
0
}},
{{
icon
.
shadowsize
.
1
}});{
%
endif
%
}
{
%
if
icon
.
iconanchor
%
}{{
icon
.
varname
}}.
iconAnchor
=
new
GPoint
({{
icon
.
iconanchor
.
0
}},
{{
icon
.
iconanchor
.
1
}});{
%
endif
%
}
{
%
if
icon
.
iconsize
%
}{{
icon
.
varname
}}.
iconSize
=
new
GSize
({{
icon
.
iconsize
.
0
}},
{{
icon
.
iconsize
.
1
}});{
%
endif
%
}
{
%
if
icon
.
infowindowanchor
%
}{{
icon
.
varname
}}.
infoWindowAnchor
=
new
GPoint
({{
icon
.
infowindowanchor
.
0
}},
{{
icon
.
infowindowanchor
.
1
}});{
%
endif
%
}{
%
endfor
%
}
{
%
endblock
vars
%
}{
%
block
functions
%
}
{
%
block
load
%
}{{
js_module
}}.{{
dom_id
}}
_load
=
function
(){
if
(
GBrowserIsCompatible
())
{
{{
js_module
}}.{{
dom_id
}}
=
new
GMap2
(
document
.
getElementById
(
"{{ dom_id }}"
));
{{
js_module
}}.{{
dom_id
}}.
setCenter
(
new
GLatLng
({{
center
.
1
}},
{{
center
.
0
}}),
{{
zoom
}});
{
%
block
controls
%
}{{
js_module
}}.{{
dom_id
}}.
setUIToDefault
();{
%
endblock
%
}
{
%
if
calc_zoom
%
}
var
bounds
=
new
GLatLngBounds
();
var
tmp_bounds
=
new
GLatLngBounds
();{
%
endif
%
}
{
%
for
kml_url
in
kml_urls
%
}{{
js_module
}}.{{
dom_id
}}
_kml
{{
forloop
.
counter
}}
=
new
GGeoXml
(
"{{ kml_url }}"
);
{{
js_module
}}.{{
dom_id
}}.
addOverlay
({{
js_module
}}.{{
dom_id
}}
_kml
{{
forloop
.
counter
}});{
%
endfor
%
}
{
%
for
polygon
in
polygons
%
}{{
js_module
}}.{{
dom_id
}}
_poly
{{
forloop
.
counter
}}
=
new
{{
polygon
}};
{{
js_module
}}.{{
dom_id
}}.
addOverlay
({{
js_module
}}.{{
dom_id
}}
_poly
{{
forloop
.
counter
}});
{
%
for
event
in
polygon
.
events
%
}
GEvent
.
addListener
({{
js_module
}}.{{
dom_id
}}
_poly
{{
forloop
.
parentloop
.
counter
}},
{{
event
}});{
%
endfor
%
}
{
%
if
calc_zoom
%
}
tmp_bounds
=
{{
js_module
}}.{{
dom_id
}}
_poly
{{
forloop
.
counter
}}.
getBounds
();
bounds
.
extend
(
tmp_bounds
.
getSouthWest
());
bounds
.
extend
(
tmp_bounds
.
getNorthEast
());{
%
endif
%
}{
%
endfor
%
}
{
%
for
polyline
in
polylines
%
}{{
js_module
}}.{{
dom_id
}}
_polyline
{{
forloop
.
counter
}}
=
new
{{
polyline
}};
{{
js_module
}}.{{
dom_id
}}.
addOverlay
({{
js_module
}}.{{
dom_id
}}
_polyline
{{
forloop
.
counter
}});
{
%
for
event
in
polyline
.
events
%
}
GEvent
.
addListener
({{
js_module
}}.{{
dom_id
}}
_polyline
{{
forloop
.
parentloop
.
counter
}},
{{
event
}});
{
%
endfor
%
}
{
%
if
calc_zoom
%
}
tmp_bounds
=
{{
js_module
}}.{{
dom_id
}}
_polyline
{{
forloop
.
counter
}}.
getBounds
();
bounds
.
extend
(
tmp_bounds
.
getSouthWest
());
bounds
.
extend
(
tmp_bounds
.
getNorthEast
());{
%
endif
%
}{
%
endfor
%
}
{
%
for
marker
in
markers
%
}{{
js_module
}}.{{
dom_id
}}
_marker
{{
forloop
.
counter
}}
=
new
{{
marker
}};
{{
js_module
}}.{{
dom_id
}}.
addOverlay
({{
js_module
}}.{{
dom_id
}}
_marker
{{
forloop
.
counter
}});
{
%
for
event
in
marker
.
events
%
}
GEvent
.
addListener
({{
js_module
}}.{{
dom_id
}}
_marker
{{
forloop
.
parentloop
.
counter
}},
{{
event
}});
{
%
endfor
%
}
{
%
if
calc_zoom
%
}
bounds
.
extend
({{
js_module
}}.{{
dom_id
}}
_marker
{{
forloop
.
counter
}}.
getLatLng
());
{
%
endif
%
}{
%
endfor
%
}
{
%
if
calc_zoom
%
}{{
js_module
}}.{{
dom_id
}}.
setCenter
(
bounds
.
getCenter
(),
{{
js_module
}}.{{
dom_id
}}.
getBoundsZoomLevel
(
bounds
));{
%
endif
%
}
{
%
block
load_extra
%
}{
%
endblock
%
}
}
else
{
alert
(
"Sorry, the Google Maps API is not compatible with this browser."
);
}
}
{
%
endblock
load
%
}{
%
endblock
functions
%
}{
%
endlocalize
%
}{
%
endautoescape
%
}
django/contrib/gis/templates/gis/google/google-multi.js
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
{
%
extends
"gis/google/google-map.js"
%
}
{
%
block
functions
%
}
{{
load_map_js
}}
{{
js_module
}}.
load
=
function
(){
{
%
for
dom_id
in
dom_ids
%
}{{
js_module
}}.{{
dom_id
}}
_load
();
{
%
endfor
%
}
}
{
%
endblock
%
}
django/contrib/gis/templates/gis/google/google-single.js
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
{
%
extends
"gis/google/google-map.js"
%
}
{
%
block
vars
%
}{
#
No
vars
here
because
used
within
GoogleMapSet
#
}{
%
endblock
%
}
docs/releases/1.11.txt
Dosyayı görüntüle @
5a51b449
...
...
@@ -382,6 +382,10 @@ Backwards incompatible changes in 1.11
``contrib.gis`` was first released, :ref:`gdalbuild` is now a required
dependency for GeoDjango. In older versions, it's only required for SQLite.
* ``contrib.gis.maps`` is removed as it interfaces with a retired version of
the Google Maps API and seems to be unmaintained. If you're using it, `let
us know <https://code.djangoproject.com/ticket/14284>`_.
Database backend API
--------------------
...
...
tests/gis_tests/maps/tests.py
deleted
100644 → 0
Dosyayı görüntüle @
727d7ce6
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
unittest
import
skipUnless
from
django.contrib.gis.geos
import
HAS_GEOS
from
django.test
import
SimpleTestCase
from
django.test.utils
import
modify_settings
,
override_settings
from
django.utils.encoding
import
force_text
GOOGLE_MAPS_API_KEY
=
'XXXX'
@skipUnless
(
HAS_GEOS
,
'Geos is required.'
)
@modify_settings
(
INSTALLED_APPS
=
{
'append'
:
'django.contrib.gis'
},
)
class
GoogleMapsTest
(
SimpleTestCase
):
@override_settings
(
GOOGLE_MAPS_API_KEY
=
GOOGLE_MAPS_API_KEY
)
def
test_google_map_scripts
(
self
):
"""
Testing GoogleMap.scripts() output. See #20773.
"""
from
django.contrib.gis.maps.google.gmap
import
GoogleMap
google_map
=
GoogleMap
()
scripts
=
google_map
.
scripts
self
.
assertIn
(
GOOGLE_MAPS_API_KEY
,
scripts
)
self
.
assertIn
(
"new GMap2"
,
scripts
)
@override_settings
(
GOOGLE_MAPS_API_KEY
=
GOOGLE_MAPS_API_KEY
)
def
test_unicode_in_google_maps
(
self
):
"""
Test that GoogleMap doesn't crash with non-ASCII content.
"""
from
django.contrib.gis.geos
import
Point
from
django.contrib.gis.maps.google.gmap
import
GoogleMap
,
GMarker
center
=
Point
(
6.146805
,
46.227574
)
marker
=
GMarker
(
center
,
title
=
'En français !'
)
google_map
=
GoogleMap
(
center
=
center
,
zoom
=
18
,
markers
=
[
marker
])
self
.
assertIn
(
"En français"
,
google_map
.
scripts
)
def
test_gevent_html_safe
(
self
):
from
django.contrib.gis.maps.google.overlays
import
GEvent
event
=
GEvent
(
'click'
,
'function() {location.href = "http://www.google.com"}'
)
self
.
assertTrue
(
hasattr
(
GEvent
,
'__html__'
))
self
.
assertEqual
(
force_text
(
event
),
event
.
__html__
())
def
test_goverlay_html_safe
(
self
):
from
django.contrib.gis.maps.google.overlays
import
GOverlayBase
overlay
=
GOverlayBase
()
overlay
.
js_params
=
'"foo", "bar"'
self
.
assertTrue
(
hasattr
(
GOverlayBase
,
'__html__'
))
self
.
assertEqual
(
force_text
(
overlay
),
overlay
.
__html__
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment