@@ -5,8 +5,6 @@ const classNames = require('classnames');
55
66const STATIC_URL = 'https://maps.googleapis.com/maps/api/staticmap?markers=color:MARKER_COLOR|LATITUDE,LONGITUDE&zoom=ZOOM&size=270x200&scale=2&key=KEY' ;
77const MAP_URL = 'https://www.google.com/maps/search/?api=1&query=LATITUDE,LONGITUDE&zoom=ZOOM' ;
8- const DEFAULT_MARKER_COLOR = 'red' ;
9- const DEFAULT_ZOOM_LEVEL = 14 ;
108
119export class LocationMessage extends Component {
1210 constructor ( props ) {
@@ -20,19 +18,19 @@ export class LocationMessage extends Component {
2018
2119 return url . replace ( 'LATITUDE' , center . latitude )
2220 . replace ( 'LONGITUDE' , center . longitude )
23- . replace ( 'MARKER_COLOR' , this . props . markerColor || DEFAULT_MARKER_COLOR )
24- . replace ( 'ZOOM' , this . props . zoom || DEFAULT_ZOOM_LEVEL )
21+ . replace ( 'MARKER_COLOR' , this . props . markerColor )
22+ . replace ( 'ZOOM' , this . props . zoom )
2523 . replace ( 'KEY' , this . props . apiKey ) ;
2624 }
2725
2826 className ( ) {
29- var className = classNames ( 'rce-mbox-location' , this . props . className ) ;
27+ var className = classNames ( 'rce-mbox-location' , this . props . className ) ;
3028
31- if ( this . props . text && this . props . text . length > 0 ) {
32- className = classNames ( className , 'rce-mbox-location-has-text' ) ;
33- }
29+ if ( this . props . text ) {
30+ className = classNames ( className , 'rce-mbox-location-has-text' ) ;
31+ }
3432
35- return className ;
33+ return className ;
3634 }
3735
3836 render ( ) {
@@ -43,11 +41,11 @@ export class LocationMessage extends Component {
4341 target = { this . props . target }
4442 href = { this . props . href || this . props . src || this . buildURL ( MAP_URL ) }
4543 className = { this . className ( ) } >
46- < img className = 'rce-mbox-location-img'
47- src = {
48- this . props . src ||
49- this . buildURL ( STATIC_URL )
50- } />
44+ < img className = 'rce-mbox-location-img'
45+ src = {
46+ this . props . src ||
47+ this . buildURL ( STATIC_URL )
48+ } />
5149 </ a >
5250 {
5351 this . props . text &&
@@ -63,6 +61,8 @@ export class LocationMessage extends Component {
6361LocationMessage . defaultProps = {
6462 target : '_blank' ,
6563 apiKey : '' ,
64+ zoom : 14 ,
65+ markerColor : 'red' ,
6666}
6767
6868export default LocationMessage ;
0 commit comments