jenkins-bot has submitted this change and it was merged.
Change subject: add yandex map service
......................................................................
add yandex map service
Change-Id: Idfbd1fe02b3ccdf76fa241c700bfd9061cf16a3e
---
M MultiMaps.php
M Settings.php
A services/Yandex/Yandex.php
A services/Yandex/ext.yandex.js
4 files changed, 256 insertions(+), 2 deletions(-)
Approvals:
Pastakhov: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/MultiMaps.php b/MultiMaps.php
index 082724f..3cc5f52 100644
--- a/MultiMaps.php
+++ b/MultiMaps.php
@@ -15,7 +15,7 @@
die( 'This file is an extension to MediaWiki and thus not a valid entry
point.' );
}
-define( 'MultiMaps_VERSION' , '0.1.1' );
+define( 'MultiMaps_VERSION' , '0.2' );
// Register this extension on Special:Version
$wgExtensionCredits['parserhook'][] = array(
@@ -90,6 +90,15 @@
'group' => 'ext.MultiMaps',
);
+// Yandex service
+$wgAutoloadClasses["MultiMaps\Yandex"] = $dir . '/services/Yandex/Yandex.php';
+$wgResourceModules['ext.MultiMaps.Yandex'] = array(
+ 'scripts' => array( 'ext.yandex.js' ),
+ 'localBasePath' => $dir . '/services/Yandex',
+ 'remoteExtPath' => 'MultiMaps/services/Yandex',
+ 'group' => 'ext.MultiMaps',
+ );
+
/**
* Add files to phpunit test
* @codeCoverageIgnore
diff --git a/Settings.php b/Settings.php
index b99e6d0..5a3568c 100644
--- a/Settings.php
+++ b/Settings.php
@@ -27,7 +27,7 @@
$egMultiMapsServices_showmap = array(
'Leaflet' => 'leaflet',
'Google' => 'google',
- //'yandexmaps',
+ 'Yandex' => 'yandex',
);
diff --git a/services/Yandex/Yandex.php b/services/Yandex/Yandex.php
new file mode 100644
index 0000000..f358af9
--- /dev/null
+++ b/services/Yandex/Yandex.php
@@ -0,0 +1,32 @@
+<?php
+namespace MultiMaps;
+/**
+ * This groupe contains all Google related files of the MultiMaps extension.
+ *
+ * @defgroup Google
+ * @ingroup MultiMaps
+ */
+
+/**
+ *
+ *
+ * @file Google.php
+ * @ingroup Google
+ *
+ * @licence GNU GPL v2+
+ * @author Pavel Astakhov < [email protected] >
+ */
+class Yandex extends BaseService {
+
+ function __construct() {
+ parent::__construct();
+ $this->classname="yandex";
+ $this->resourceModules[] = 'ext.MultiMaps.Yandex';
+
+ $urlArgs = array();
+ $urlArgs['load'] = 'package.standard,package.geoObjects';
+ $urlArgs['lang'] = 'ru-RU';
+ $this->headerItem .= \Html::linkedScript(
'http://api-maps.yandex.ru/2.0-stable/?'.wfArrayToCgi($urlArgs) ) . "\n";
+ }
+
+}
\ No newline at end of file
diff --git a/services/Yandex/ext.yandex.js b/services/Yandex/ext.yandex.js
new file mode 100644
index 0000000..c85af9a
--- /dev/null
+++ b/services/Yandex/ext.yandex.js
@@ -0,0 +1,213 @@
+/**
+ * JavaScript for Leaflet in the MultiMaps extension.
+ * @see http://www.mediawiki.org/wiki/Extension:MultiMaps
+ *
+ * @author Pavel Astakhov < [email protected] >
+ */
+
+(function ($, mw) {
+ $.fn.multimapsyandex = function ( options ) {
+ var _this = this;
+ this.map = null;
+ this.options = options;
+
+ /**
+ * Convert properties given from multimaps extension to options
of map element
+ * @param {Object} properties Contains the fields lat, lon,
title, text and icon
+ * @return {Object} options of map element
+ */
+ this.convertPropertiesToOptions = function (properties) {
+ var prop = {};
+ var options = {};
+
+ if( properties.icon !== undefined ) {
+ options.iconImageHref = properties.icon;
+ }
+ if( properties.color !== undefined ) {
+ options.strokeColor = properties.color;
+ }
+ if( properties.weight !== undefined ) {
+ options.strokeWidth = properties.weight;
+ }
+ if( properties.opacity !== undefined ) {
+ options.strokeOpacity = properties.opacity;
+ }
+ if( properties.fill !== undefined ) {
+ options.fill = properties.fill;
+ }
+ if( properties.fillcolor !== undefined ) {
+ options.fillColor = properties.fillcolor;
+ }
+ if( properties.fillopacity !== undefined ) {
+ options.fillOpacity = properties.fillopacity;
+ }
+
+ if( properties.title !== undefined && properties.text
!== undefined ) {
+ prop.hintContent = properties.title;
+ prop.balloonContent = '<strong>' +
properties.title + '</strong><hr />' + properties.text;
+ } else if( properties.title !== undefined ) {
+ prop.hintContent = properties.title;
+ prop.balloonContent = '<strong>' +
properties.title + '</strong>';
+ } else if( properties.text !== undefined ) {
+ prop.balloonContent = properties.text;
+ }
+
+ return { properties:prop, options:options };
+ };
+
+ /**
+ * Add Marker to map
+ * @param {Object} properties Contains the fields lat, lon,
title, text and icon
+ * @param {String} icon Global value for all icons
+ */
+ this.addMarker = function (properties, icon) {
+ if( icon ) {
+ if( !properties.icon ) {
+ properties.icon = icon;
+ }
+ }
+ var value = this.convertPropertiesToOptions(properties);
+
+ var marker = new ymaps.Placemark(
[properties.pos[0].lat, properties.pos[0].lon], value.properties, value.options
);
+ this.map.geoObjects.add(marker);
+ };
+
+ /**
+ * Add Line to map
+ * @param {Object} properties
+ */
+ this.addLine = function (properties) {
+ var value = this.convertPropertiesToOptions(properties);
+
+ var latlngs = [];
+ for (var x = 0; x < properties.pos.length; x++) {
+ latlngs.push([properties.pos[x].lat,
properties.pos[x].lon]);
+ }
+
+ var polyline = new ymaps.Polyline( latlngs,
value.properties, value.options );
+ this.map.geoObjects.add(polyline);
+ };
+
+ /**
+ * Add Polygon to map
+ * @param {Object} properties
+ */
+ this.addPolygon = function (properties) {
+ var value = this.convertPropertiesToOptions(properties);
+
+ var latlngs = [];
+ for (var x = 0; x < properties.pos.length; x++) {
+ latlngs.push([properties.pos[x].lat,
properties.pos[x].lon]);
+ }
+ latlngs.push([properties.pos[0].lat,
properties.pos[0].lon]);
+
+ var polygon = new ymaps.Polygon( [latlngs],
value.properties, value.options );
+ this.map.geoObjects.add(polygon);
+ };
+
+ /**
+ * Add Circle to map
+ * @param {Object} properties
+ */
+ this.addCircle = function (properties) {
+ var value = this.convertPropertiesToOptions(properties);
+
+ var circle = new ymaps.Circle( [[properties.pos[0].lat,
properties.pos[0].lon], properties.radius[0]], value.properties, value.options
);
+ this.map.geoObjects.add(circle);
+ };
+
+ /**
+ * Add Rectangle to map
+ * @param {Object} properties
+ */
+ this.addRectangle = function (properties) {
+ var value = this.convertPropertiesToOptions(properties);
+
+ var bounds = [[properties.pos[0].lat,
properties.pos[0].lon], [properties.pos[1].lat, properties.pos[1].lon]];
+
+ var rectangle = new ymaps.Rectangle( bounds,
value.properties, value.options );
+ this.map.geoObjects.add(rectangle);
+ };
+
+ this.setup = function () {
+
+ var mapOptions = {};
+ if (options.minzoom !== false ) mapOptions.minZoom =
options.minzoom;
+ if (options.maxzoom !== false ) mapOptions.maxZoom =
options.maxzoom;
+ var mapState = {
+ center:[0, 0],
+ zoom: 1
+ };
+
+ this.get(0).innerHTML = '';
+ var map = new ymaps.Map( this.get(0), mapState,
mapOptions );
+ map.controls
+ .add('zoomControl')
+ .add('typeSelector')
+ .add('smallZoomControl', { right: 5, top: 75 });
+ this.map = map;
+
+ if (options.resizable) {
+ mw.loader.using('ext.maps.resizable', function
() { //TODO: Fix moving map when resized
+ _this.resizable();
+ });
+ }
+
+ // Add the markers.
+ for (var im in options.markers) {
+ this.addMarker( options.markers[im],
options.icon );
+ }
+
+ // Add lines
+ for (var il in options.lines) {
+ this.addLine(options.lines[il]);
+ }
+
+ // Add polygons
+ for (var ip in options.polygons) {
+ this.addPolygon(options.polygons[ip]);
+ }
+
+ // Add circles
+ for (var ic in options.circles) {
+ this.addCircle(options.circles[ic]);
+ }
+
+ // Add rectangles
+ for (var ir in options.rectangles) {
+ this.addRectangle(options.rectangles[ir]);
+ }
+
+ // Set map position (centre and zoom)
+ if( options.bounds ) {
+ map.setBounds( [
+ [options.bounds.sw.lat,
options.bounds.sw.lon],
+ [options.bounds.ne.lat,
options.bounds.ne.lon]
+ ] );
+ } else {
+ if( options.center ) {
+ map.setCenter( [options.center.lat,
options.center.lon], options.zoom );
+ } else if ( options.zoom ) {
+ map.setZoom( options.zoom );
+ }
+ }
+ };
+
+ this.setup();
+
+ return this;
+
+ };
+})(jQuery, window.mediaWiki);
+
+(function( $, mw ) {
+
+ ymaps.ready( function() {
+
+ $( '.multimaps-map-yandex' ).each( function() {
+ var $this = $( this );
+ $this.multimapsyandex( $.parseJSON(
$this.find('div').text() ) );
+ } );
+ } );
+
+})( window.jQuery, mediaWiki );
--
To view, visit https://gerrit.wikimedia.org/r/49625
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idfbd1fe02b3ccdf76fa241c700bfd9061cf16a3e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MultiMaps
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>
Gerrit-Reviewer: Pastakhov <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits