示例#1
0
    def __init__(self,city):
        polygons = []

        for ward in Ward.objects.filter(city=city):
            for poly in ward.geom:
                polygons.append( GPolygon( poly ) )
        GoogleMap.__init__(self,zoom=13,key=settings.GMAP_KEY, polygons=polygons, dom_id='map_canvas', template="maps/fixmystreetmap.js")
示例#2
0
 def __init__(self,city):
     polygons = []
     ward = Ward.objects.filter(city=city)[:1][0]
     for ward in Ward.objects.filter(city=city):
         for poly in ward.geom:
             polygons.append( GPolygon( poly ) )
     GoogleMap.__init__(self,center=ward.geom.centroid,zoom=13,key=settings.GMAP_KEY, polygons=polygons,dom_id='map_canvas')
示例#3
0
 def __init__(self,city):
     polygons = []
     ward = Ward.objects.filter(city=city)[:1][0]
     for ward in Ward.objects.filter(city=city):
         for poly in ward.geom:
             polygons.append( GPolygon( poly ) )
     GoogleMap.__init__(self,center=ward.geom.centroid,zoom=13,key=settings.GMAP_KEY, polygons=polygons,dom_id='map_canvas')
示例#4
0
    def __init__(self,city):
        polygons = []
        kml_url = 'http://localhost:8000/media/kml/' + city.name + '.kml'

        ward = Ward.objects.filter(city=city)[:1][0]
        #for ward in Ward.objects.filter(city=city):
        #    for poly in ward.geom:
        #        polygons.append( GPolygon( poly ) )
        GoogleMap.__init__(self,center=ward.geom.centroid,zoom=13,key=settings.GMAP_KEY, polygons=polygons, kml_urls=[kml_url],dom_id='map_canvas')
示例#5
0
    def __init__(self,ward, reports = []):
        polygons = []
        for poly in ward.geom:
                polygons.append( GPolygon( poly ) )
        markers = []
        for i in range( len( reports ) ):
            marker = ReportMarker(reports[i], str(i+1) )
            markers.append(marker)

        GoogleMap.__init__(self,zoom=13,markers=markers,key=settings.GMAP_KEY, polygons=polygons, dom_id='map_canvas')
示例#6
0
    def __init__(self,ward, reports = []):
        polygons = []
        for poly in ward.geom:
                polygons.append( GPolygon( poly ) )
        markers = []
        for i in range( len( reports ) ):
            marker = ReportMarker(reports[i], str(i+1) )
            markers.append(marker)

        GoogleMap.__init__(self,zoom=13,markers=markers,key=settings.GMAP_KEY, polygons=polygons, dom_id='map_canvas')
示例#7
0
    def __init__(self, city):
        polygons = []
        kml_url = 'http://localhost:8000/media/kml/' + city.name + '.kml'

        ward = Ward.objects.filter(city=city)[:1][0]
        # for ward in Ward.objects.filter(city=city):
        #    for poly in ward.geom:
        #        polygons.append( GPolygon( poly ) )
        GoogleMap.__init__(self, center=ward.geom.centroid, zoom=13, key=settings.GMAP_KEY, polygons=polygons,
                           kml_urls=[kml_url], dom_id='map_canvas')
示例#8
0
    def __init__(self,pnt,draggable=False,nearby_reports = [] ):  
#        self.icons = []
        markers = []
        marker = GMarker(geom=(pnt.x,pnt.y), draggable=draggable)
        if draggable:
            event = GEvent('dragend',
                           'function() { window.location.href = "/reports/new?" +"&lat="+geodjango.map_canvas_marker1.getPoint().lat().toString()+"&lon="+geodjango.map_canvas_marker1.getPoint().lng().toString(); }')        
            marker.add_event(event)
        markers.append(marker)
        
        for i in range( len( nearby_reports ) ):
            nearby_marker = ReportMarker(nearby_reports[i], str(i+1) )
            markers.append(nearby_marker)

        GoogleMap.__init__(self,center=(pnt.x,pnt.y),zoom=17,key=settings.GMAP_KEY, markers=markers, dom_id='map_canvas')
示例#9
0
    def __init__(self,pnt,draggable=False,nearby_reports = [] ):  
#        self.icons = []
        markers = []
        marker = GMarker(geom=(pnt.x,pnt.y), draggable=draggable)
        if draggable:
            event = GEvent('dragend',
                           'function() { reverse_geocode (geodjango.map_canvas_marker1.getPoint()); }')        
            marker.add_event(event)
        markers.append(marker)
        
        for i in range( len( nearby_reports ) ):
            nearby_marker = ReportMarker(nearby_reports[i], str(i+1) )
            markers.append(nearby_marker)

        GoogleMap.__init__(self,center=(pnt.x,pnt.y),zoom=17,key=settings.GMAP_KEY, markers=markers, dom_id='map_canvas')
示例#10
0
    def __init__(self, pnt, draggable=False, nearby_reports=[]):
        # self.icons = []
        version = settings.GOOGLE_MAPS_API_VERSION
        markers = []
        center = (pnt.x, pnt.y)
        gIcon = GIcon("dragme",
                      image="/static/images/marker/default/marker.png",
                      iconsize=(29, 38))
        marker = GMarker(geom=(pnt.x, pnt.y), draggable=draggable, icon=gIcon)
        if draggable:
            event = GEvent('dragend', 'function(){}')
            marker.add_event(event)
        markers.append(marker)

        for i in range(len(nearby_reports)):
            nearby_marker = ReportMarker(nearby_reports[i], str(i + 1))
            markers.append(nearby_marker)

        GoogleMap.__init__(self, center=center, zoom=17, key=settings.GMAP_KEY, version=version,
                           markers=markers, dom_id='map_canvas', )
示例#11
0
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,
        })
示例#12
0
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)})
示例#13
0
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 
示例#14
0
# 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:
示例#15
0
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():
示例#16
0
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)