D7 Google Maps

Events happening in the community are now at Drupal community events on www.drupal.org.
jeffc518's picture

Hello all,

I'm working on a Google Map that is rendered via a custom module's theme() implementation. The problem I'm running into is being able to dynamically add / remove / update markers on the map based on the values from a custom form (built with FAPI). That is, without reloading the page - just by targeting the map in a callback.

I'm trying to do so with an AJAX callback, (#ajax attribute on form submit) but am having difficulty with the AJAX callback system. It's easy enough to add / replace elements on the page with it, but I want to pass the form ($_POST) values to the callback and add / change the map markers instead.

Is this something that I'd need to do with JS Behaviors instead? I would really appreciate anyone who could spread some light on this. Here's an example of the kind of thing I'm trying to create: http://www.scripps.org/locations

Thanks!

Comments

window.requestAnimationFrame()

Patrick_McMahon's picture

try using window.requestAnimationFrame() it will give you a 60FPS loop that you can add and remove the objects as needed. best of all the loop is only running when the page is active. It also hands over the loop to the system so it will not stall the system.

requestAnimationFrame()

jeffc518's picture

Thanks Patrick. I've seen this function before was but unsure of its browser compatibility, but it's not bad. Any suggestions on specific modules to use for maps? I wasn't able to find any that have the functionality I need, so I ended up writing my own. It passes the location information via theme() to a custom template. I figure I need to bone up on Drupal JS Behaviors for this.

The go to mapping module has

greggmarshall's picture

The go to mapping module has traditionally been the GMap module, which integrates views and Google Maps. https://www.drupal.org/project/gmap

About a year ago I started hearing more about Open Layers, which is more flexible and simultaneously harder to set up. https://www.drupal.org/project/openlayers

Recently I've been hearing a lot about Leaflet, which is a completely different approach using the Leaflet JavaScript library. https://www.drupal.org/project/leaflet

There are a number of alternative modules, but these three are the ones I hear the most about. All of these are integrations with views.

Albany, NY

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week