Skip to content

Commit 48ed8cf

Browse files
required changes added.
1 parent e6b5269 commit 48ed8cf

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ import { LocationMessage } from 'react-chat-elements'
428428
| ---- | ---- | ---- | ---- |
429429
| src | none | image | image src |
430430
| apiKey | none | string | google staticmap api key |
431+
| zoom | 14 | int | google staticmap zoom level |
432+
| markerColor | red | string | google staticmap marker color |
431433
| data | {} | object | message data |
432434
| target | _blank | string | image a tag target prop |
433435
| onOpen | none | function | image on open |

src/LocationMessage/LocationMessage.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.rce-mbox-location {
22
position: relative;
33
width: 250px;
4+
height: 150px;
45
overflow: hidden;
56
display: flex;
67
align-items: center;
@@ -16,7 +17,8 @@
1617
}
1718

1819
.rce-mbox-location-text {
19-
width: 250px;
20-
margin-left: -6px;
21-
margin-right: -6px;
20+
padding: 5px 0;
21+
width: 250px;
22+
margin-left: -6px;
23+
margin-right: -6px;
2224
}

src/LocationMessage/LocationMessage.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ const classNames = require('classnames');
55

66
const STATIC_URL = 'https://maps.googleapis.com/maps/api/staticmap?markers=color:MARKER_COLOR|LATITUDE,LONGITUDE&zoom=ZOOM&size=270x200&scale=2&key=KEY';
77
const 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

119
export 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 {
6361
LocationMessage.defaultProps = {
6462
target: '_blank',
6563
apiKey: '',
64+
zoom: 14,
65+
markerColor: 'red',
6666
}
6767

6868
export default LocationMessage;

0 commit comments

Comments
 (0)