質問編集履歴
1
コード修正したので追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -142,4 +142,120 @@
|
|
142
142
|
|
143
143
|
|
144
144
|
|
145
|
+
jsonデータをループさせました。間違えてたらごめんなさい。
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
```lang-<javascript>
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
var data = new Array();
|
156
|
+
|
157
|
+
var geocoder = new google.maps.Geocoder();
|
158
|
+
|
159
|
+
var encode = 'db→PHP→jsonencodeしたデータ';
|
160
|
+
|
161
|
+
var addressAr = JSON.parse(encode);
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
for(i=0; i<addressAr.length; i++)
|
166
|
+
|
167
|
+
{
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
geocoder.geocode(
|
174
|
+
|
175
|
+
{ address: addressAr[i] },
|
176
|
+
|
177
|
+
function( results, status )
|
178
|
+
|
179
|
+
{
|
180
|
+
|
181
|
+
if( status == google.maps.GeocoderStatus.OK )
|
182
|
+
|
183
|
+
{
|
184
|
+
|
185
|
+
lat = results[0].geometry.location.k;
|
186
|
+
|
187
|
+
lng = results[0].geometry.location.D;
|
188
|
+
|
189
|
+
console.log(lat,lng);
|
190
|
+
|
191
|
+
/*
|
192
|
+
|
193
|
+
35.1927384 136.88722489999998
|
194
|
+
|
195
|
+
(index):96 35.1589488 136.8899139
|
196
|
+
|
197
|
+
(index):96 35.1754295 136.8752482
|
198
|
+
|
199
|
+
(index):96 35.1687471 136.87301509999998
|
200
|
+
|
201
|
+
(index):96 35.1676346 136.91235329999995
|
202
|
+
|
203
|
+
(index):96 35.1671924 136.89628530000005
|
204
|
+
|
205
|
+
(index):96 35.1536495 136.89023900000007
|
206
|
+
|
207
|
+
(index):96 35.1742916 136.89973759999998
|
208
|
+
|
209
|
+
*/
|
210
|
+
|
211
|
+
data.push({position: new google.maps.LatLng(lat,lng), content: 'ab'})
|
212
|
+
|
213
|
+
/*dataのデータが増えない*/
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
else
|
218
|
+
|
219
|
+
{
|
220
|
+
|
221
|
+
alert( 'Faild:' + status );
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
);
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
console.log(data.length); // 0
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
for (i = 0; i < data.length; i++) {
|
238
|
+
|
239
|
+
var myMarker = new google.maps.Marker({
|
240
|
+
|
241
|
+
position: data[i].position,
|
242
|
+
|
243
|
+
map: mapdiv
|
244
|
+
|
245
|
+
});
|
246
|
+
|
247
|
+
attachMessage(myMarker, data[i].content);
|
248
|
+
|
249
|
+
// google.maps.InfoWindowを呼ぶプログラム
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
```
|
258
|
+
|
259
|
+
|
260
|
+
|
145
261
|
ぶしつけですみません。もし分かる方が居たら、助言を下さい・・・。
|