Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
svolochev committed Jun 5, 2014
2 parents ff643bf + 675cf74 commit e768648
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# jQuery.ddYMap

A jQuery library that allows Yandex.Maps to be rendered on a page in a simple way.
___
Visit the following [link](http://code.divandesign.biz/jquery/ddymap) to read the documentation, instructions & changelog.
19 changes: 14 additions & 5 deletions jquery.ddYMap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* jQuery ddYMap Plugin
* @version 1.1 (2014-03-16)
* @version 1.2 (2014-06-05)
*
* @desc A jQuery library that allows Yandex.Maps to be rendered on a page in a simple way.
*
Expand All @@ -9,12 +9,13 @@
*
* 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 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.1
* @link http://code.divandesign.biz/jquery/ddymap/1.2
*
* @copyright 2014, DivanDesign
* http://www.DivanDesign.biz
Expand All @@ -25,9 +26,10 @@ $.extend(true, {ddYMap: {
defaults: {
latLng: new Array(),
element: 'map',
zoom: 15,
defaultZoom: 15,
defaultType: 'map',
scrollZoom: false,
mapCenterOffset: false,
placemarkOptions: {}
},
init: function(params){
Expand All @@ -41,11 +43,18 @@ $.extend(true, {ddYMap: {
//Создаём карту
var map = new ymaps.Map(params.element, {
center: params.latLng,
zoom: params.zoom,
zoom: params.defaultZoom,
type: 'yandex#' + params.defaultType
}
);

//Если нужно смещение центр карты
if ($.isArray(params.mapCenterOffset) && params.mapCenterOffset.length == 2){
var position = map.getGlobalPixelCenter();

map.setGlobalPixelCenter([position[0] - params.mapCenterOffset[0], position[1] - params.mapCenterOffset[1]]);
}

//Добавляем контролы
map.controls
.add('zoomControl')
Expand Down
11 changes: 6 additions & 5 deletions jquery.ddYMap.min.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* jQuery ddYMap Plugin
* @version 1.1 (2014-03-16)
* @version 1.2 (2014-06-05)
*
* @desc A jQuery library that allows Yandex.Maps to be rendered on a page in a simple way.
*
Expand All @@ -9,16 +9,17 @@
*
* 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 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.1
* @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",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);
(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);

0 comments on commit e768648

Please sign in to comment.