GMap

From Daniel's homepage

Jump to: navigation, search


This extension lets you embed an arbitrary amount of fully interactive Google Maps objects into your wikipages. The mapcontrols appear when you move the mouse over the map, and disappear when you leave it. Two helper modes are available, outputting either current map view settings or coordinates on click, making it easy to choose a map locaton to display and to create markers and lines.

  • Download version 0.2 here. (tested to work up to MediaWiki: 1.7.1 (r16466))
  • Download version 0.2.1 here. (only for MediaWiki 1.8 series!)
  • Download version 0.2.2 here. (only for MediaWiki 1.9 series!)
  • Check the documentation.

Three examples of the GMap extension:

Map with lines, markers and helper="line"

Click the map to add coordinates to the box. This allows you to easily buld your own polylines.

Sample

<gmap lat="40.748" long="-73.886" zoom="5" helper="line" width="500" height="400">
points:
40.763905|-73.826374|Flushing YMCA. [http://www.ymcanyc.org/sub.php?p=services&sp=guest/guestbrookqueens website]
40.75974059207392|-73.82898330688477|Main Street station (7 line)

lines:
ff0000|3|0.5|40.759741|-73.828983|40.759220|-73.831043|40.758635|-73.832674|40.758180|-73.834305|40.757855|-73.836021|40.757335|-73.837652|40.755742|-73.841643|40.753726|-73.848510|40.750931|-73.857822|40.750085|-73.860569|40.749533|-73.865504|40.748948|-73.870826|40.748232|-73.877950|40.747582|-73.884215|40.746314|-73.896103|40.745501|-73.903527|40.745306|-73.905587|40.745306|-73.906960|40.745176|-73.908162|40.744721|-73.910480|40.742998|-73.916187|40.742900|-73.916702|40.742900|-73.917431|40.743583|-73.923376|40.744672|-73.932538|40.744770|-73.933139|40.745322|-73.933868|40.749110|-73.937838|40.749338|-73.938096|40.749663|-73.938525|40.750264|-73.939641|40.751142|-73.941658|40.751207|-73.942087|40.751045|-73.942516|40.748444|-73.944747|40.745973|-73.945606|40.745745|-73.945649|40.744315|-73.944705|40.744054|-73.944662|40.743729|-73.944790|40.743534|-73.945005|40.742429|-73.947880
</gmap>

Map with markers

Click on the markers. You can use wiki-syntax in them.

Sample

<gmap lat="40.7" long="-73.8" zoom="7" width="500" height="300">
points:
40.76445385284412|-73.97450923919678|[[image:Ich_logo.svg|none|40px]] I wish I lived [[:en:Plaza_Hotel|here]]!
40.59085093941084|-73.79788041114807|[[Image:NYCSub A Beach67 Gaston.jpg|100px]]
</gmap>

Map in satellite mode with helper="on"

Click on the textbox to update it with the coordinates the map is centered on.

Sample

<gmap lat="35" long="-95" zoom="14" type="satellite" helper="on"></gmap>


Issue with IE Browsers

Was still experiencing issues with IE Browsers. After some research determined it was related to the DIV tags. To resolve this I modified gmaps.php:

       $output.=<<<CODE_END
<div id="map${gmapIndex}" style="width: ${width}; height: ${height}; border: 1px solid gray" onMouseOver="if(mcinserted${gmapIndex}==0) { map${gmapIndex}.add\
Control(mycontrol${gmapIndex}); map${gmapIndex}.addControl(mytypctrl${gmapIndex}); mcinserted${gmapIndex}=1; } if(mcinserted${gmapIndex}==2) mcinserted${gmap\
Index}=1;" onMouseOut="mcinserted${gmapIndex}=2; setTimeout('if(mcinserted${gmapIndex}==2) { map${gmapIndex}.removeControl(mycontrol${gmapIndex}); map${gmapI\
ndex}.removeControl(mytypctrl${gmapIndex}); mcinserted${gmapIndex}=0; }',50000);"></div>
${helper}
CODE_END;
        $gmapscript.=<<<CODE_END
<script type="text/javascript" defer="defer">
//<![CDATA[
var mcinserted${gmapIndex} = 0;
var map${gmapIndex} = new GMap(document.getElementById("map${gmapIndex}"));
var mycontrol${gmapIndex} = new GSmallMapControl();
var mytypctrl${gmapIndex} = new GMapTypeControl();
map${gmapIndex}.setMapType(${maptype});
map${gmapIndex}.centerAndZoom(new GPoint(${long},${lat}), ${zoom});
${extracode}${linedata}${markers}//]]></script>\n
CODE_END;
        $wgOut->addScript("<gmapwuzhere>$gmapscript");

And within skins/MonoBook.php, at the end of the file, added:

    <?php $this->html('reporttime') ?>

              <?php $this->html('headscripts') ?> <!-- Add this line --->
  </body>

This resolved the IE error. Further testing needs to be done to ensure additional functionality is still working properly. (Smcnaught)

Personal tools