Я сейчас работаю над моей ссылкой (ReactJS Google Map) . и я сделал этот проект в ReactJS и Laravel.
Я не понимаю, почему tomchentw API Json Data работает на моей карте Google, однако мой собственный API Json Data выдает ошибку
Hc {сообщение: «не LatLng или LatLngLiteral: не объект», имя: «InvalidValueError», стек: «Ошибка» на новом Hc (https://maps.googleapis.com/m…stanc InvalidValueError: setPosition: не LatLng или LatLngLiteral: in свойство lat: не число
Hc {сообщение: «не LatLng или LatLngLiteral: не объект», имя: «InvalidValueError», стек: «Ошибка» на новом Hc (https://maps.googleapis.com/m…stanc
InvalidValueError: setPosition: не LatLng или LatLngLiteral: in свойство lat: не число
tomchentw: API DATA https://gist.githubusercontent.com/farrrr/dfda7dd7fccfec5474d3/raw/758852bbc1979f6c4522ab4e92d1c92cba8fb0dc/data.json
мой собственный: API DATA
Мои коды:
{props.markers.map(marker => ( <Marker key={marker.id} position={{ lat: marker.store_lat, lng: marker.store_long }} /> ))} componentDidMount() { axios.get('/api/googlemapstore') .then(response => { this.setState({ markers: response.data }) }) }
Томченту Коды:
{props.markers.map(marker => ( <Marker key={marker.photo_id} position={{ lat: marker.latitude, lng: marker.longitude }} /> ))} fetch('https://gist.githubusercontent.com/farrrr/dfda7dd7fccfec5474d3/raw/758852bbc1979f6c4522ab4e92d1c92cba8fb0dc/data.json') .then(res => res.json()) .then(data => { this.setState({ markers: data.photos }); });
Это потому, что значения в ваших данных являются строками, а не числами.
У вас есть:
'store_lat': '53.628301'
Должно быть:
'store_lat': 53.628301