我正在使用react-google-maps
,我能够显示位置lan
,lat
但我找不到任何使用共享链接显示位置的方法,例如
https://goo.gl/maps/YBuwmbwH21yUE19Z9
我想在谷歌地图中显示这个链接
这是我的代码:
withGoogleMap(props => (
<GoogleMap
defaultZoom={17}
defaultCenter={{ lat: props.lat, lng: props.lng }}
>
{props.isMarkerShown && (
<Marker
clickable={true}
title={'asdasdads'}
position={{ lat: props.lat, lng: props.lng }}
/>
)}
</GoogleMap>
)),
);
const Location = ({ URL }) => {
var splitUrl = URL.split('!3d');
var latLong = splitUrl[splitUrl.length - 1].split('!4d');
var longitude;
if (latLong.indexOf('?') !== -1) {
longitude = latLong[1].split('\\?')[0];
} else {
longitude = latLong[1];
}
var latitude = latLong[0];
return (
<div
className={`box-dashboard d-flex justify-content-center align-items-center bg-white mb-4`}
>
<MyMapComponent
lat={parseFloat(latitude)}
lng={parseFloat(longitude)}
isMarkerShown
googleMapURL={`https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places&key=${YOUR_GOOGLE_API_KEY}`}
loadingElement={<div style={{ height: `100%` }} />}
containerElement={<div style={{ height: `300px`, width: '100%' }} />}
mapElement={<div style={{ height: `100%` }} />}
/>
</div>
);
};
请帮助我,谢谢