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




On 27 January 2015 at 03:54, George Silva <[email protected]> wrote:

> 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.
>
> On Mon, Jan 26, 2015 at 2:41 PM, Victor <[email protected]> wrote:
>
>> 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
>>
>> --
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> 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
> ----------------------------
> http://www.consultoriasigma.com.br/
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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/CAGyPVTt2bpAwzi5XVXH3sRZH7YWJEkLikdiZLTpnLPmL_KDA%3DA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAGyPVTt2bpAwzi5XVXH3sRZH7YWJEkLikdiZLTpnLPmL_KDA%3DA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CAHqTbj%3D2sYVZ9amrRtD6jmsks0p2cGJj74VQ_2axVc1oJQ1eTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to