Tim,
Thanks. That's exactly the kind of simple example that I was looking
for of how to bridge the two worlds of Django templates and Ajax. BTW,
me living in a major crucible of brass band music, I'm completely
fascinated by your site and brass band culture in England -- of which
to date I was completely unfamiliar despite living there for six
months.
The example poses an additional dilemma, however, which is probably
the subject of separate post: How to present data in a browser using a
mapping API without exposing valuable or sensitive data to
unscrupulous hackers.
Let's say it's sensitive data that required an enormous investment to
scrape and aggregate.
The project I'm working would require mapping and charting events
without exposing the bulk of data or other attributes in a way that
could be easily filched.
I think the answer might be server-side Javascript -- something
ASP.NET can handle with the Ajax Toolkit, and Ruby on Rails can handle
-- as I understand it -- by allowing injection of Javascript into its
templates. Django seems to have left Javascript out of mind, which I
view as a weakness.
There do appear to be some Django kludges -- using Jaxer for example.
http://filthyweasel.co.uk/post/7/
Then again, maybe I should really be investing my time learning how to
deploy GeoDjango.
I really looking for an expert opinion before I discover that I've
scaled the wrong mountain.
I'd appreciate any additional comments the Django community might
offer. This seems like a discussion others would benefit from as well.
On Nov 25, 7:56 am, Tim Sawyer wrote:
> Not quite sure what you're looking for, but I've used google maps with
> django, without using GeoDjango.
>
> http://www.brassbandresults.co.uk/map/
>
> The script used in this page is here:
>
> http://www.brassbandresults.co.uk/map/map_script.js
>
> which is generated using this template:
>
> function initialize() {
> if (GBrowserIsCompatible()) {
> var map = new GMap2(document.getElementById("map_canvas"));
> {% if Band %}
> map.setCenter(new GLatLng({{Band.latitude}},
> {{Band.longitude}}), 12);
> {% else %}
> map.setCenter(new GLatLng(53.800651, -1.454), 8);
> {% endif %}
> map.setUIToDefault();
> var mgr = new MarkerManager(map);
> var lBandMarkers = [];
> {% for band in Bands %}
> {% if band.latitude %}
> {% if band.longitude %}
> lPoint{{band.id}} = new GLatLng({{band.latitude}},
> {{band.longitude}});
> lMarker{{band.id}} = new GMarker(lPoint{{band.id}}, {title:
> "{{band.name}}"});
> GEvent.addListener(lMarker{{band.id}}, "click", function() {
> var myHtml = "{{band.name}}{% if
> band.rehearsal_night_1
> %}Rehearsals {{band.rehearsal_nights}}{%endif%}[ href='/bands/{{band.slug}}/'>Contest Results] [ target='_blank' href='{{band.website}}'>Band Website]";
> map.openInfoWindowHtml(lPoint{{band.id}}, myHtml);
> });
> lBandMarkers.push(lMarker{{band.id}});
> {% endif %}
> {% endif %}
> {% endfor %}
> mgr.addMarkers(lBandMarkers, 0);
> mgr.refresh();
> }
> }
>
> Hope that helps,
>
> Tim.
>
> 504Django wrote:
> > Hmm ... the lack of a suggested solution to my question is
> > discouraging. The lack of common knowledge in the developer community
> > leads me to think that, aside from using the GeoDjango module, Django
> > may not be able to elegantly integrate with Google Maps AJAX API. It
> > that's truly the case, perhaps I should consider looking at a
> > different framework before I invest too much more effort.
>
> > On Nov 23, 10:01 pm, 504Django <504cr...@gmail.com> wrote:
> >> There seems to be a dearth of examples illustrating best practices in
> >> deploying Google Maps with Django.
>
> >> Common recommendations are to use GeoDjango.
>
> >> Of course, it doesn't have to be Google Maps. It could be
> >> OpenSteetMap, Yahoo Maps, or some other mapping API.
>
> >> Not necessarily related, there are also suggestions to use JQuery to
> >> handle AJAX requests.
>
> >> I'm trying to understand how to take the next step -- to make the
> >> required GXmlHttp GET requests calling a Django view that returns
> >> marker points, while not violating the RESTful nature of Django URLs.
>
> >> What would be the recommendation?
>
> >> To help the discussion along with an example, this might be