Opened 12 years ago

Closed 11 years ago

#9955 closed (fixed)

GoogleMap support for multiple maps

Reported by: mandric Owned by: nobody
Component: GIS Version: 1.0
Severity: Keywords: maps gmaps gis javascript
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I'm working on a project that displays more than one google map on a page. I'm using contrib.gis and it's totally awesome but I ran into this limitation. I'd like to approach the problem but not really sure where to begin. Before I go and hack up the javascript I thought I would file a ticket. Comments are appreciated, I searched the tickets under GIS component and didn't find any regarding this issue.

Here's a dpaste of my view and template code:

I don't mind coding up a patch but I need help in the approach for a solution. Another feature which is minor is adding support for XML. Basically I'm doing the same thing as the nytimes represent site.

Attachments (1)

google-maps.patch (13.2 KB) - added by aromano 11 years ago.
Google Maps patch - multiple map instance support

Download all attachments as: .zip

Change History (3)

comment:1 Changed 11 years ago by aromano

Has patch: set

I have had the same exact problem these days, so I decided to make a patch for this. I have created a new GoogleMapSet object, which works the following way:
gmaps = GoogleMapSet(key=api_key, maps=gmap_objects)

where gmap_objects is a vector of (traditional) GoogleMap instances. When a DOM name is not specified, unique ones are generated.

In the templating system, the way to access the GMaps changes as follows:
<div id="{{ gmaps.maps.0.dom_id }}"></div> <!-- But also maps.1, maps.2 ... (in the order specified in gmaps_objects) -->

In JS code, map is then being replaced by a maps[] array.

This patch also includes the GMarker advanced features in #9440, and does not aim to be the best one, it is just a way to fix the solution. Feel free to change it and improve it.

Changed 11 years ago by aromano

Attachment: google-maps.patch added

Google Maps patch - multiple map instance support

comment:2 Changed 11 years ago by jbronn

Resolution: fixed
Status: newclosed

(In [10011]) Fixed #9955 -- Added GoogleMapSet, which enables multiple GoogleMap objects to placed on the same page; moved all templates to google parent dir, and added 'google-map.html' for an included example. Thanks to mandric for the ticket and aromano for initial patch.

Note: See TracTickets for help on using tickets.
Back to Top