From a8640ee497014d2dc6a224fcd90402dfbed582f0 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 16 Mar 2014 00:29:03 +0600 Subject: [PATCH] Initial commit --- README.md | 3 ++ jquery.ddYMap.js | 66 ++++++++++++++++++++++++++++++++++++++++++++ jquery.ddYMap.min.js | 23 +++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 README.md create mode 100644 jquery.ddYMap.js create mode 100644 jquery.ddYMap.min.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..e4ca903 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# jQuery.ddYMap + +Visit the following [link](http://code.divandesign.biz/jquery/ddymap) to read the documentation, instructions & changelog. \ No newline at end of file diff --git a/jquery.ddYMap.js b/jquery.ddYMap.js new file mode 100644 index 0000000..75f1125 --- /dev/null +++ b/jquery.ddYMap.js @@ -0,0 +1,66 @@ +/** + * jQuery ddYMap Plugin + * @version 1.0 (2013-07-12) + * + * @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 “$.ddYMap.init” method (transferred as plain object). + * @param latLng {array} - Comma separated longitude and latitude. @required + * @param elementId {string} - Container ID which the map is required to be embed in. Default: 'map'. + * @param zoom {integer} - Масштаб карты по умолчанию. Default: 15. + * @param scrollZoom {boolean} - Allow zoom while scrolling. Default: false. + * @param placemarkOptions {plain object} - Placemark options. Default: {}. + * + * @link http://code.divandesign.biz/jquery/ddymap/1.0 + * + * @copyright 2013, DivanDesign + * http://www.DivanDesign.biz + */ + +(function($){ +$.extend(true, {ddYMap: { + defaults: { + latLng: new Array(), + elementId: 'map', + zoom: 15, + scrollZoom: false, + placemarkOptions: {} + }, + init: function(params){ + var _this = this; + + params = $.extend({}, _this.defaults, params); + + //Если координаты заданы + if ($.isArray(params.latLng) && params.latLng.length == 2){ + ymaps.ready(function(){ + //Создаём карту + var map = new ymaps.Map(params.elementId, { + center: params.latLng, + zoom: params.zoom + } + ); + + //Добавляем контролы + map.controls + .add('zoomControl') + .add('typeSelector') + .add('scaleLine') + .add('mapTools'); + + //Если зум нужен + if (params.scrollZoom){ + //Включим масштабирование колесом мыши + map.behaviors.enable('scrollZoom'); + } + + //Создаём метку и добавляем на карту + map.geoObjects.add(new ymaps.Placemark(params.latLng, {}, params.placemarkOptions)); + }); + } + } +}}); +})(jQuery); \ No newline at end of file diff --git a/jquery.ddYMap.min.js b/jquery.ddYMap.min.js new file mode 100644 index 0000000..7ae1225 --- /dev/null +++ b/jquery.ddYMap.min.js @@ -0,0 +1,23 @@ +/** + * jQuery ddYMap Plugin + * @version 1.0 (2013-07-12) + * + * @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 “$.ddYMap.init” method (transferred as plain object). + * @param latLng {array} - Comma separated longitude and latitude. @required + * @param elementId {string} - Container ID which the map is required to be embed in. Default: 'map'. + * @param zoom {integer} - Масштаб карты по умолчанию. Default: 15. + * @param scrollZoom {boolean} - Allow zoom while scrolling. Default: false. + * @param placemarkOptions {plain object} - Placemark options. Default: {}. + * + * @link http://code.divandesign.biz/jquery/ddymap/1.0 + * + * @copyright 2013, DivanDesign + * http://www.DivanDesign.biz + */ + +(function(b){b.extend(!0,{ddYMap:{defaults:{latLng:[],elementId:"map",zoom:15,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.elementId,{center:a.latLng,zoom:a.zoom});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))})}}})})(jQuery); \ No newline at end of file