def zipcode_detail(request, object_id): zipcode = get_object_or_404(Zipcode, code=object_id) polygons = () polygons += (GPolygon(zipcode.mpoly), ) return render_to_response( 'census/zipcode_detail.html', { 'google': GoogleMap(key=settings.GOOGLE_MAPS_API_KEY, polygons=polygons), 'object': zipcode, })
def gmap(request, id): api_key = api_key_dict[request.META['SERVER_NAME']] d = Office.objects.filter(id=id) return render_to_response('map.html', {'district': d[0], 'google' : GoogleMap(key=api_key)})
import settings from django import forms from django.contrib.admin import widgets from django.contrib.gis import admin from django.contrib.gis.maps.google import GoogleMap from django.db import models as djangomodels from django.utils.translation import ugettext_lazy as _ from locast.admin import UserActivityAdmin, FlagAdmin from travels import models from modeltranslation.admin import TranslationAdmin GMAP = GoogleMap(key=settings.GOOGLE_MAPS_KEY) # Can also set GOOGLE_MAPS_API_KEY in settings class MapAdmin(admin.OSMGeoAdmin): class Media: css = { 'all': ('css/jquery.tooltip.css',) } js = ('js/admin_jquery_hack.js', 'js/jquery.tooltip.min.js') extra_js = [GMAP.api_url + GMAP.key] map_template = 'admin/map_admin.django.html' default_lon = settings.DEFAULT_LON default_lat = settings.DEFAULT_LAT # because of the way that the site switches base layers default_zoom = settings.DEFAULT_ZOOM + 6
# Merengue is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Merengue. If not, see <http://www.gnu.org/licenses/>. from django.conf import settings from django.contrib.gis import admin as geoadmin from django.contrib.gis.maps.google import GoogleMap from transmeta import canonical_fieldname from merengue.base.admin import BaseAdmin GMAP = GoogleMap(key=settings.GOOGLE_MAPS_API_KEY) class GoogleAdmin(geoadmin.OSMGeoAdmin, BaseAdmin): extra_js = [GMAP.api_url + GMAP.key] map_width = 500 map_height = 300 default_zoom = 10 default_lat = 4500612.0 default_lon = -655523.0 map_template = 'gis/admin/google.html' def comes_from_buildbot(request): if hasattr(settings, 'BUILDBOT_IP'): if request.META.get('REMOTE_ADDR') == settings.BUILDBOT_IP:
import logging, os, traceback from django.conf.urls import patterns from django.contrib import admin from django.contrib.gis import admin as gis_admin from django.contrib.gis.maps.google import GoogleMap from django.shortcuts import render from countdracula.forms import UploadCountForm from countdracula.models import Node, StreetName, TurnCountLocation, TurnCount, MainlineCountLocation, MainlineCount # key associated with [email protected] GMAP = GoogleMap(key='AIzaSyDSscDrdYK3lENjefyjoBof_JjXY5LJLRo') # create custom admin site to add the upload counts view class CountDraculaAdminSite(admin.sites.AdminSite): def get_urls(self): urls = super(CountDraculaAdminSite, self).get_urls() my_urls = patterns( '', (r'^upload_counts/$', self.admin_view(self.upload_view))) # print "CountDraculaAdminSite" # print (my_urls + urls) # todo: can we put the auth (admin.site.get_urls() here? it'd be nice to have one page) return my_urls + urls def upload_view(self, request): context_dict = {} if request.method == 'POST': form = UploadCountForm(request.POST, request.FILES) if form.is_valid():
from django.conf import settings from django.contrib.gis import admin from django.contrib.gis.geos import Point from django.contrib.gis.maps.google import GoogleMap from waypoints.forms import WaypointAdminForm from waypoints.models import Waypoint GMAP = GoogleMap() class WaypointAdmin(admin.GeoModelAdmin): # Set a default location pnt = Point(-98.3,39.5, srid=4326) #pnt.transform(3857) #fallback (900913) # Use with OSMModelAdmin debug = True default_lon, default_lat = pnt.coords #extra_js = [GMAP.api_url + GMAP.key] #form = WaypointAdminForm list_display = ('name','geometry') #map_template = 'gis/admin/google.html' admin.site.register(Waypoint, WaypointAdmin)