Changeset 32607 for main/trunk
- Timestamp:
- 2018-11-16T13:21:39+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js
r32604 r32607 82 82 { 83 83 var myOptions = 84 {84 { 85 85 zoom: 2, 86 86 center: new google.maps.LatLng(0, 0), … … 110 110 var lngDistance = neLng - swLng; 111 111 112 console.log("neLat = " + neLat + " neLng = " + neLng + " swLat = " + swLat + " swLng = " + swLng + " latDistance = " + latDistance + " lngDistance = " + lngDistance);113 114 112 //Check which increment to use for latitude (i.e. 0.001, 0.01, 0.1 or 1 degree increments) 115 113 var latDelta; … … 136 134 } 137 135 } 138 139 if(latDelta == 0.1){latDelta = 1; latPrecision = 0;}140 if(lngDelta == 0.1){lngDelta = 1; lngPrecision = 0;}136 137 if(latDelta == 0.1){latDelta = 1; latPrecision = 0; } 138 if(lngDelta == 0.1){lngDelta = 1; lngPrecision = 0; } 141 139 142 140 var query = ""; … … 182 180 var url = gs.xsltParams.library_name; 183 181 var data = "a=q&s=RawQuery&rt=rd&c=" + gs.cgiParams.c + "&s1.rawquery=" + query + "&excerptid=jsonNodes"; 184 185 182 $.ajax({type:"POST", url:url, data:data}) 186 183 .success(function(responseText) … … 258 255 function updateMap() 259 256 { 260 var north = -180; 261 var east = -180; 262 var south = 180; 263 var west = 180; 264 265 var markersOnMap = 0; 257 var markersOnMap = 0; 258 var bounds = new google.maps.LatLngBounds(); 266 259 for(var i = 0; i < _docList.ids.length; i++) 267 260 { 268 261 var doc = _docList.getDocByIndex(i); 269 270 262 if(doc.parentCL && doc.parentCL.style.display == "none") 271 263 { … … 278 270 markersOnMap++; 279 271 } 280 281 if(doc.lat > north) 282 { 283 north = doc.lat; 284 } 285 if(doc.lat < south) 286 { 287 south = doc.lat; 288 } 289 if(doc.lng > east) 290 { 291 east = doc.lng; 292 } 293 if(doc.lng < west) 294 { 295 west = doc.lng; 296 } 297 } 298 299 //As there is always 2 possible bounding boxes we want the smaller of the two 300 if(east - west > 180) 301 { 302 var temp = east; 303 east = west; 304 west = temp; 305 } 306 307 var bounds; 308 if(markersOnMap > 0) 309 { 310 bounds = new google.maps.LatLngBounds(new google.maps.LatLng(south, west), new google.maps.LatLng(north, east)); 311 _map.fitBounds(bounds); 312 } 272 273 bounds.extend(new google.maps.LatLng(doc.lat, doc.lng)); 274 } 275 276 if(markersOnMap > 1) 277 { 278 _map.fitBounds(bounds); 279 } else if (markersOnMap == 1) { 280 // sometimes a single point bounds are too small for the map to display, so use center and zoom instead of fitbounds. 281 _map.setCenter(bounds.getCenter()); 282 _map.setZoom(18); // arbitrary value that looked nice for my example 283 } 313 284 } 314 285 … … 438 409 marker.markerInfo = info; 439 410 doc.marker = marker; 440 441 411 attachClickHandler(marker, doc.nodeID); 442 412 }
Note:
See TracChangeset
for help on using the changeset viewer.