react-cartographer
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -60,3 +60,2 @@ /** | ||
new webpack.NormalModuleReplacementPlugin(/^react?$/, require.resolve('react')), | ||
new webpack.NormalModuleReplacementPlugin(/^react(\/addons)?$/, require.resolve('react/addons')) | ||
], | ||
@@ -63,0 +62,0 @@ stats: { |
@@ -8,5 +8,6 @@ /** | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Map from './src/components/Map'; | ||
React.render( | ||
ReactDOM.render( | ||
<div> | ||
@@ -13,0 +14,0 @@ Example of using a Google Map (Location: 1600 Amphitheatre Parkway, Mountain View CA United States) |
@@ -1,128 +0,94 @@ | ||
/** | ||
* Copyright 2015, Yahoo! Inc. | ||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = Map; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _react = require('react'); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _react2 = _interopRequireDefault(_react); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _propTypes = require('prop-types'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _mapLocationFactory = require('../lib/mapLocationFactory'); | ||
var _react = require('react'); | ||
var _mapLocationFactory2 = _interopRequireDefault(_mapLocationFactory); | ||
var _react2 = _interopRequireDefault(_react); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _libMapLocationFactory = require('../lib/mapLocationFactory'); | ||
var _libMapLocationFactory2 = _interopRequireDefault(_libMapLocationFactory); | ||
// Factory | ||
var factory = new _libMapLocationFactory2['default'](); | ||
var factory = new _mapLocationFactory2.default(); /** | ||
* Copyright 2015, Yahoo! Inc. | ||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. | ||
*/ | ||
function Map(props) { | ||
var location = factory.getMap({ | ||
providerKey: props.providerKey, | ||
provider: props.provider, | ||
mapId: props.mapId, | ||
line1: props.addressLine1, | ||
line2: [props.city, props.state].join(','), | ||
line3: props.country, | ||
longitude: props.longitude, | ||
latitude: props.latitude, | ||
height: props.height, | ||
width: props.width, | ||
zoom: props.zoom | ||
}); | ||
var locationText = void 0; | ||
var locationLink = void 0; | ||
var style = void 0; | ||
var Map = (function (_React$Component) { | ||
_inherits(Map, _React$Component); | ||
if (!location.data || !location.data.locationLink) { | ||
return null; | ||
} | ||
function Map() { | ||
_classCallCheck(this, Map); | ||
locationText = location.data.locationText; | ||
locationLink = location.data.locationLink; | ||
style = { | ||
width: props.width, | ||
height: props.height | ||
}; | ||
_get(Object.getPrototypeOf(Map.prototype), 'constructor', this).apply(this, arguments); | ||
if (props.useBackgroundImageStyle) { | ||
style = { | ||
width: '100%', | ||
height: props.height, | ||
background: 'url(' + locationLink + ') no-repeat' | ||
}; | ||
} | ||
_createClass(Map, [{ | ||
key: 'getLocation', | ||
value: function getLocation() { | ||
return factory.getMap({ | ||
providerKey: this.props.providerKey, | ||
provider: this.props.provider, | ||
mapId: this.props.mapId, | ||
line1: this.props.addressLine1, | ||
line2: [this.props.city, this.props.state].join(','), | ||
line3: this.props.country, | ||
longitude: this.props.longitude, | ||
latitude: this.props.latitude, | ||
height: this.props.height, | ||
width: this.props.width, | ||
zoom: this.props.zoom | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var location = this.getLocation(); | ||
var locationText = undefined; | ||
var locationLink = undefined; | ||
var style = undefined; | ||
return _react2.default.createElement( | ||
'div', | ||
{ style: style, className: 'cartographer-container' }, | ||
!props.useBackgroundImageStyle ? _react2.default.createElement('img', { src: locationLink, alt: locationText, title: locationText }) : null | ||
); | ||
} | ||
if (!location.data || !location.data.locationLink) { | ||
return null; | ||
} | ||
Map.propTypes = { | ||
providerKey: _propTypes2.default.string.isRequired, | ||
provider: _propTypes2.default.oneOf(['yahoo', 'google', 'bing']), | ||
mapId: _propTypes2.default.string.isRequired, | ||
addressLine1: _propTypes2.default.string, | ||
city: _propTypes2.default.string, | ||
state: _propTypes2.default.string, | ||
country: _propTypes2.default.string, | ||
longitude: _propTypes2.default.number, | ||
latitude: _propTypes2.default.number, | ||
height: _propTypes2.default.number.isRequired, | ||
width: _propTypes2.default.number.isRequired, | ||
zoom: _propTypes2.default.number, | ||
useBackgroundImageStyle: _propTypes2.default.bool | ||
}; | ||
locationText = location.data.locationText; | ||
locationLink = location.data.locationLink; | ||
style = { | ||
width: this.props.width, | ||
height: this.props.height | ||
}; | ||
if (this.props.useBackgroundImageStyle) { | ||
style = { | ||
width: '100%', | ||
height: this.props.height, | ||
background: 'url(' + locationLink + ') no-repeat' | ||
}; | ||
} | ||
return _react2['default'].createElement( | ||
'div', | ||
{ style: style, className: 'cartographer-container' }, | ||
!this.props.useBackgroundImageStyle ? _react2['default'].createElement('img', { src: locationLink, alt: locationText, title: locationText }) : null | ||
); | ||
} | ||
}], [{ | ||
key: 'propTypes', | ||
value: { | ||
providerKey: _react2['default'].PropTypes.string.isRequired, | ||
provider: _react2['default'].PropTypes.oneOf(['yahoo', 'google', 'bing']), | ||
mapId: _react2['default'].PropTypes.string.isRequired, | ||
addressLine1: _react2['default'].PropTypes.string, | ||
city: _react2['default'].PropTypes.string, | ||
state: _react2['default'].PropTypes.string, | ||
country: _react2['default'].PropTypes.string, | ||
longitude: _react2['default'].PropTypes.number, | ||
latitude: _react2['default'].PropTypes.number, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
zoom: _react2['default'].PropTypes.number, | ||
useBackgroundImageStyle: _react2['default'].PropTypes.bool | ||
}, | ||
enumerable: true | ||
}, { | ||
key: 'defaultProps', | ||
value: { | ||
provider: 'yahoo', | ||
mapId: 'map', | ||
height: 270, | ||
width: 580, | ||
zoom: 10, | ||
useBackgroundImageStyle: false | ||
}, | ||
enumerable: true | ||
}]); | ||
return Map; | ||
})(_react2['default'].Component); | ||
exports['default'] = Map; | ||
; | ||
module.exports = exports['default']; | ||
Map.defaultProps = { | ||
provider: 'yahoo', | ||
mapId: 'map', | ||
height: 270, | ||
width: 580, | ||
zoom: 10, | ||
useBackgroundImageStyle: false | ||
}; |
@@ -13,14 +13,10 @@ /** | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _config = require('../../config/config.json'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _configConfigJson = require('../../config/config.json'); | ||
var _url = require('url'); | ||
@@ -30,2 +26,6 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _ = { | ||
@@ -37,3 +37,3 @@ // Collection | ||
var BingMapService = (function () { | ||
var BingMapService = function () { | ||
function BingMapService() { | ||
@@ -46,2 +46,3 @@ _classCallCheck(this, BingMapService); | ||
/** | ||
@@ -54,6 +55,6 @@ * Get the map location details for the address provided in the params | ||
value: function getMap(params) { | ||
var locationText = undefined; | ||
var location = undefined; | ||
var pushpin = undefined; | ||
var url = undefined; | ||
var locationText = void 0; | ||
var location = void 0; | ||
var pushpin = void 0; | ||
var url = void 0; | ||
@@ -69,6 +70,6 @@ if (isFinite(params.longitude) && isFinite(params.latitude)) { | ||
url = _url2['default'].format({ | ||
protocol: _configConfigJson.bing.protocol, | ||
hostname: _configConfigJson.bing.host, | ||
pathname: _configConfigJson.bing.path + encodeURIComponent(location), | ||
url = _url2.default.format({ | ||
protocol: _config.bing.protocol, | ||
hostname: _config.bing.host, | ||
pathname: _config.bing.path + encodeURIComponent(location), | ||
query: _.pick({ | ||
@@ -92,3 +93,3 @@ mapSize: [params.width, params.height].join(','), | ||
get: function get() { | ||
return _configConfigJson.bing.name; | ||
return _config.bing.name; | ||
} | ||
@@ -98,5 +99,4 @@ }]); | ||
return BingMapService; | ||
})(); | ||
}(); | ||
exports['default'] = BingMapService; | ||
module.exports = exports['default']; | ||
exports.default = BingMapService; |
@@ -13,14 +13,10 @@ /** | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _config = require('../../config/config.json'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _configConfigJson = require('../../config/config.json'); | ||
var _url = require('url'); | ||
@@ -30,2 +26,6 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _ = { | ||
@@ -37,3 +37,3 @@ // Collection | ||
var GoogleMapService = (function () { | ||
var GoogleMapService = function () { | ||
function GoogleMapService() { | ||
@@ -46,2 +46,3 @@ _classCallCheck(this, GoogleMapService); | ||
/** | ||
@@ -54,4 +55,4 @@ * Get the map location details for the address provided in the params | ||
value: function getMap(params) { | ||
var location = undefined; | ||
var url = undefined; | ||
var location = void 0; | ||
var url = void 0; | ||
@@ -64,11 +65,11 @@ if (isFinite(params.longitude) && isFinite(params.latitude)) { | ||
url = _url2['default'].format({ | ||
protocol: _configConfigJson.google.protocol, | ||
hostname: _configConfigJson.google.host, | ||
pathname: _configConfigJson.google.path, | ||
url = _url2.default.format({ | ||
protocol: _config.google.protocol, | ||
hostname: _config.google.host, | ||
pathname: _config.google.path, | ||
query: _.pick({ | ||
center: location, | ||
size: [params.width, params.height].join('x'), | ||
mapType: _configConfigJson.google.mapType, | ||
markers: [_configConfigJson.google.markerColor, _configConfigJson.google.markerLabel, location].join('|'), | ||
mapType: _config.google.mapType, | ||
markers: [_config.google.markerColor, _config.google.markerLabel, location].join('|'), | ||
zoom: params.zoom, | ||
@@ -90,3 +91,3 @@ key: params.providerKey | ||
get: function get() { | ||
return _configConfigJson.google.name; | ||
return _config.google.name; | ||
} | ||
@@ -96,5 +97,4 @@ }]); | ||
return GoogleMapService; | ||
})(); | ||
}(); | ||
exports['default'] = GoogleMapService; | ||
module.exports = exports['default']; | ||
exports.default = GoogleMapService; |
@@ -8,12 +8,8 @@ /** | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _bingMap = require('./bingMap'); | ||
@@ -31,6 +27,10 @@ | ||
var bingService = new _bingMap2['default'](); | ||
var yahooService = new _yahooMap2['default'](); | ||
var googleService = new _googleMap2['default'](); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var bingService = new _bingMap2.default(); | ||
var yahooService = new _yahooMap2.default(); | ||
var googleService = new _googleMap2.default(); | ||
/** | ||
@@ -45,3 +45,3 @@ * Call the mapLocation service to obtain location details for | ||
var MapLocationFactory = (function () { | ||
var MapLocationFactory = function () { | ||
function MapLocationFactory() { | ||
@@ -67,5 +67,4 @@ _classCallCheck(this, MapLocationFactory); | ||
return MapLocationFactory; | ||
})(); | ||
}(); | ||
exports['default'] = MapLocationFactory; | ||
module.exports = exports['default']; | ||
exports.default = MapLocationFactory; |
@@ -13,14 +13,10 @@ /** | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _config = require('../../config/config.json'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _configConfigJson = require('../../config/config.json'); | ||
var _url = require('url'); | ||
@@ -30,2 +26,6 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _ = { | ||
@@ -37,3 +37,3 @@ // Collection | ||
var MapQuestService = (function () { | ||
var MapQuestService = function () { | ||
function MapQuestService() { | ||
@@ -54,11 +54,11 @@ _classCallCheck(this, MapQuestService); | ||
var location = [params.line1, params.line2, params.line3].join(','); | ||
var url = _url2['default'].format({ | ||
protocol: _configConfigJson.mapQuest.protocol, | ||
hostname: _configConfigJson.mapQuest.host, | ||
pathname: _configConfigJson.mapQuest.path, | ||
var url = _url2.default.format({ | ||
protocol: _config.mapQuest.protocol, | ||
hostname: _config.mapQuest.host, | ||
pathname: _config.mapQuest.path, | ||
query: _.pick({ | ||
key: params.providerKey, | ||
size: [params.width, params.height].join(','), | ||
type: _configConfigJson.mapQuest.mapType, | ||
showicon: _configConfigJson.mapQuest.icon, | ||
type: _config.mapQuest.mapType, | ||
showicon: _config.mapQuest.icon, | ||
location: location | ||
@@ -79,5 +79,4 @@ }, _.identity) | ||
return MapQuestService; | ||
})(); | ||
}(); | ||
exports['default'] = MapQuestService; | ||
module.exports = exports['default']; | ||
exports.default = MapQuestService; |
@@ -13,14 +13,10 @@ /** | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _config = require('../../config/config.json'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _configConfigJson = require('../../config/config.json'); | ||
var _url = require('url'); | ||
@@ -30,2 +26,6 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _ = { | ||
@@ -37,3 +37,3 @@ // Collection | ||
var YahooMapService = (function () { | ||
var YahooMapService = function () { | ||
function YahooMapService() { | ||
@@ -46,2 +46,3 @@ _classCallCheck(this, YahooMapService); | ||
/** | ||
@@ -55,4 +56,4 @@ * Get the map location details for the address provided in the params | ||
value: function getMap(params) { | ||
var location = undefined; | ||
var url = undefined; | ||
var location = void 0; | ||
var url = void 0; | ||
var query = _.pick({ | ||
@@ -62,4 +63,4 @@ appid: params.providerKey, | ||
imh: params.height, | ||
imi: _configConfigJson.yahoo.imi, | ||
radius: _configConfigJson.yahoo.radius, | ||
imi: _config.yahoo.imi, | ||
radius: _config.yahoo.radius, | ||
zoom: params.zoom | ||
@@ -77,6 +78,6 @@ }, _.identity); | ||
url = _url2['default'].format({ | ||
protocol: _configConfigJson.yahoo.protocol, | ||
hostname: _configConfigJson.yahoo.host, | ||
pathname: _configConfigJson.yahoo.path, | ||
url = _url2.default.format({ | ||
protocol: _config.yahoo.protocol, | ||
hostname: _config.yahoo.host, | ||
pathname: _config.yahoo.path, | ||
query: query | ||
@@ -96,3 +97,3 @@ }); | ||
get: function get() { | ||
return _configConfigJson.yahoo.name; | ||
return _config.yahoo.name; | ||
} | ||
@@ -102,5 +103,4 @@ }]); | ||
return YahooMapService; | ||
})(); | ||
}(); | ||
exports['default'] = YahooMapService; | ||
module.exports = exports['default']; | ||
exports.default = YahooMapService; |
{ | ||
"name": "react-cartographer", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Generic React component for displaying static maps using Yahoo, Google or Bing as a map provider.", | ||
@@ -16,4 +16,4 @@ "author": "Edmond Chow <echow23@yahoo-inc.com>", | ||
"dev": "webpack-dev-server --progress --colors --port 8090", | ||
"test": "jenkins-mocha --compilers js:babel/register tests/unit/*", | ||
"devtest": "mocha --compilers js:babel/register tests/unit/* --reporter nyan", | ||
"test": "jenkins-mocha --compilers js:babel-core/register tests/unit/*", | ||
"devtest": "mocha --compilers js:babel-core/register tests/unit/* --reporter nyan", | ||
"cover": "node node_modules/istanbul/lib/cli.js cover --dir artifacts -- ./node_modules/mocha/bin/_mocha tests/ --recursive --reporter spec", | ||
@@ -23,31 +23,33 @@ "prepublish": "npm run compile" | ||
"dependencies": { | ||
"lodash": "^4.0.0" | ||
"lodash": "4", | ||
"react": "15", | ||
"prop-types": "15" | ||
}, | ||
"peerDependencies": { | ||
"react": "^0.14.0 || ^15.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel": "^5.8.19", | ||
"babel-loader": "^5.3", | ||
"chai": "^3.2.0", | ||
"coveralls": "^2.11.2", | ||
"debug": "^2.0.0", | ||
"grunt": "^0.4.5", | ||
"grunt-babel": "^5.0", | ||
"grunt-cli": "^1.0.0", | ||
"grunt-concurrent": "^1.0.0", | ||
"grunt-contrib-clean": "^1.0.0", | ||
"grunt-contrib-copy": "^1.0.0", | ||
"grunt-nodemon": "^0.4.0", | ||
"grunt-webpack": "^1.0.8", | ||
"http-server": "^0.9.0", | ||
"istanbul": "^0.4.0", | ||
"jenkins-mocha": "^2.2", | ||
"jshint": "^2.5.5", | ||
"json-loader": "^0.5.1", | ||
"mocha": "^2.2.5", | ||
"nodemon": "^1.2.1", | ||
"react": "^15.0.0", | ||
"webpack": "^1.4.12", | ||
"webpack-dev-server": "^1.6.5" | ||
"babel-cli": "6", | ||
"babel-core": "6", | ||
"babel-loader": "7", | ||
"babel-preset-env": "1", | ||
"babel-preset-react": "6", | ||
"chai": "3", | ||
"coveralls": "2", | ||
"debug": "2", | ||
"grunt": "1", | ||
"grunt-babel": "6", | ||
"grunt-cli": "1", | ||
"grunt-concurrent": "2", | ||
"grunt-contrib-clean": "1", | ||
"grunt-contrib-copy": "1", | ||
"grunt-nodemon": "0.4", | ||
"grunt-webpack": "3", | ||
"http-server": "0.10", | ||
"istanbul": "0.4", | ||
"jenkins-mocha": "4", | ||
"jshint": "2", | ||
"json-loader": "0", | ||
"mocha": "3", | ||
"nodemon": "1", | ||
"react-dom": "15", | ||
"webpack": "2", | ||
"webpack-dev-server": "2" | ||
}, | ||
@@ -54,0 +56,0 @@ "precommit": [ |
@@ -6,2 +6,4 @@ <img src="https://avatars2.githubusercontent.com/u/6412038?v=3&s=200" alt="react logo" title="react" align="right" width="64" height="64" /> | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/yahoo/react-cartographer.svg)](https://greenkeeper.io/) | ||
[![npm version](https://badge.fury.io/js/react-cartographer.svg)](http://badge.fury.io/js/react-cartographer) | ||
@@ -8,0 +10,0 @@ [![Build Status](https://travis-ci.org/yahoo/react-cartographer.svg?branch=master)](https://travis-ci.org/yahoo/react-cartographer) |
@@ -5,6 +5,4 @@ /** | ||
*/ | ||
'use strict'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types' | ||
import MapLocationFactory from '../lib/mapLocationFactory'; | ||
@@ -15,78 +13,72 @@ | ||
export default class Map extends React.Component { | ||
static propTypes = { | ||
providerKey: React.PropTypes.string.isRequired, | ||
provider: React.PropTypes.oneOf(['yahoo', 'google', 'bing']), | ||
mapId: React.PropTypes.string.isRequired, | ||
addressLine1: React.PropTypes.string, | ||
city: React.PropTypes.string, | ||
state: React.PropTypes.string, | ||
country: React.PropTypes.string, | ||
longitude: React.PropTypes.number, | ||
latitude: React.PropTypes.number, | ||
height: React.PropTypes.number.isRequired, | ||
width: React.PropTypes.number.isRequired, | ||
zoom: React.PropTypes.number, | ||
useBackgroundImageStyle: React.PropTypes.bool | ||
} | ||
export default function Map (props) { | ||
const location = factory.getMap({ | ||
providerKey: props.providerKey, | ||
provider: props.provider, | ||
mapId: props.mapId, | ||
line1: props.addressLine1, | ||
line2: [props.city, props.state].join(','), | ||
line3: props.country, | ||
longitude: props.longitude, | ||
latitude: props.latitude, | ||
height: props.height, | ||
width: props.width, | ||
zoom: props.zoom | ||
}); | ||
let locationText; | ||
let locationLink; | ||
let style; | ||
static defaultProps = { | ||
provider: 'yahoo', | ||
mapId: 'map', | ||
height: 270, | ||
width: 580, | ||
zoom: 10, | ||
useBackgroundImageStyle: false | ||
if (!location.data || !location.data.locationLink) { | ||
return null; | ||
} | ||
getLocation () { | ||
return factory.getMap({ | ||
providerKey: this.props.providerKey, | ||
provider: this.props.provider, | ||
mapId: this.props.mapId, | ||
line1: this.props.addressLine1, | ||
line2: [this.props.city, this.props.state].join(','), | ||
line3: this.props.country, | ||
longitude: this.props.longitude, | ||
latitude: this.props.latitude, | ||
height: this.props.height, | ||
width: this.props.width, | ||
zoom: this.props.zoom | ||
}); | ||
} | ||
locationText = location.data.locationText; | ||
locationLink = location.data.locationLink; | ||
style = { | ||
width: props.width, | ||
height: props.height | ||
}; | ||
render () { | ||
const location = this.getLocation(); | ||
let locationText; | ||
let locationLink; | ||
let style; | ||
if (!location.data || !location.data.locationLink) { | ||
return null; | ||
} | ||
locationText = location.data.locationText; | ||
locationLink = location.data.locationLink; | ||
if (props.useBackgroundImageStyle) { | ||
style = { | ||
width: this.props.width, | ||
height: this.props.height | ||
width: '100%', | ||
height: props.height, | ||
background: `url(${locationLink}) no-repeat` | ||
}; | ||
} | ||
if (this.props.useBackgroundImageStyle) { | ||
style = { | ||
width: '100%', | ||
height: this.props.height, | ||
background: `url(${locationLink}) no-repeat` | ||
}; | ||
} | ||
return ( | ||
<div style={style} className="cartographer-container"> | ||
{ | ||
!props.useBackgroundImageStyle ? | ||
<img src={locationLink} alt={locationText} title={locationText} /> : null | ||
} | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div style={style} className="cartographer-container"> | ||
{ | ||
!this.props.useBackgroundImageStyle ? | ||
<img src={locationLink} alt={locationText} title={locationText} /> : null | ||
} | ||
</div> | ||
); | ||
} | ||
Map.propTypes = { | ||
providerKey: PropTypes.string.isRequired, | ||
provider: PropTypes.oneOf(['yahoo', 'google', 'bing']), | ||
mapId: PropTypes.string.isRequired, | ||
addressLine1: PropTypes.string, | ||
city: PropTypes.string, | ||
state: PropTypes.string, | ||
country: PropTypes.string, | ||
longitude: PropTypes.number, | ||
latitude: PropTypes.number, | ||
height: PropTypes.number.isRequired, | ||
width: PropTypes.number.isRequired, | ||
zoom: PropTypes.number, | ||
useBackgroundImageStyle: PropTypes.bool | ||
}; | ||
Map.defaultProps = { | ||
provider: 'yahoo', | ||
mapId: 'map', | ||
height: 270, | ||
width: 580, | ||
zoom: 10, | ||
useBackgroundImageStyle: false | ||
}; |
@@ -29,7 +29,6 @@ /** | ||
new webpack.NormalModuleReplacementPlugin(/^react?$/, require.resolve('react')), | ||
new webpack.NormalModuleReplacementPlugin(/^react(\/addons)?$/, require.resolve('react/addons')) | ||
], | ||
resolve: { | ||
extensions: ['', '.js', '.jsx'] | ||
extensions: ['.js', '.jsx'] | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
162052
29
1058
181
1
3
26
+ Addedprop-types@15
+ Addedreact@15
Updatedlodash@4