Django

Code

Ticket #9955 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

GoogleMap support for multiple maps

Reported by: mandric Assigned to: nobody
Milestone: Component: GIS
Version: 1.0 Keywords: maps gmaps gis javascript
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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:

http://dpaste.com/105280/

http://dpaste.com/105281/

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.

http://prototype.nytimes.com/represent/98-Rivington-St-New-York-NY-10002/

Attachments

google-maps.patch (13.2 kB) - added by aromano on 01/10/09 21:59:23.
Google Maps patch - multiple map instance support

Change History

01/10/09 21:58:45 changed by aromano

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

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.

01/10/09 21:59:23 changed by aromano

  • attachment google-maps.patch added.

Google Maps patch - multiple map instance support

03/09/09 14:22:25 changed by jbronn

  • status changed from new to closed.
  • resolution set to fixed.

(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.


Add/Change #9955 (GoogleMap support for multiple maps)




Change Properties
Action