Changeset 7083
- Timestamp:
- 11/26/08 01:44:04 (6 weeks ago)
- Location:
- trunk/plugins/GoogleMap
- Files:
-
- 2 modified
-
gmap_common.js (modified) (1 diff)
-
index.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/GoogleMap/gmap_common.js
r7082 r7083 78 78 function GMap_findLocationCallback(response, gmap, location_info, title, link, boundary, locations) { 79 79 if (!response || response.Status.code != 200) { 80 // alert('Can\'t retrieve this address "'+address+'"'); 80 if (process_count != undefined) 81 process_count++; 81 82 } else { 82 83 var place = response.Placemark[0]; -
trunk/plugins/GoogleMap/index.php
r7082 r7083 137 137 locationMap.enableContinuousZoom(); 138 138 locationMap.setCenter(new GLatLng(<?php echo $lat;?>, <?php echo $lng;?>), <?php echo $zoom;?>); 139 boundary = new GLatLngBounds(locationMap.getCenter()); //, new GLatLng(<?php echo $lat+0.1;?>, <?php echo $lng+0.1;?>));139 boundary = new GLatLngBounds(locationMap.getCenter()); 140 140 var locations = new Array(); 141 141 <?php 142 142 $count = 0; 143 $countRemoteQuery = 0; 143 144 foreach ($locatives as $locative) { 144 145 $locative['link'] = "$blogURL/" . ($blog['useSloganOnPost'] ? 'entry/' . URL::encode($locative['slogan'],$service['useEncodedURL']) : $locative['id']); 145 146 $row = POD::queryRow("SELECT * FROM {$database['prefix']}GMapLocations WHERE blogid = ".getBlogId()." AND address = '".POD::escapeString($locative['location'])."'"); 146 $ found = false;147 $result = 9; // 0 = found, 1 = find in client, 9 = not found 147 148 if ($row == null || empty($row)) { 148 //echo "\t\t\t/* New location query */\n";149 149 // Recursively repeat until location is found. (continuously reducing accuracy) 150 150 $addr = explode(' ', _GMap_normalizeAddress($locative['location'])); 151 151 while (true) { 152 if ($countRemoteQuery == 12) { // not to exceed script-running time limit 153 $result = 1; 154 break; 155 } 152 156 $url = "http://maps.google.co.kr/maps/geo?q=".urlencode(trim(implode(' ', $addr)))."&output=csv&sensor=false&key={$config['apiKey']}"; 153 //echo "\t\t\t/* recurse : $addr */\n";154 157 $response = requestHttp('get', $url, false, 'text/plain'); 158 $countRemoteQuery++; 155 159 if ($response === false) { 156 $ found = false;160 $result = 9; 157 161 break; 158 162 } else { … … 161 165 if ($response_csv[0] == '200') { 162 166 // Insert for later use. 163 //echo "\t\t\t/* read from api, {$locative['location']} */\n";164 167 $lat = $response_csv[2]; 165 168 $lng = $response_csv[3]; 166 169 POD::execute("INSERT INTO {$database['prefix']}GMapLocations VALUES (".getBlogId().", '".POD::escapeString($locative['location'])."', $lng, $lat, NOW())"); 167 $ found = true;170 $result = 0; 168 171 break; 169 172 } else { 170 //echo "\t\t\t/* can't retrieve result for {$locative['location']} */\n";171 173 $lat = null; $lng = null; 172 $ found = false;174 $result = 9; 173 175 if (count($addr) == 1) 174 176 break; 175 if ( !$found)177 if ($result == 9) 176 178 array_pop($addr); 177 179 continue; … … 179 181 } 180 182 } 181 if (!$found) { 182 // Not found. 183 //echo "\t\t\t/* no result for {$locative['location']} */\n"; 183 if ($result == 9) { 184 // Not found. Don't try also later. 184 185 POD::execute("INSERT INTO {$database['prefix']}GMapLocations VALUES (".getBlogId().", '".POD::escapeString($locative['location'])."', NULL, NULL, NOW())"); 185 186 } 186 187 } else { 187 //echo "\t\t\t/* read from db : {$locative['location']} */\n";188 188 $lat = $row['latitude']; 189 189 $lng = $row['longitude']; 190 $found = true; 191 } 192 if ($found && !is_null($lat)) { 190 $result = 0; 191 } 192 switch ($result) { 193 case 0: // found 193 194 echo "\t\t\tGMap_addLocationMarkDirect(locationMap, {address:GMap_normalizeAddress('{$locative['location']}'), path:'{$locative['location']}'}, '".str_replace("'", "\\'", $locative['title'])."', encodeURI('".str_replace("'", "\\'", $locative['link'])."'), new GLatLng($lat, $lng), boundary, locations);\n"; 194 } else 195 break; 196 case 1: // find in client 197 echo "\t\t\tGMap_addLocationMark(locationMap, {address:GMap_normalizeAddress('{$locative['location']}'), path:'{$locative['location']}'}, '".str_replace("'", "\\'", $locative['title'])."', encodeURI('".str_replace("'", "\\'", $locative['link'])."'), boundary, locations);\n"; 198 break; 199 case 9: 195 200 echo "\t\t\tif (process_count != undefined) process_count++;\n"; 201 } 196 202 $count++; 197 203 } 198 204 ?> 199 //window.setTimeout('locationFetchPoller(<?php echo $count;?>);', polling_interval);200 adjustToBoundary();205 window.setTimeout('locationFetchPoller(<?php echo $count;?>);', polling_interval); 206 //adjustToBoundary(); 201 207 } else { 202 208 c.innerHTML = '<p style="text-align:center; color:#c99;">이 웹브라우저는 구글맵과 호환되지 않습니다.</p>';
