Support sharing custom locations. (#7185)

Add the ability to click on the map to share a specific named location.
This commit is contained in:
Matthew Hodgson 2021-12-06 10:13:06 +00:00 committed by GitHub
parent 1262021417
commit 684b0617ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 14 deletions

View file

@ -76,15 +76,22 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
componentDidMount() {
const config = SdkConfig.get();
const coordinates = new maplibregl.LngLat(this.coords.longitude, this.coords.latitude);
this.map = new maplibregl.Map({
container: this.getBodyId(),
style: config.map_style_url,
center: [this.coords.longitude, this.coords.latitude],
center: coordinates,
zoom: 13,
});
new maplibregl.Marker()
.setLngLat([this.coords.longitude, this.coords.latitude])
new maplibregl.Popup({
closeButton: false,
closeOnClick: false,
closeOnMove: false,
})
.setLngLat(coordinates)
.setHTML(this.description)
.addTo(this.map);
this.map.on('error', (e)=>{
@ -106,7 +113,6 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
return <div className="mx_MLocationBody">
<div id={this.getBodyId()} className="mx_MLocationBody_map" />
{ error }
<span className="mx_EventTile_body">{ this.description }</span>
</div>;
}
}