質問編集履歴
2
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -127,3 +127,13 @@
|
|
127
127
|
/>
|
128
128
|
|
129
129
|
```
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
参考:
|
134
|
+
|
135
|
+
stack overflowにて同様の質問をしています。
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
https://ja.stackoverflow.com/questions/77553/googleplacesautocomplete%e3%81%a8google-map-react%e3%82%92%e5%85%b1%e5%ad%98%e3%81%95%e3%81%9b%e3%82%8b%e6%96%b9%e6%b3%95
|
1
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -33,6 +33,44 @@
|
|
33
33
|
```Map.js
|
34
34
|
|
35
35
|
import GoogleMapReact from "google-map-react";
|
36
|
+
|
37
|
+
...
|
38
|
+
|
39
|
+
//住所から地名を取得
|
40
|
+
|
41
|
+
const Geocoding = useCallback(() => {
|
42
|
+
|
43
|
+
Geocode.setApiKey("AIzaSyDUDTHfWX33hew2WbRittJIKhHfVWgz5dY");
|
44
|
+
|
45
|
+
Geocode.fromAddress(prop.address).then(
|
46
|
+
|
47
|
+
(response) => {
|
48
|
+
|
49
|
+
const { lat, lng } = response.results[0].geometry.location;
|
50
|
+
|
51
|
+
setSpotLat(lat);
|
52
|
+
|
53
|
+
setSpotLng(lng);
|
54
|
+
|
55
|
+
console.log(lat, lng);
|
56
|
+
|
57
|
+
},
|
58
|
+
|
59
|
+
(error) => {
|
60
|
+
|
61
|
+
console.error(error);
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
);
|
66
|
+
|
67
|
+
}, [prop.address]);
|
68
|
+
|
69
|
+
useEffect(() => {
|
70
|
+
|
71
|
+
Geocoding();
|
72
|
+
|
73
|
+
}, [Geocoding]);
|
36
74
|
|
37
75
|
...
|
38
76
|
|