bing-map-box
Version:
bing map component in react.js
60 lines • 2.7 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var BingMapBoxLoader_1 = require("./BingMapBoxLoader");
var BingMapBox = /** @class */ (function (_super) {
__extends(BingMapBox, _super);
function BingMapBox() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.mapRef = React.createRef();
return _this;
}
//This function is invoked immediately after the component is mounted to the DOM.
//If you also want to make network requests as soon as the component is mounted to the DOM, this is a perfect place to do
BingMapBox.prototype.componentDidMount = function () {
var _this = this;
BingMapBoxLoader_1.loadBingApi(this.props.apiKey).then(function () {
_this.initMap();
});
};
BingMapBox.prototype.render = function () {
return React.createElement("div", { ref: this.mapRef, className: this.props.className });
};
BingMapBox.prototype.componentWillReceiveProps = function (newProps) {
if (newProps.center !== this.props.center) {
this.map.setView({
center: new BingMapBoxLoader_1.Microsoft.Maps.Location(newProps.center.latitude, newProps.center.longitude),
});
}
};
BingMapBox.prototype.initMap = function () {
this.map = new BingMapBoxLoader_1.Microsoft.Maps.Map(this.mapRef.current);
// if (this.props.mapOptions) {
// let center1: LatLng = this.props.center;
// this.map.setOptions({
// center: new Microsoft.Maps.Location(center1.latitude, center1.longitude)
// });
this.map.setView({
//mapTypeId: Microsoft.Maps.MapTypeId.aerial,
center: new BingMapBoxLoader_1.Microsoft.Maps.Location(this.props.center.latitude, this.props.center.longitude),
});
// }
//return map;
};
return BingMapBox;
}(React.Component));
exports.BingMapBox = BingMapBox;
//# sourceMappingURL=index.js.map