teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

修正

2017/03/17 15:24

投稿

ssk
ssk

スコア332

title CHANGED
File without changes
body CHANGED
@@ -144,9 +144,4 @@
144
144
  ///////////////////////////////////////////////////////////////////////
145
145
 
146
146
  window.onload = Yucho.initMap;
147
- ```
148
-
149
- ######エラー
150
- ```エラー
151
- Uncaught TypeError: Cannot read property 'getNorthEast' of undefined
152
147
  ```

2

修正

2017/03/17 15:24

投稿

ssk
ssk

スコア332

title CHANGED
File without changes
body CHANGED
@@ -67,7 +67,7 @@
67
67
  Yucho.getMapSize();
68
68
  $.ajax({
69
69
  type: "GET",
70
- url: Yucho.jsonUrl + '?min_lat=' + Yucho.swLatLng.lat() + '&max_lat=' + Yucho.neLatLng.lat() + '&min_lng=' + Yucho.swLatLng.lng() + '&max_lng=' + Yucho.neLatLng.lng(),
70
+ url: Yucho.jsonUrl + '?min_lat=' + Yucho.swLatLng.lat + '&max_lat=' + Yucho.neLatLng.lat + '&min_lng=' + Yucho.swLatLng.lng + '&max_lng=' + Yucho.neLatLng.lng,
71
71
  dataType: "json",
72
72
  }).done(function(jsonDataList){
73
73
  Yucho.jsonData = jsonDataList;

1

修正

2017/03/17 15:24

投稿

ssk
ssk

スコア332

title CHANGED
File without changes
body CHANGED
@@ -31,7 +31,7 @@
31
31
  swLatLng:{},
32
32
  swLat:{},
33
33
  swLng:{},
34
- jsonUrl:"./map.json",
34
+ jsonUrl:'/ajaxtestmaps/testsearch.json',
35
35
  jsonData:{},
36
36
  boundsData:{},
37
37
  };
@@ -43,10 +43,10 @@
43
43
 
44
44
  // googleMaps 初期設定
45
45
  Yucho.gMapInit();
46
-
46
+
47
- // json読み込み
47
+ // json読み込み
48
48
  Yucho.getJson();
49
-
49
+
50
50
  };
51
51
 
52
52
  ///////////////////////////////////////////////////////////////////////
@@ -63,14 +63,15 @@
63
63
  // JSON読み込み
64
64
  ///////////////////////////////////////////////////////////////////////
65
65
  Yucho.getJson = function(){
66
-
66
+ // マップサイズ取得
67
+ Yucho.getMapSize();
67
68
  $.ajax({
68
69
  type: "GET",
69
- url: Yucho.jsonUrl,
70
+ url: Yucho.jsonUrl + '?min_lat=' + Yucho.swLatLng.lat() + '&max_lat=' + Yucho.neLatLng.lat() + '&min_lng=' + Yucho.swLatLng.lng() + '&max_lng=' + Yucho.neLatLng.lng(),
70
- dataType: "json"
71
+ dataType: "json",
71
- }).done(function(data){
72
+ }).done(function(jsonDataList){
72
- Yucho.jsonData = data.shop;
73
+ Yucho.jsonData = jsonDataList;
73
- $('#status_all').html(Yucho.jsonData.length);
74
+ //$('#status_all').html(Yucho.jsonData.length);
74
75
 
75
76
  // googleMaps アイドル設定
76
77
  Yucho.gMapSetIdle();
@@ -90,16 +91,10 @@
90
91
  // MAPリフレッシュ
91
92
  ///////////////////////////////////////////////////////////////////////
92
93
  Yucho.refleshMap = function() {
93
-
94
+
94
95
  // マップサイズ取得
95
96
  Yucho.getMapSize();
96
97
 
97
- // データ格納
98
- Yucho.boundsData = [];
99
- for (var i = 0, l = Yucho.jsonData.length; i < l; i++) {
100
- Yucho.storeDataToRectangle(Yucho.jsonData[i]);
101
- }
102
-
103
98
  // マーカー削除
104
99
  Yucho.markerArr.forEach(function(marker, idx) {
105
100
  marker.setMap(null);
@@ -107,13 +102,13 @@
107
102
 
108
103
  // マーカー作成
109
104
  Yucho.createMarker();
110
-
111
- $('#status_bounds').html(Yucho.boundsLen);
105
+
112
-
113
106
  };
114
107
 
115
108
  ///////////////////////////////////////////////////////////////////////
116
109
  // マップサイズ取得
110
+ //getSouthWest():表示領域の南西(左下)の頂点の地理座標を返す
111
+ //getNorthEast():領域の北東(右上)の頂点の地理座標を返す
117
112
  ///////////////////////////////////////////////////////////////////////
118
113
  Yucho.getMapSize = function() {
119
114
  Yucho.boundsLen = 0;
@@ -129,36 +124,19 @@
129
124
  };
130
125
 
131
126
  ///////////////////////////////////////////////////////////////////////
132
- // データ格納(それぞれの短形領域へ)
133
- ///////////////////////////////////////////////////////////////////////
134
- Yucho.storeDataToRectangle = function(place) {
135
- Yucho.rectangleArrData[x][y] = [];
136
- var latlng = new google.maps.LatLng(place.lat,place.lng);
137
- if( Yucho.bounds.contains(latlng) ){
138
- var x = Math.floor( (Yucho.neLat - place.lat ) / Yucho.latDiff );
139
- var y = Math.floor( (place.lng - Yucho.swLng) / Yucho.lngDiff );
140
- Yucho.boundsData.push(place);
141
- Yucho.rectangleArrData[x][y].push(place);
142
- Yucho.boundsLen++;
143
- }
144
- };
145
-
146
- ///////////////////////////////////////////////////////////////////////
147
127
  // マーカー作成
148
128
  ///////////////////////////////////////////////////////////////////////
149
129
  Yucho.createMarker = function() {
150
- var dataLength = Yucho.rectangleArrData[x][y].length;
151
- if( dataLength > 0 ){
152
- var placeLoc = Yucho.rectangleArrData[x][y];
130
+ console.log(Yucho.jsonData.jsonDataList);
131
+ Yucho.jsonData.jsonDataList.forEach(function (place) {
153
- var latlng = new google.maps.LatLng(placeLoc.lat,placeLoc.lng);
132
+ var latlng = new google.maps.LatLng(place.lat,place.lan);
154
133
  var marker = new google.maps.Marker({
155
134
  position: latlng,
156
135
  map: Yucho.map,
157
136
  flat: true,
158
- content: '<div class="marker">'+dataLength+'件</div>'
159
137
  });
160
138
  Yucho.markerArr.push(marker);
161
- }
139
+ });
162
140
  };
163
141
 
164
142
  ///////////////////////////////////////////////////////////////////////
@@ -166,4 +144,9 @@
166
144
  ///////////////////////////////////////////////////////////////////////
167
145
 
168
146
  window.onload = Yucho.initMap;
147
+ ```
148
+
149
+ ######エラー
150
+ ```エラー
151
+ Uncaught TypeError: Cannot read property 'getNorthEast' of undefined
169
152
  ```