CaseWiki talk:Map

Very cool page, which extension did you use to make this happen or did you write it your self? We have been admiring your excellent implementation as we build similar systems here in intel Well Done! mailto:john.g.miner@intel.com

John,
The Google Map takes articles that are geo-tagged using the GIS extension (available at http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/gis/).
There is a script that outputs these locations in a simple XML format (http://wiki.case.edu/misc/markers.php).
There are multiple Google Maps extensions in existence. The one on this wiki is the one I wrote (IndyGreg on meta.wikimedia.org). I added some JS to the CaseWiki version that downloads the markers.php XML file and plots these points on the map. The JS source can be found at http://wiki.case.edu/misc/gmap.js
--Gregory.Szorc 01:23, May 4, 2006 (EDT)
 
<?php
/*
  This script outputs a very simple XML document to be read by the Google Maps extension
 
  Gregory Szorc <gregory.szorc@case.edu>
 
*/
 
 
define('MEDIAWIKI', true);
require_once('../includes/Defines.php');
require_once('../LocalSettings.php');
require_once('../includes/Setup.php');
require_once('../includes/SpecialSearch.php');
 
$db = new mysqli('localhost','user','password', 'dbname');
 
$points = array();
 
$query = "SELECT page.page_title, gis.gis_latitude_min, gis.gis_latitude_max, gis.gis_longitude_min, gis.gis_longitude_max, gis.gis_page FROM page, gis WHERE page.page_id=gis.gis_page AND page.page_namespace=0";
if ($result = $db->query($query)) {
  if ($result->num_rows) {
    while ($row = $result->fetch_row()) {
      $p = array();
      $p['lat'] = ($row[1]+$row[2])/2;
      $p['lon'] = ($row[3]+$row[4])/2;
 
      $title = Title::newFromText($row[0]);
      $p['url'] = $title->getFullURL();
 
      $p['title'] = $title->getText();
      $p['id'] = $row[0];
 
      $points[] = $p;
    }
  }
}
 
header('Content-Type: text/xml');
 
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
echo "<markers>\n";
 
foreach ($points as $p) {
  echo "  <marker id=\"".$p['id']."\" lat=\"".$p['lat']."\" lng=\"".$p['lon']."\" title=\"".$p['title']."\" url=\"".$p['url']."\">\n";
  echo "  </marker>\n";
}
 
echo "</markers>";
?>
 

[edit] Browser Compatibility

If you can somehow load my User:Brian.Beck/case.js so that User:Brian.Beck/WikiMap will load, it appears to work in Opera and Konqueror. --Brian.Beck 15:50, October 26, 2006 (EDT)

Case Referrers

Blog Entries
Other Sites
This page has been accessed 1,607 times.
This page was last modified 14:50, October 26, 2006 by Brian Beck.
About | Disclaimers