From 1f88a21fd504f4dad3da0dc8470d6a770f824091 Mon Sep 17 00:00:00 2001 From: svolochev Date: Thu, 5 Jun 2014 10:29:56 +0600 Subject: [PATCH] =?UTF-8?q?Version=201.3:=20=09*=20=E2=80=9CjQuery.ddYMap?= =?UTF-8?q?=E2=80=9D=20has=20been=20updated=20to=201.2.=20=09+=20The=20?= =?UTF-8?q?=E2=80=9CmapCenterOffset=E2=80=9D=20parameter=20has=20been=20ad?= =?UTF-8?q?ded.=20It=20allows=20center=20offset=20of=20the=20map=20to=20be?= =?UTF-8?q?=20set=20in=20pixels=20with=20respect=20to=20the=20center=20of?= =?UTF-8?q?=20the=20map=20container.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ assets/js/jquery.ddYMap-1.1.min.js | 24 ------------------------ assets/js/jquery.ddYMap-1.2.min.js | 25 +++++++++++++++++++++++++ ddYMap.php | 9 ++++++--- 4 files changed, 33 insertions(+), 27 deletions(-) delete mode 100644 assets/js/jquery.ddYMap-1.1.min.js create mode 100644 assets/js/jquery.ddYMap-1.2.min.js diff --git a/README.md b/README.md index 73960dc..225a776 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # ddYMap +A snippet that allows Yandex.Maps to be rendered on a page in a simple way. +___ Visit the following [link](http://code.divandesign.biz/modx/ddymap) to read the documentation, instructions & changelog. \ No newline at end of file diff --git a/assets/js/jquery.ddYMap-1.1.min.js b/assets/js/jquery.ddYMap-1.1.min.js deleted file mode 100644 index 8bf5700..0000000 --- a/assets/js/jquery.ddYMap-1.1.min.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * jQuery ddYMap Plugin - * @version 1.1 (2014-03-16) - * - * @desc A jQuery library that allows Yandex.Maps to be rendered on a page in a simple way. - * - * @uses jQuery 1.10.2. - * @uses Yandex.Maps 2.0-stable. - * - * Parameters of the “$.fn.ddYMap” method (transferred as plain object). - * @param latLng {array} - Comma separated longitude and latitude. @required - * @param zoom {integer} - Default map zoom. Default: 15. - * @param defaultType {'map'; 'satellite'; 'hybrid'; 'publicMap'; 'publicMapHybrid'} - Default map type: 'map' — schematic map, 'satellite' — satellite map, 'hybrid' — hybrid map, 'publicMap' — public map, 'publicMapHybrid' - hybrid public map. Default: 'map'; - * @param scrollZoom {boolean} - Allow zoom while scrolling. Default: false. - * @param placemarkOptions {plain object} - Placemark options. Default: {}. - * - * @link http://code.divandesign.biz/jquery/ddymap/1.1 - * - * @copyright 2014, DivanDesign - * http://www.DivanDesign.biz - */ - -(function(b){b.extend(!0,{ddYMap:{defaults:{latLng:[],element:"map",zoom:15,defaultType:"map",scrollZoom:!1,placemarkOptions:{}},init:function(a){a=b.extend({},this.defaults,a);b.isArray(a.latLng)&&2==a.latLng.length&&ymaps.ready(function(){var b=new ymaps.Map(a.element,{center:a.latLng,zoom:a.zoom,type:"yandex#"+a.defaultType});b.controls.add("zoomControl").add("typeSelector").add("scaleLine").add("mapTools");a.scrollZoom&&b.behaviors.enable("scrollZoom");b.geoObjects.add(new ymaps.Placemark(a.latLng, -{},a.placemarkOptions))})}}});b.fn.ddYMap=function(a){var c=b.ddYMap;return b(this).each(function(){c.init(b.extend(a,{element:b(this).get(0)}))})}})(jQuery); \ No newline at end of file diff --git a/assets/js/jquery.ddYMap-1.2.min.js b/assets/js/jquery.ddYMap-1.2.min.js new file mode 100644 index 0000000..97c44bf --- /dev/null +++ b/assets/js/jquery.ddYMap-1.2.min.js @@ -0,0 +1,25 @@ +/** + * jQuery ddYMap Plugin + * @version 1.2 (2014-06-05) + * + * @desc A jQuery library that allows Yandex.Maps to be rendered on a page in a simple way. + * + * @uses jQuery 1.10.2. + * @uses Yandex.Maps 2.0-stable. + * + * Parameters of the “$.fn.ddYMap” method (transferred as plain object). + * @param latLng {array} - Comma separated longitude and latitude. @required + * @param defaultZoom {integer} - Default map zoom. Default: 15. + * @param defaultType {'map'; 'satellite'; 'hybrid'; 'publicMap'; 'publicMapHybrid'} - Default map type: 'map' — schematic map, 'satellite' — satellite map, 'hybrid' — hybrid map, 'publicMap' — public map, 'publicMapHybrid' - hybrid public map. Default: 'map'; + * @param scrollZoom {boolean} - Allow zoom while scrolling. Default: false. + * @param mapCenterOffset {array} - Center offset of the map with respect to the center of the map container in pixels. Default: [0, 0]. + * @param placemarkOptions {plain object} - Placemark options. Default: {}. + * + * @link http://code.divandesign.biz/jquery/ddymap/1.2 + * + * @copyright 2014, DivanDesign + * http://www.DivanDesign.biz + */ + +(function(b){b.extend(!0,{ddYMap:{defaults:{latLng:[],element:"map",defaultZoom:15,defaultType:"map",scrollZoom:!1,mapCenterOffset:!1,placemarkOptions:{}},init:function(a){a=b.extend({},this.defaults,a);b.isArray(a.latLng)&&2==a.latLng.length&&ymaps.ready(function(){var c=new ymaps.Map(a.element,{center:a.latLng,zoom:a.defaultZoom,type:"yandex#"+a.defaultType});if(b.isArray(a.mapCenterOffset)&&2==a.mapCenterOffset.length){var d=c.getGlobalPixelCenter();c.setGlobalPixelCenter([d[0]-a.mapCenterOffset[0], +d[1]-a.mapCenterOffset[1]])}c.controls.add("zoomControl").add("typeSelector").add("scaleLine").add("mapTools");a.scrollZoom&&c.behaviors.enable("scrollZoom");c.geoObjects.add(new ymaps.Placemark(a.latLng,{},a.placemarkOptions))})}}});b.fn.ddYMap=function(a){var c=b.ddYMap;return b(this).each(function(){c.init(b.extend(a,{element:b(this).get(0)}))})}})(jQuery); \ No newline at end of file diff --git a/ddYMap.php b/ddYMap.php index a903996..8af9254 100644 --- a/ddYMap.php +++ b/ddYMap.php @@ -1,7 +1,7 @@ regClientStartupScript('http://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU', array('name' => 'api-maps.yandex.ru', 'version' => '2.0-stable')); //Подключаем $.ddYMap - $modx->regClientStartupScript($modx->getConfig('site_url').'assets/js/jquery.ddYMap-1.1.min.js', array('name' => '$.ddYMap', 'version' => '1.1')); + $modx->regClientStartupScript($modx->getConfig('site_url').'assets/js/jquery.ddYMap-1.2.min.js', array('name' => '$.ddYMap', 'version' => '1.2')); //Инлайн-скрипт инициализации $inlineScript = '(function($){$(function(){$("'.$mapElement.'").ddYMap({latLng: new Array('.$geoPos.')'; @@ -84,6 +85,8 @@ if (!empty($defaultType)){$inlineScript .= ', defaultType: "'.$defaultType.'"';} //Масштаб карты по умолчанию if (!empty($defaultZoom)){$inlineScript .= ', zoom: '.$defaultZoom;} + //Если указано смещение центра карты + if (isset($mapCenterOffset)){$inlineScript .= ', mapCenterOffset: new Array('.$mapCenterOffset.')';} $inlineScript .= '});});})(jQuery);';