質問編集履歴
2
コード追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -81,3 +81,57 @@
|
|
81
81
|
|
82
82
|
|
83
83
|
上記のlocation.jsに書いて呼んでます。
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
location.js
|
88
|
+
|
89
|
+
```javascript
|
90
|
+
|
91
|
+
1 var map = new google.maps.Map(
|
92
|
+
|
93
|
+
2 document.getElementById("gmap"),{
|
94
|
+
|
95
|
+
3 zoom : 15,
|
96
|
+
|
97
|
+
4 center : new google.maps.LatLng(35.689160610317174, 139.70083951950073),
|
98
|
+
|
99
|
+
5 mapTypeId : google.maps.MapTypeId.ROADMAP
|
100
|
+
|
101
|
+
6 }
|
102
|
+
|
103
|
+
7 );
|
104
|
+
|
105
|
+
8
|
106
|
+
|
107
|
+
9 var ll = map.getCenter();
|
108
|
+
|
109
|
+
10 var gc = new google.maps.Geocoder();
|
110
|
+
|
111
|
+
11 gc.geocode({ location : ll }, function(results, status){
|
112
|
+
|
113
|
+
12 if (status == google.maps.GeocoderStatus.OK) {
|
114
|
+
|
115
|
+
13 var adrsData = results[0].address_components;
|
116
|
+
|
117
|
+
14 var txt = "";
|
118
|
+
|
119
|
+
15 for(var i=0; i<adrsData.length; i++){
|
120
|
+
|
121
|
+
16 txt += adrsData[i].long_name + " / ";
|
122
|
+
|
123
|
+
17 txt += adrsData[i].types + "<br>";
|
124
|
+
|
125
|
+
18 }
|
126
|
+
|
127
|
+
19 document.getElementById("result").innerHTML = txt;
|
128
|
+
|
129
|
+
20 }else{
|
130
|
+
|
131
|
+
21 alert(status+" : ジオコードに失敗しました");
|
132
|
+
|
133
|
+
22 }
|
134
|
+
|
135
|
+
23 });
|
136
|
+
|
137
|
+
```
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -29,3 +29,55 @@
|
|
29
29
|
|
30
30
|
|
31
31
|
上記箇所が原因なのは特定できたのですが、どのように書き換えるべきでしょうか。(ただ、このソースを載せている[ページ](http://www.openspc2.org/reibun/Google/Maps/API/ver3/code/map/geocoding/0003/)のサンプルは動いているので、APIのkeyに問題があるような気はするのですが、その認識で合ってますでしょうか。)
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
追記:
|
36
|
+
|
37
|
+
```html
|
38
|
+
|
39
|
+
<head>
|
40
|
+
|
41
|
+
12 <title>hoge</title>
|
42
|
+
|
43
|
+
13
|
44
|
+
|
45
|
+
14
|
46
|
+
|
47
|
+
15 <link rel="canonical" href="/link">
|
48
|
+
|
49
|
+
16
|
50
|
+
|
51
|
+
17
|
52
|
+
|
53
|
+
18 <link rel="icon" type="image/x-icon" href="/moge/assets/default/img/common/favicon.ico" />
|
54
|
+
|
55
|
+
19
|
56
|
+
|
57
|
+
20 <link rel="stylesheet" type="text/css" href="hoge.css">
|
58
|
+
|
59
|
+
21 <link rel="stylesheet" type="text/css" media="print" href="moge.css">
|
60
|
+
|
61
|
+
22 <script src="http://maps.google.com/maps/api/js?key=mykey&sensor=false"></script>
|
62
|
+
|
63
|
+
23 <script src="http://fb.me/react-0.13.3.js"></script>
|
64
|
+
|
65
|
+
24 <script src="http://fb.me/JSXTransformer-0.13.3.js"></script>
|
66
|
+
|
67
|
+
25 <script data-require="angular.js@1.2.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.min.js" data-semver="1.2.17"></script>
|
68
|
+
|
69
|
+
26 <script src="app.js"></script>
|
70
|
+
|
71
|
+
27 <script src="hoge.js"></script>
|
72
|
+
|
73
|
+
28 <script src="location.js"></script>
|
74
|
+
|
75
|
+
29
|
76
|
+
|
77
|
+
30 </head>
|
78
|
+
|
79
|
+
```
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
上記のlocation.jsに書いて呼んでます。
|