Disorientated by too many google-maps django packages

53 views
Skip to first unread message

Victor

unread,
Jan 26, 2015, 11:44:00 AM1/26/15
to django...@googlegroups.com
I'm working for a medical non-profit company for domiciliary assistance of ill people managed by means of a django app in production. One of the models is for patients and contains, among many other pieces of info, their addresses scattered all over Rome. I would like to use a google-maps django package able to put all the flags of patients' addresses on the map of Rome in one shot. Googling around I found many of them and frankly feel somewhat disorientated. As a matter of fact it looks as those packages are able to put just one flag at a time on a map.
In your experience is there any specific package able to suit my needs?
Thanks
Vittorio

George Silva

unread,
Jan 26, 2015, 11:55:53 AM1/26/15
to django-users
I would suggest a new approach here. Don't use a package that is out there.

Since your task is quite simple, you should create you webmapp using JavaScript, and pull all the patient data from your django server using REST or use a map server, like GeoServer, to create and render your layers on top of your Google Map's Layers.

In the client side, two libraries dominate: OpenLayers and Leaflet.

Check them out.

If you need other functionality, you can code it yourself. These packages have limited functions, so if you ever need anything else, you'll end up hacking the package or letting it go all the way.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/12E97993-5E82-48EF-AE5C-443F51F79C32%40gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
George R. C. Silva
SIGMA Consultoria
----------------------------

Mario Gudelj

unread,
Jan 26, 2015, 6:12:59 PM1/26/15
to django...@googlegroups.com
Hey Victor,

Here's some basic JS I've used in a project to plot client locations, and to show their name and phone when the marker is clicked:

var locations = {{ locations|safe }};

var map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 11,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();

var marker, i;

for (i = 0; i < locations.length; i++) {
lat_log_split = locations[i][1].split(",");
marker = new google.maps.Marker({
position: new google.maps.LatLng(parseFloat(lat_log_split[0]),parseFloat(lat_log_split[1])),
map: map
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
var popup = '<strong>'+locations[i][0]+' </strong><p>'+locations[i][2]+'</p><p><a href="tel:'+locations[i][3]+'">M:'+locations[i][3]+'</a></p>';
infowindow.setContent(popup);
infowindow.open(map, marker);
}
})(marker, i));
}
You'll see that the following code is plotting the marker on the map using lat and long, which I've obtained by geocoding the client's address on the server side.

marker = new google.maps.Marker({
        position: new google.maps.LatLng(parseFloat(lat_log_split[0]),parseFloat(lat_log_split[1])),
        map: map
    });

You have to link to maps api before this code with:

<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>

I'm just passing an array inside {{ locations|safe }} where each array item contains customer info. 

It's probably not the best way to do this and what George has written is a better approach, but it works well for me. I think I've used something from here to obtain lat and long https://pypi.python.org/pypi/django-easy-maps

Cheers,

M




Victor

unread,
Jan 29, 2015, 4:14:13 AM1/29/15
to django...@googlegroups.com
Many thanks to Mario Goodelj for the very clear example and his explanations.
Ciao
Vittorio
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHqTbj%3D2sYVZ9amrRtD6jmsks0p2cGJj74VQ_2axVc1oJQ1eTQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages