Opened 14 years ago
Closed 12 years ago
#14186 closed New feature (wontfix)
Adding GDirections wrapper to overlays.py
Reported by: | Miguel Araujo | Owned by: | Miguel Araujo |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | muchochini@… | Triage Stage: | Design decision needed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Today I needed to add support to GoogleMap GeoDjango abstraction so it could draw directions in a map. So I coded GDirections class, modified gmap.py to add a directions parameter and modified the template. Directions are drawn in a path within the map, adding a directions div and getting direction steps would be trivial with this. Take in mind only one GDirections object is passed to the GoogleMap object, as only one route will be drawn in the map.
You can find an example of use in the Doc strings of the class:
from django.shortcuts import render_to_response from django.contrib.gis.maps.google.overlays import GDirections def sample_request(request): route = GDirections(LineString(POINT(40.44 -3.77), POINT(42.33 -3.66)) return render_to_response('mytemplate.html', {'google' : GoogleMap(directions=route)})
You can still pass other overlays and they will get drawn in the map. Just be careful with zoom, because GDirections will set automatically the zoom to show the whole path.
I hope somebody finds this useful, Best regards
Miguel Araujo
Attachments (1)
Change History (11)
comment:1 by , 14 years ago
by , 14 years ago
Attachment: | geodjango-gdirections.patch added |
---|
comment:2 by , 14 years ago
Component: | Uncategorized → GIS |
---|
comment:3 by , 14 years ago
Cc: | added |
---|
comment:4 by , 14 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
This seems to me like something that should be handled as an external extension, rather than a builtin feature -- but I'll defer to anyone with better GeoDjango experience.
comment:5 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Uncategorized |
As GeoDjango is moving or has moved to the new Google's API v3. This is probably not necessary, as GDirections objects don't exist anymore and directions handling is done completely different.
comment:6 by , 14 years ago
Type: | Uncategorized → New feature |
---|
I'm not sure why but the patch diff is not showing correctly in the Trac interface, sorry.