Google Maps v0.7

Release Notes

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

It includes the "widget-plus" plugin, which adds some widget functionality (notably adding a 'widget ajax load complete' event and facilitating changing a widget's title).

Note: contributions adding various gmap options to the widget edit/view are welcome.

This release includes more IE bugfixes.

Sample Map

  • Hi Timothy!
    First thanks for this plugin, very great idea ! ;-)

    I'm pretty new on Elgg platform and i try to lean step by step how it works.

    For my dev, i would use your plugin and displau map with lat/lng value and not "address" in string format. In gmap.js, i saw that if "address" is an objet, the map center on this point (lat,lng)...but when I open mod/google-map/views/default/google-map/view.php I saw that "address" could never be a "object" because of the double quote :

    L28 : var address = "<?php echo $location; ?>";
    In this case, it's impossible to undestand {lat:48.8842781,lng:2.3253479} as an object, because of double quote "{lat:48.8842781,lng:2.3253479}"
    So, I need to delete this double quote and replace L28 by var address = <?php echo $location; ?>; (without ")

    When i want use a string, i put the quote in the array params like this :
    echo elgg_view('google-map/view', array('eid'=>$eid,
                                            'location'=> '"'.$vars['entity']->location.'"',
                                            'zoom'=>$vars['entity']->zoom));
    For a lat/lng use :
    echo elgg_view('google-map/view', array('eid'=>$eid,
                                            'location'=> {lat:48.8842781,lng:2.3253479}
                                            'zoom'=>$vars['entity']->zoom));


    But keep it simple as possible, i purpose this solution :
    In mod/google-map/views/default/google-map/view.php
    Replace
    L13 : $location = isset($vars['location'])?$vars['location']:GMAP_DEFAULT_LOCATION;
    By
    //--Detect if "location" is a string or a coordinate
    if(isset($vars['location'])) {
        $pattern = '/\([ \t]*([0-9]+\.[0-9]*)?[ \t]*,[ \t]*([0-9]+\.[0-9]*)?[ \t]*\)/';
        if ( preg_match($pattern, trim($vars['location']),$matches) ) {
            $location = "{lat:".$matches[1].",lng:".$matches[2]."}";
        } else {
            $location = '"'.$vars['location'].'"';
        }
    } else {
        GMAP_DEFAULT_LOCATION;
    }


    With this fix, we can use :
    String mode :
    echo elgg_view('google-map/view', array('eid'=>$eid,
                                            'location'=> '23 rue des moines, 75017 PARIS',
                                            'zoom'=>$vars['entity']->zoom));

    OR
    Lat/lon mod
    echo elgg_view('google-map/view', array('eid'=>$eid,
                                            'location'=> '(48.8842781,2.3253479)',
                                            'zoom'=>$vars['entity']->zoom));

    Hope this will help you...

    Sorry for my Frenchglish ;-)

  • After installing the plugin, I can only get the default map view to be the current user's location but with no pointers.  Also, I dont know if this was an intended function, but is there a way to create pointers for your friends locations on the map?

  • Whenever a widget on the page finishes loading, the map widget scans for divs as described above.  If you extend the friends view to include a div as described above, markers will be placed on the map. 

  • Wow, impressing. I'm still learning basic functionalities of elgg, but as i'm more experienced i'll head over to this plugin.

  • I am also getting no pointers. Is it due to any errors?

  • One more thing, when i activated the widget plus mod, the title of youtube and flicker video get changed (view link)

    Can you  tell me what is the use of the widget plus pluggin?

  • widget-plus will set the title of the widget to the "title" field of the widget, if it is set.  That part of the functionality is not required for the google map plugin.

    If you have marker markup on your page, the map plugin scans the DOM for them when the map widget is loaded and when other widgets finish loading.  The widget-loaded event is enabled by the widget-plus plugin.

  • Timothy, Thanks for this pluggin. I activated it, but i am not getting any pointers in the map

    image

    I saw the posts above. but i am totally new to elgg. can you please tell me in which file,  where should i add the above tags to get the pointers?

    Thank you

  • You can make a view, for example, in mod/google-map/views/default/google-map/location.php, that looks like this:

    $latlng = "(".$vars['entity']->getLatitude().",".$vars['entity']->getLongitude().")";

    echo gmap_marker($latlng);

    Then use extend_view() to append this view to any view which has a locatable entity, e.g.

    extend_view('user/default', 'google-map/location');

    This will cause a marker to appear in the map if that view is used anywhere on the page.

  • Does anyone see anything wrong with the following:

                        echo elgg_view('google-map/view', array('eid'=>"test",
                                            'location'=> '{lat:'.$lat.",lng:".$lon."}" ,
                                            'zoom'=>'13'
                                            ));
    I am not sure what to put in for eid.  I have confirmed that my $lat and $lon are correct.  I look them up in a database that I have for zipcodes.  I am not getting the correct location in the map.

     

  • Get the plugin update.  0.8 has a bug parsing (lat,lng) formatted locations.

    In addition, your lat/lng should use the format "(lat,lng)", not JSON object notation.

Stats

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

Other Projects

View Timothy Wall's plugins