Google Maps v0.9.2

Release Notes

In this Release:

  • Markers may be passed directly to the view
  • GMap support scripts are only loaded if there is a gmap view or gmap widget on the page
  • Example page with standalone view usage

Sample Map

This plugin provides a simple Google Map view and widget.  You should supply your Google Maps API key in the "more info" tab of the plugin on the Tool Administration page.  The map may be included in any given page via elgg_view('google-map/view', $vars).

Other widgets may automatically trigger map markers by including special markup (see the gmap_marker function in start.php).  For example, a list of users might append one of these divs for each user:

<div class='gmapped' address='Hamburg, Germany'>Hi! I am here</div>
<div class='gmapped' latlng='(34,-120)' origin='clickme'>You're over here</div>

If an "origin" attribute is supplied, clicks on a component with that id will cause the map to center on the marker and display its text/html.  The map widget will automatically scan for new markers when widgets are edited or dynamically loaded.  You can force a scan yourself with the JavaScript method $.gmap.scan_markers().

See example.php for an example of passing markers directly to the view.

  • TImothy, I was working with your plugin lately and I did a few improvements that base on it. I will release it to the community probably with the end of this, or beginning of the next week. Maybe you'll find some of those changes usefull enought to incorporate them into your plugin.

  • could you please join this group:

    so you can develop and get ideas from other users?


  • probably just me


    line 222

    char 9

    Error:'GClientGeocoder is undefined

    code 0

  • sensational Timothy - thanks for all your hard work..

  • @lanwjensen I haven't specifically tested on IE, but that error implies that the google scripts were not loaded.  Do a view page source to see if there's a script reference to google maps; if not, please indicate how you included a google-map view in your pages.

  • Hi Timothy,

    I installed your plugin and all work fine, but widget doesn`t show marks. When you select a location and save, widget shows the map in the good place but mark doesn`t appear, any idea?

    Thans for all,


  • Hi Timothy,

    it's all fine , but how can i put mouse hover effect to change image ...
    thanks in advance

  • Hey, Timothy, 

    Your plugin is so nice!! But here I've got a problem with your plugin, which may seems stupid since I was just get started with Elgg:

    in your "example.php", it really shows the members of position with a marker for each at first, but they (the markers) will dispapper in about 20 mins when you refresh the page again without any modifications... after I cleaned the whole database and try again, the markers will show up and dispear again in about another 20 mins when you refresh that page.

    have any idea? thanks!

  • anyway forget about this, I now grab the users out and add markers explicitly to $options['markers']


    thanks for this great work!!

  • Hi, Timothy!!

    Great job, really helped me a lot! Thank you very much :)

    I'm having some trouble, though, with a customization I've made. I created two new widgets that get special markers and display the map, using the "first" address on the array as the location. It works FINE in the Profile, but in the dashboard I only see a "blank" widget, with no map. View source shows none of the code, but I got a hint:

    Error: el.gmap is not a function
    Source File:
    Line: 7

    Of course, in the view source I only get a dumb meta tag with Elgg version at line 7.

    My code is as follows:


        // Google Maps plugin general settings
        $rp_options = array('zoom'=>2);

        // Loads last 10 places added
        $recentPlaces = get_entities('object','imub_places',0,10,false);

        // Counter (todo? research a join, merge or combine for creating array)
        $placesCounter = 0;

        if ($recentPlaces) {
            foreach ($recentPlaces as $actualPlace) {
                if ($placesCounter == 0) {
                    $rp_options['location'] = $actualPlace->address;

                // Create markers for the map
                $rp_options['markers'][$placesCounter] =


            // Configure map to display
            $body = elgg_view('google-map/view', $rp_options);
        } else {

            // Ooops, no places yet
            $body = elgg_echo('gmap:norecentplacestext');

        // Populate the layout and draws the page
        echo $body;


    I've also tried to put:

        include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");

    in the beginning of the file to no effect at all.

    I'm using Elgg Dev Tools plugin, but still I disable and re-enable after altering the view, yet to no change. Is there a limitation to the use in the Dashboard? I tried also to use the <DIV> option too, with AND without the $options markers, but to no result as well.

    If you can please help me, thanks!

  • @Fernando: try it with only the google-map plugin enabled.  this will indicate whether the behavior is due to plugin conflicts.

  • @Timothy, thanks a lot for your answer! I got news: my widget works when the default widget that comes with the plugin is enabled in the page (the profile or the dashboard). If I remove the google-maps widget from the profile, or the dashboard, my widget stops working. Don't have a clue on why is that - maybe I have to have a directory google-map/views/recent-places (recent-places is my new widget)?

    Any idea will be welcome, and thanks again :)

  • @Fernando The google-maps view only loads the google gmap scripts if it determines that there is a map on the current page (since these support scripts can often be slow to load).  In the case of widgets, it can't extend the metatags view to include scripts, since that part of the page is already loaded, so the plugin extends the widget wrapper view to detect whether a google-maps widget is being loaded via ajax, and extends the metatags view if that is the case.  See the google-map/gmap-support view; you can extend this view to additionally check for your widget type.

    It might be possible to use google's script loading mechanisms to avoid having to put the gmap scripts into the html header, but I haven't tried that variation.  If you include the gmap scripts directly anywhere but the html header, you'll get strange page reloading artifacts.

  • @Timothy, I had success doing a different approach: modified your plugin so it is not editable and added to the page my plugin with a text listing and the <DIV> for gmaps. That way I got things working and I think the end result is great, too - people can search by the text listing or go right to the map.

    Thanks a lot for the great plugin and the support!

  • hi timothy..great just having a big problem getting the map widget to display markers for friends...any help would be greatly appreciated...a simple how to as in what code needs to go in the view.php file?

  • I am trying to figure out how to change the size of the popup bubble when a friends marker is show. I see that it has a class of gmnoprint. However, I see no css for this at all. I think that it is pulling this info from google maps. But I just would like to make it a little bit smaller. Is there a way to override the size? Any help is appreciated.

    @david haynes and anyone else interested. if you would like to show all friends locations and your own on the map you can put this code in your view.php file

       * Google Map view page
       * @package travelqube
       * @license GNU Public License version 2
       * @author movi LLC <>
       * @copyright famos LLC 2009
       * @link

    $page_owner = page_owner_entity();
    $options = array('location'=>$vars['entity']->location,'zoom'=>$vars['entity']->zoom);

    // Tack on gmap marker information to each user view
    // This extra markup is read automatically by the map and converted into
    // markers unless
    // $vars['autoPopulate'] == false
    extend_view('profile/icon', 'google-map/user');
    $users = list_entities('user');

    $page_owner = page_owner_entity();
    $plugin_setting = get_plugin_usersetting('location',$page_owner->guid,'google-map');
    $owner_icon = elgg_view("profile/icon",array('entity' => $page_owner, 'size' => 'tiny'));
    $owner_icon .= '<br>'.$page_owner->name;
    $owner_icon .= '<br>'.$plugin_setting;

    $friends = $page_owner->getFriends('',9999);
    foreach($friends as $friend)
    $plugin_setting = get_plugin_usersetting('location',$friend->guid,'google-map');
    $icon = '<div style="float:left">';
    $icon .= elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny'));
    $icon .= '</div>';
    $icon .= '<div style="clear:left;float:left">';
    $icon .= $friend->name;
    $icon .= '<br>'.$plugin_setting;
    $icon .= '</div>';

    // You can explicitly add markers to the map view
    $markers[] = array('address'=>$plugin_setting,

    $markers[] = array('address'=>$vars['entity']->location,

    $options['markers'] = $markers;
    $map = elgg_view('google-map/view', $options);
    $body = <<<EOT
    <div id='map'>{$map}</div>

    echo $body;


  • @ngreenwood6: Have you tried explicitly setting the size of the html you provide for the info window ($icon in the code above)?

  • Also does anyone have an issue with it not working in ie. I am getting a javascript error. It says line:13 char:12949. I have uninstalled and reinstalled the default plugin and its not working in ie. Any ideas?

  • I found out where the problem is. It is the code in the views/default/google-map/view.php file. If I remove the whole <script> from the page the error goes away but it doesnt show the map. Is there something in that script that isnt compatible with ie?

  • Ok so I finally figured it out. It was this line:


    I just manually set it to 280 like this:


    Is there another way to do this?

  • @ngreenwood6: google maps generally require on their container having a non-zero size before they'll render properly, and may have to be reinitialized if the map was initialized when the container had zero size.

  • I'm a complete newbie (been using Elgg since one week) and I'm so glad to find this great pulgin ! thank you for making this.

    Do you think it is possible to only list the members who are appearing on the map ? (and if the visitor scrolls the map the list will change as new members are pointed on the map) ?

  • Hi,

    My map is show gray areas and not focusing where it should be. Any ideas about why that is. Here's a picture:



  • just to say I'm all done with my Map, it works perfectly. Thanks again for sharing such a usefull/helpfull plugin

  • Hi

    I am experiencing the same problem as David Haynes
    The gmap dosen´t show the markers

    Any idea?




  • Category: Uncategorized
  • License: GNU General Public License (GPL) version 3
  • Updated: 2014-11-17
  • Downloads: 10584
  • Recommendations: 3

Other Projects

View Timothy Wall's plugins