Open main menu
MediaWiki extensions manual
OOjs UI icon advanced.svg
Simple GoogleMap
Release status: experimental
Implementation API
Description This makes a map using street and city names NOT geocodes.
Author(s) Schalice (talk)
Latest version 0.5
MediaWiki 1.18 (it should work on much earlier versions)
License GPL, Google TOS
Download Source
Translate the Schalice extension if it is available at translatewiki.net

Contents

DescriptionEdit

This extension embeds an iFrame to display a single point GoogleMap within an article. It includes google's geocoding and single point map apis using javascript. It should work inside a tough firewall policy. It does not require a google key.


InstallationEdit

This extension requires Extension:Website in iFrame. As a result, it should not be used on a public or anonymous wiki. Copy and save, as "map.php", the following code into the 'root' of your wiki.


SourceEdit

map.php
<?php
/* version 0.5 */
$loc=$_GET["loc"];
$zoom=$_GET["zoom"];
?> 

<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">

  var geocoder;
  var map;

   geocoder = new google.maps.Geocoder();

   var address ="<?php echo $loc ?>";
   geocoder.geocode( { 'address': address}, function(results, status)
   {
      if (status == google.maps.GeocoderStatus.OK)
      {
         var myOptions =
         {
            zoom: <?php echo $zoom ?>,
            disableDefaultUI: true,
            center: results[0].geometry.location,
            mapTypeId: google.maps.MapTypeId.ROADMAP
          }

          map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
       } 
    });

</script>
<body>
<div id="map_canvas" style="width:100%; height:100%"><?php echo $loc ?></div>
</body>


UsageEdit

Example of a calling function
{{#tag:websiteFrame|website=map.php?zoom=17&loc=Central Park, New York
width=400
height=300
scroll=no
border=0
name=googlemap
}}


Advanced UsageEdit

create an article on your wiki named
Template:Map
<includeonly>{{#tag:websiteFrame|website=map.php?zoom=16&loc={{ #if: {{{name}}} | {{urlencode:{{{name|}}}|PATH}}, }} {{{address|}}}, {{{city|}}}, {{{country|}}}
width=640
height=480
scroll=no
border=0
name=googlemap
}}</includeonly>


create an article on your wiki named
Gucci Map
{{Map
|name    = Gucci
|address = 5th Avenue
|city    = New York
|country = USA
}}


[[Category:Maps]]