Skip to content

Commit 0122c69

Browse files
Merge pull request #96 from Detaysoft/map-feature
LocationMessage mapURL and staticURL options added.
2 parents 374aa3b + fa9454a commit 0122c69

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ import { LocationMessage } from 'react-chat-elements'
462462
data={{
463463
latitude: '37.773972',
464464
longitude: '-122.431297',
465+
// staticURL: '<optional>',
466+
// mapURL: '<optional>'
465467
}}/>
466468
```
467469

example/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class App extends Component {
110110
height: 300,
111111
latitude: '37.773972',
112112
longitude: '-122.431297',
113+
staticURL: 'https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/pin-s-circle+FF0000(LONGITUDE,LATITUDE)/LONGITUDE,LATITUDE,ZOOM/270x200@2x?access_token=KEY',
113114
},
114115
onLoad: () => {
115116
console.log('Photo loaded');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-chat-elements",
3-
"version": "10.4.3",
3+
"version": "10.5.0",
44
"description": "Reactjs chat components",
55
"author": "Avare Kodcu <abdurrahmaneker58@gmail.com>",
66
"main": "dist/main.js",

src/LocationMessage/LocationMessage.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export class LocationMessage extends Component {
1616
buildURL(url) {
1717
var center = this.props.data || {};
1818

19-
return url.replace('LATITUDE', center.latitude)
20-
.replace('LONGITUDE', center.longitude)
19+
return url.replace(/LATITUDE/g, center.latitude)
20+
.replace(/LONGITUDE/g, center.longitude)
2121
.replace('MARKER_COLOR', this.props.markerColor)
2222
.replace('ZOOM', this.props.zoom)
2323
.replace('KEY', this.props.apiKey);
@@ -34,19 +34,21 @@ export class LocationMessage extends Component {
3434
}
3535

3636
render() {
37+
const data = this.props.data || {};
38+
3739
return (
3840
<div className='rce-container-lmsg'>
3941
<a
4042
onClick={this.props.onOpen}
4143
target={this.props.target}
42-
href={this.props.href || this.props.src || this.buildURL(MAP_URL)}
44+
href={this.props.href || this.props.src || this.buildURL(data.mapURL || MAP_URL)}
4345
className={this.className()}>
4446
<img
4547
onError={this.props.onError}
4648
className='rce-mbox-location-img'
4749
src={
4850
this.props.src ||
49-
this.buildURL(STATIC_URL)
51+
this.buildURL(data.staticURL || STATIC_URL)
5052
}/>
5153
</a>
5254
{

0 commit comments

Comments
 (0)