Skip to content

Commit

Permalink
Version 1.3:
Browse files Browse the repository at this point in the history
	* “jQuery.ddYMap” has been updated to 1.2.
	+ The “mapCenterOffset” parameter has been added. It allows center
offset of the map to be set in pixels with respect to the center of the
map container.
  • Loading branch information
svolochev committed Jun 5, 2014
1 parent fc1803e commit 1f88a21
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
24 changes: 0 additions & 24 deletions assets/js/jquery.ddYMap-1.1.min.js

This file was deleted.

25 changes: 25 additions & 0 deletions assets/js/jquery.ddYMap-1.2.min.js
Original file line number Diff line number Diff line change
@@ -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);
9 changes: 6 additions & 3 deletions ddYMap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* ddYMap.php
* @version 1.2 (2014-03-16)
* @version 1.3 (2014-06-05)
*
* @desc A snippet that allows Yandex.Maps to be rendered on a page in a simple way.
*
Expand All @@ -19,8 +19,9 @@
* @param $icon {string} - An icon to use (relative address). Default: without (default icon).
* @param $iconOffset {comma separated string} - An offset of the icon in pixels (x, y).Basic position: the icon is horizontally centered with respect to x and its bottom position is y. Default: '0,0'.
* @param $scrollZoom {0; 1} - Allow zoom while scrolling. Default: 0.
* @param $mapCenterOffset {comma separated string} - Center offset of the map with respect to the center of the map container in pixels. Default: '0,0'.
*
* @link http://code.divandesign.biz/modx/ddymap/1.2
* @link http://code.divandesign.biz/modx/ddymap/1.3
*
* @copyright 2014, DivanDesign
* http://www.DivanDesign.biz
Expand All @@ -42,7 +43,7 @@
//Подключаем библиотеку карт
$modx->regClientStartupScript('http://api-maps.yandex.ru/2.0-stable/?load=package.standard&amp;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.')';
Expand Down Expand Up @@ -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);';

Expand Down

0 comments on commit 1f88a21

Please sign in to comment.