Re: Django with GXmlHttp

2009-11-25 Thread 504Django
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 

Re: Django with GXmlHttp

2009-11-24 Thread 504Django
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 the
> implementation of a pure AJAX solution returning XML with a Get
> request to a PHP page:
>
> var request = GXmlHttp.create();
> request.open('GET','query.php?var1=' + val1 + '&var2=' + val1, true);
> request.onreadystatechange = function() {
>         if (request.readyState == 4) {
>                 if (request.status == 200) {
>                         var xmlsource = request.responseXML;
>                         var markers = 
> xmlsource.documentElement.getElementsByTagName
> ("marker");
>                         for (var i = 0; i < markers.length; i++) {
>                                 var lat = 
> parseFloat(markers[i].getAttribute("lat"));
>                                 var lng = 
> parseFloat(markers[i].getAttribute("lng"));
>                                 var latlng = new GLatLng(lat,lng);

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Django with GXmlHttp

2009-11-23 Thread 504Django
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 the
implementation of a pure AJAX solution returning XML with a Get
request to a PHP page:

var request = GXmlHttp.create();
request.open('GET','query.php?var1=' + val1 + '&var2=' + val1, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 200) {
var xmlsource = request.responseXML;
var markers = 
xmlsource.documentElement.getElementsByTagName
("marker");
for (var i = 0; i < markers.length; i++) {
var lat = 
parseFloat(markers[i].getAttribute("lat"));
var lng = 
parseFloat(markers[i].getAttribute("lng"));
var latlng = new GLatLng(lat,lng);

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.