Skip to content

Commit

Permalink
Merge pull request #63 from GFDRR/baselayers
Browse files Browse the repository at this point in the history
Remove Google Layers and avoid duplication of the local source in embedded maps.
  • Loading branch information
ingenieroariel committed Sep 19, 2011
2 parents 0327f53 + 7110599 commit 325c786
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 26 deletions.
40 changes: 40 additions & 0 deletions docs/source/deploy/production.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,46 @@ By default GeoNode runs in ``http://localhost/``, but when running in production
To configure it, edit the ``SITEURL`` setting in ``local_settings.py`` (which can be found either in your GeoNodePy/src/geonode folder or in ``/etc/geonode/local_settings.py`` if you used an automated installer.


Adding layers from Google, Bing and other providers
---------------------------------------------------

Bing
++++

Get an API key from Microsoft at http://bingmapsportal.com/ and place it in ``local_settings.py``. Add the following to ``MAP_BASELAYERS``::

},{
"source": {
"ptype":"gxp_bingsource",
"apiKey": "YOUR_BING_API"
},
"group":"background",
"name":"Aerial",
"visibility": False,
"fixed": True,



Google
++++++

Get an API key from Google at http://code.google.com/apis/maps/signup.html and place it in ``local_settings.py``, for example::

GOOGLE_API_KEY="zxcxzcXAWdqwdQWWQEDzxcxz"

Copy the ``MAP_BASELAYERS`` dictionary from ``settings.py`` into ``local_settings.py`` and add the following snippet::

},{
"source": {
"ptype":"gxp_googlesource",
"apiKey": GOOGLE_API_KEY
},
"group":"background",
"name":"SATELLITE",
"visibility": False,
"fixed": True,


Robot Exclusion File
--------------------

Expand Down
6 changes: 1 addition & 5 deletions src/GeoNodePy/geonode/maps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ def viewer_json(self, *added_layers):
"""
layers = list(self.layer_set.all()) + list(added_layers) #implicitly sorted by stack_order
server_lookup = {}
sources = dict()
sources = {'local': settings.LOCAL_LAYER_SOURCE }

def uniqify(seq):
"""
Expand All @@ -1278,10 +1278,6 @@ def uniqify(seq):
return results

configs = [l.source_config() for l in layers]
configs.insert(0, {
"ptype":"gxp_wmscsource",
"url": "/geoserver/wms",
"restUrl": "/gs/rest"})

i = 0
for source in uniqify(configs):
Expand Down
2 changes: 1 addition & 1 deletion src/GeoNodePy/geonode/maps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _baselayer(lyr, order):
return MapLayer.objects.from_viewer_config(
map = _default_map,
layer = lyr,
source = settings.MAP_BASELAYERSOURCES[lyr["source"]],
source = lyr["source"],
ordering = order
)

Expand Down
28 changes: 8 additions & 20 deletions src/GeoNodePy/geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,35 +174,28 @@
# maximum zoom is between 12 and 15 (for Google Maps, coverage varies by area)
DEFAULT_MAP_ZOOM = 7

MAP_BASELAYERSOURCES = {
"any": {
"ptype":"gx_olsource"
},
"capra": {
"url":"/geoserver/wms"
},
"google":{
"ptype":"gx_googlesource",
"apiKey": GOOGLE_API_KEY
}
DEFAULT_LAYER_SOURCE = {
"ptype":"gxp_wmscsource",
"url":"/geoserver/wms",
"restUrl": "/gs/rest"
}

MAP_BASELAYERS = [{
"source":"any",
"source": {"ptype": "gx_olsource"},
"type":"OpenLayers.Layer",
"args":["No background"],
"visibility": False,
"fixed": True,
"group":"background"
},{
"source":"any",
"source": { "ptype":"gx_olsource"},
"type":"OpenLayers.Layer.OSM",
"args":["OpenStreetMap"],
"visibility": True,
"fixed": True,
"group":"background"
},{
"source":"any",
"source": {"ptype":"gx_olsource"},
"type":"OpenLayers.Layer.WMS",
"group":"background",
"visibility": False,
Expand All @@ -218,12 +211,7 @@
},
{"buffer":0}
]
},{
"source":"google",
"group":"background",
"name":"SATELLITE",
"visibility": False,
"fixed": True,

}]

# NAVBAR expects a dict of dicts or a path to an ini file
Expand Down

0 comments on commit 325c786

Please sign in to comment.