- mapsandsemanticmaps0.2.zip
- Maps
- COPYING
- Geocoders
- GoogleMaps
- INSTALL
- Maps.i18n.php
- Maps.php
- Maps_BaseGeocoder.php
- Maps_BaseMap.php
- Maps_Geocoder.php
- Maps_Mapper.php
- Maps_Settings.php
- Maps_Utils.php
- MapUtilityFunctions.js
- OpenLayers
- Maps_OpenLayers.php
- OpenLayerFunctions.js
- OpenLayers
- img
- blank.gif
- cloud-popup-relative.png
- drag-rectangle-off.png
- drag-rectangle-on.png
- east-mini.png
- layer-switcher-maximize.png
- layer-switcher-minimize.png
- marker.png
- marker-blue.png
- marker-gold.png
- marker-green.png
- measuring-stick-off.png
- measuring-stick-on.png
- north-mini.png
- panning-hand-off.png
- panning-hand-on.png
- slider.png
- south-mini.png
- west-mini.png
- zoombar.png
- zoom-minus-mini.png
- zoom-plus-mini.png
- zoom-world-mini.png
- OpenLayers.js
- theme
- default
- framedCloud.css
- google.css
- ie6-style.css
- img
- add_point_off.png
- add_point_on.png
- blank.gif
- close.gif
- drag-rectangle-off.png
- drag-rectangle-on.png
- draw_line_off.png
- draw_line_on.png
- draw_point_off.png
- draw_point_on.png
- draw_polygon_off.png
- draw_polygon_on.png
- editing_tool_bar.png
- move_feature_off.png
- move_feature_on.png
- navigation_history.png
- overview_replacement.gif
- pan_off.png
- pan_on.png
- panning-hand-off.png
- panning-hand-on.png
- pan-panel.png
- pan-panel-NOALPHA.png
- remove_point_off.png
- remove_point_on.png
- ruler.png
- save_features_off.png
- save_features_on.png
- view_next_off.png
- view_next_on.png
- view_previous_off.png
- view_previous_on.png
- zoom-panel.png
- zoom-panel-NOALPHA.png
- style.css
- OSM
- README
- RELEASE-NOTES
- YahooMaps
- SemanticMaps
|
<?php
/**
* A query printer for maps using the Google Maps API
*
* @file SM_GoogleMaps.php
* @ingroup SemanticMaps
*
* @author Robert Buzink
* @author Yaron Koren
* @author Jeroen De Dauw
*/
if( !defined( 'MEDIAWIKI' ) ) {
die( 'Not an entry point.' );
}
final class SMGoogleMaps extends SMMapPrinter {
// TODO: only js that should be printed is a claa to a js function that does all the work
public function getName() {
wfLoadExtensionMessages('SemanticMaps');
return wfMsg('sm_googlemaps_printername');
}
protected function getResultText($res, $outputmode) {
parent::getResultText($res, $outputmode);
// Go through the array with map parameters and create new variables
// with the name of the key and value of the item.
foreach($this->m_params as $paramName => $paramValue) {
if (empty(${$paramName})) ${$paramName} = $paramValue;
}
global $wgJsMimeType, $egGoogleMapsKey, $egGoogleMapsOnThisPage, $egMapsGoogleMapsZoom;
global $wgLang;
$result = "";
if (strlen($zoom) < 1) $zoom = $egMapsGoogleMapsZoom;
// TODO: autozoom does not work (accuratly) for GE?
switch($earth) {
case 'on' : case 'yes' :
$earthCode = "map.addMapType(G_SATELLITE_3D_MAP);";
break;
default :
$earthCode = '';
break;
}
// Get the Google Maps names for the control and map types
$type = MapsGoogleMaps::getGMapType($type, strlen($earthCode) > 0);
$control_class = MapsGoogleMaps::getGControlType($controls);
$map_text = '';
if (empty($egGoogleMapsOnThisPage)) {
$egGoogleMapsOnThisPage = 0;
MapsGoogleMaps::addGMapDependencies($map_text);
}
$egGoogleMapsOnThisPage++;
// Enable the scroll wheel zoom when autozoom is not set to off
switch($autozoom) {
case 'no' : case 'off' :
$autozoomCode = '';
break;
default:
$autozoomCode = 'map.enableScrollWheelZoom();';
break;
}
$map_text .= <<<END
<div id="map$egGoogleMapsOnThisPage" class="$class"></div>
<script type="text/javascript">
function makeMap{$egGoogleMapsOnThisPage}() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map$egGoogleMapsOnThisPage"), {size: new GSize('$width', '$height')});
map.setMapType($type);
map.addControl(new {$control_class}());
map.addControl(new GMapTypeControl());
$autozoomCode $earthCode
END;
if (count($this->m_locations) > 0) {
if (empty($centre)) {
// If the center is not set, it needs to be determined, together with the bounds
// This is done by extending the bounds with every point (Google Maps API)
// and then getting the center and zoom level
$map_text .= "var bounds = new GLatLngBounds();";
foreach ($this->m_locations as $i => $location) {
// Add the markers to the map
list($lat, $lon, $title, $label, $icon) = $location;
$title = str_replace("'", "\'", $title);
$label = str_replace("'", "\'", $label);
$map_text .= "
var point = new GLatLng($lat, $lon);
bounds.extend(point);
map.addOverlay(createGMarker(point, '$title', '$label', '$icon'));";
}
$map_text .= "map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));";
}
else {
if ($centre == null) {
$centre_lat = 0;
$centre_lon = 0;
}
else {
// If the center is set, get the coordinates
// GLatLng class expects only numbers, no letters or degree symbols
list($centre_lat, $centre_lon) = MapsUtils::getLatLon($centre);
}
foreach ($this->m_locations as $i => $location) {
// Add the markers to the map
list($lat, $lon, $title, $label, $icon) = $location;
$title = str_replace("'", "\'", $title);
$label = str_replace("'", "\'", $label);
$map_text .= "map.addOverlay(createGMarker(new GLatLng($lat, $lon), '$title', '$label', '$icon'));";
}
$map_text .= " map.setCenter(new GLatLng($centre_lat, $centre_lon), $zoom);\n";
}
}
$map_text .=<<<END
}
}
addLoadEvent(makeMap{$egGoogleMapsOnThisPage});
</script>
END;
$result .= $map_text;
// print further results footer
// getSearchLabel() method was added in SMW 1.3
if (method_exists($this, 'getSearchLabel')) {
$search_label = $this->getSearchLabel(SMW_OUTPUT_HTML);
} else {
$search_label = $this->mSearchlabel;
}
if ( $this->mInline && $res->hasFurtherResults() && $search_label !== '') {
$link = $res->getQueryLink();
$link->setCaption($search_label);
$result .= "\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . $res->getColumnCount() . '"> ' . $link->getText($outputmode,$this->mLinker) . "</td></tr>\n";
}
return array($result, 'noparse' => 'true', 'isHTML' => 'true');
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a free and open source software enthusiast and freelance software developer with multiple years of experience in both web and desktop development. Currently my primarily focus is on MediaWiki and Semantic MediaWiki work. I'm in the all time top 10 MediaWiki comitters and am one of the WikiWorks consultants. You can contact me at jeroendedauw at gmail for development jobs and questions related to my work.
More info can be found on my website [0] and my blog [1]. You can also follow me on twitter [2] and identi.ca [3].
[0] http://www.jeroendedauw.com/
[1] http://blog.bn2vs.com/
[2] https://twitter.com/#!/JeroenDeDauw
[3] http://identi.ca/jeroendedauw