Skip to content
This repository was archived by the owner on Feb 2, 2020. It is now read-only.

Commit ff66db3

Browse files
authored
Merge pull request #36 from danilbykov/bounds
added parameter 'bounds' to MapContainer
2 parents 37c9da8 + beacae1 commit ff66db3

File tree

6 files changed

+46
-20
lines changed

6 files changed

+46
-20
lines changed

lib/MapContainer.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ var YandexMap = function (_Component) {
9494
_this2._controller.setZoom(nextProps.zoom);
9595
}
9696

97+
break;
98+
case 'bounds':
99+
if (_this2.props.bounds !== nextProps.bounds) {
100+
_this2._controller.setBounds(nextProps.bounds);
101+
}
102+
97103
break;
98104
default:
99105
break;
@@ -148,7 +154,8 @@ var YandexMap = function (_Component) {
148154
this._controller = new _MapController2.default();
149155
this._controller.createMap(_reactDom2.default.findDOMNode(this.refs.mapContainer), _extends({}, this.props.state, {
150156
center: this.props.center,
151-
zoom: this.props.zoom
157+
zoom: this.props.zoom,
158+
bounds: this.props.bounds
152159
}), _extends({}, this.props.options));
153160

154161
this._setupEvents();
@@ -171,13 +178,15 @@ YandexMap.propTypes = {
171178
zoom: _react.PropTypes.number,
172179
state: _react.PropTypes.object,
173180
coordorder: _react.PropTypes.oneOf(['latlong', 'longlat']),
174-
options: _react.PropTypes.object
181+
options: _react.PropTypes.object,
182+
bounds: _react.PropTypes.array
175183
};
176184
YandexMap.defaultProps = {
177185
zoom: 10,
178186
center: [55, 45],
179187
width: 600,
180188
height: 600,
189+
bounds: undefined,
181190
state: {
182191
controls: []
183192
},

lib/MapMarker.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ var MapMarker = function (_Component) {
4949
value: function componentDidUpdate(prevProps) {
5050
var _this2 = this;
5151

52-
var _props = this.props;
53-
var lat = _props.lat;
54-
var lon = _props.lon;
55-
var children = _props.children;
56-
var properties = _props.properties;
57-
var options = _props.options;
58-
var balloonState = _props.balloonState;
52+
var _props = this.props,
53+
lat = _props.lat,
54+
lon = _props.lon,
55+
children = _props.children,
56+
properties = _props.properties,
57+
options = _props.options,
58+
balloonState = _props.balloonState;
5959

6060

6161
if (lat !== prevProps.lat || lon !== prevProps.lon) {
@@ -84,12 +84,12 @@ var MapMarker = function (_Component) {
8484
}, {
8585
key: 'componentDidMount',
8686
value: function componentDidMount() {
87-
var _props2 = this.props;
88-
var lat = _props2.lat;
89-
var lon = _props2.lon;
90-
var properties = _props2.properties;
91-
var options = _props2.options;
92-
var balloonState = _props2.balloonState;
87+
var _props2 = this.props,
88+
lat = _props2.lat,
89+
lon = _props2.lon,
90+
properties = _props2.properties,
91+
options = _props2.options,
92+
balloonState = _props2.balloonState;
9393

9494
var coords = this.context.coordorder === 'longlat' ? [lon, lat] : [lat, lon];
9595

lib/controllers/MapController.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ var MapController = function () {
5050
value: function setZoom(zoom) {
5151
this._map.setZoom(zoom);
5252
}
53+
}, {
54+
key: 'setBounds',
55+
value: function setBounds(bounds) {
56+
this._map.setBounds(bounds);
57+
}
5358
}, {
5459
key: 'setState',
5560
value: function setState(name, value) {

lib/controllers/layouts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function detectImagesLoaded(element) {
2929
}
3030

3131
function createLayout(_ref) {
32-
var domElement = _ref.domElement;
33-
var _ref$extendMethods = _ref.extendMethods;
34-
var extendMethods = _ref$extendMethods === undefined ? {} : _ref$extendMethods;
32+
var domElement = _ref.domElement,
33+
_ref$extendMethods = _ref.extendMethods,
34+
extendMethods = _ref$extendMethods === undefined ? {} : _ref$extendMethods;
3535

3636
var LayoutClass = _api2.default.getAPI().templateLayoutFactory.createClass('<i></i>', Object.assign({
3737
build: function build() {

src/MapContainer.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ class YandexMap extends Component {
1616
zoom: PropTypes.number,
1717
state: PropTypes.object,
1818
coordorder: PropTypes.oneOf(['latlong', 'longlat']),
19-
options: PropTypes.object
19+
options: PropTypes.object,
20+
bounds: PropTypes.array
2021
}
2122

2223
static defaultProps = {
2324
zoom: 10,
2425
center: [55, 45],
2526
width: 600,
2627
height: 600,
28+
bounds: undefined,
2729
state: {
2830
controls: []
2931
},
@@ -74,6 +76,12 @@ class YandexMap extends Component {
7476
this._controller.setZoom(nextProps.zoom);
7577
}
7678

79+
break;
80+
case 'bounds':
81+
if (this.props.bounds !== nextProps.bounds) {
82+
this._controller.setBounds(nextProps.bounds);
83+
}
84+
7785
break;
7886
default:
7987
break;
@@ -127,7 +135,8 @@ class YandexMap extends Component {
127135
{
128136
...this.props.state,
129137
center: this.props.center,
130-
zoom: this.props.zoom
138+
zoom: this.props.zoom,
139+
bounds: this.props.bounds
131140
},
132141
{...this.props.options}
133142
);

src/controllers/MapController.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class MapController {
3434
setZoom (zoom) {
3535
this._map.setZoom(zoom);
3636
}
37+
setBounds (bounds) {
38+
this._map.setBounds(bounds);
39+
}
3740

3841
setState (name, value) {
3942
this._map.state.set(name, value);

0 commit comments

Comments
 (0)