Changeset 6492
- Timestamp:
- 03/11/08 14:32:17 (4 months ago)
- Files:
-
- trunk/openlayers/examples/google.html (modified) (1 diff)
- trunk/openlayers/examples/spherical-mercator.html (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Control/DragPan.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/EventPane.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Google.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/examples/google.html
r6491 r6492 58 58 <div id="map"></div> 59 59 60 <div id="docs"></div> 60 <div id="docs"> 61 For best performance, you must be using a version of the Google Maps 62 API which is v2.93 or higher. In order to use this version of the API, 63 it is best to simply set your application to use the string "v=2" in 64 the request, rather than tying your application to an explicit version. 65 </div> 61 66 </body> 62 67 </html> trunk/openlayers/examples/spherical-mercator.html
r6316 r6492 12 12 13 13 <script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script> 14 <script src='http://maps.google.com/maps?file=api&v=2 .82&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>14 <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script> 15 15 <script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script> 16 16 trunk/openlayers/lib/OpenLayers/Control/DragPan.js
r5614 r6492 47 47 panMap: function(xy) { 48 48 this.panned = true; 49 var deltaX = this.handler.last.x - xy.x; 50 var deltaY = this.handler.last.y - xy.y; 51 var size = this.map.getSize(); 52 var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, 53 size.h / 2 + deltaY); 54 var newCenter = this.map.getLonLatFromViewPortPx( newXY ); 55 this.map.setCenter(newCenter, null, this.handler.dragging); 49 this.map.pan( 50 this.handler.last.x - xy.x, 51 this.handler.last.y - xy.y, 52 {dragging: this.handler.dragging, animate: false} 53 ); 56 54 }, 57 55 trunk/openlayers/lib/OpenLayers/Layer/EventPane.js
r5627 r6492 242 242 if (dragging && this.dragPanMapObject && 243 243 this.smoothDragPan) { 244 var resolution = this.map.getResolution(); 245 var dX = (newCenter.lon - oldCenter.lon) / resolution; 246 var dY = (newCenter.lat - oldCenter.lat) / resolution; 247 this.dragPanMapObject(dX, dY); 244 var oldPx = this.map.getViewPortPxFromLonLat(oldCenter); 245 var newPx = this.map.getViewPortPxFromLonLat(newCenter); 246 this.dragPanMapObject(newPx.x-oldPx.x, oldPx.y-newPx.y); 248 247 } else { 249 248 var center = this.getMapObjectLonLatFromOLLonLat(newCenter); … … 282 281 var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel); 283 282 lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat); 284 var xrem = this.map.size.w % 2;285 var yrem = this.map.size.h % 2;286 if(xrem != 0 || yrem != 0) {287 // odd sized viewport288 var olPx = viewPortPx.add(xrem, yrem);289 var moPx = this.getMapObjectPixelFromOLPixel(olPx);290 var moLoc = this.getMapObjectLonLatFromMapObjectPixel(moPx);291 var olLoc = this.getOLLonLatFromMapObjectLonLat(moLoc);292 // adjust by half a pixel in odd dimension(s)293 lonlat.lon += (olLoc.lon - lonlat.lon) / 2;294 lonlat.lat += (olLoc.lat - lonlat.lat) / 2;295 }296 283 } 297 284 return lonlat; trunk/openlayers/lib/OpenLayers/Layer/Google.js
r6442 r6492 76 76 */ 77 77 sphericalMercator: false, 78 79 /** 80 * Property: dragObject 81 * {GDraggableObject} Since 2.93, Google has exposed the ability to get 82 * the maps GDraggableObject. We can now use this for smooth panning 83 */ 84 dragObject: null, 78 85 79 86 /** … … 107 114 // create GMap, hide nav controls 108 115 this.mapObject = new GMap2( this.div ); 116 117 //since v 2.93 getDragObject is now available. 118 if(typeof this.mapObject.getDragObject == "function") { 119 this.dragObject = this.mapObject.getDragObject(); 120 } else { 121 this.dragPanMapObject = null; 122 } 123 109 124 110 125 // move the ToS and branding stuff up to the pane … … 124 139 termsOfUse.style.bottom = ""; 125 140 126 //can we do smooth panning? (some versions don't)127 if ( !this.mapObject.G || !this.mapObject.G.qb ||128 (typeof this.mapObject.G.qb != "function") ) {129 130 this.dragPanMapObject = null;131 }132 133 141 } catch (e) { 134 // do not crash142 OpenLayers.Console.error(e); 135 143 } 136 144 … … 344 352 */ 345 353 dragPanMapObject: function(dX, dY) { 346 var newX = this.mapObject.G.left - dX; 347 var newY = this.mapObject.G.top + dY; 348 this.mapObject.G.qb(newX, newY); 349 }, 350 354 this.dragObject.moveBy(new GSize(-dX, dY)); 355 }, 356 351 357 /** 352 358 * APIMethod: getMapObjectCenter trunk/openlayers/lib/OpenLayers/Map.js
r6447 r6492 1318 1318 * dx - {Integer} 1319 1319 * dy - {Integer} 1320 * options - {Object} Only one at this time: "animate", which uses 1321 * panTo instead of setCenter. Default is true. 1320 * options - {Object} Options to configure panning: 1321 * - *animate* {Boolean} Use panTo instead of setCenter. Default is true. 1322 * - *dragging* {Boolean} Call setCenter with dragging true. Default is 1323 * false. 1322 1324 */ 1323 1325 pan: function(dx, dy, options) { 1324 1326 // this should be pushed to applyDefaults and extend 1325 1327 if (!options) { 1326 options = {animate: true} 1327 } 1328 options = {}; 1329 } 1330 OpenLayers.Util.applyDefaults(options, { 1331 animate: true, 1332 dragging: false 1333 }); 1328 1334 // getCenter 1329 1335 var centerPx = this.getViewPortPxFromLonLat(this.getCenter()); … … 1332 1338 var newCenterPx = centerPx.add(dx, dy); 1333 1339 1334 // only call setCenter if there has been a change1335 if (! newCenterPx.equals(centerPx)) {1340 // only call setCenter if not dragging or there has been a change 1341 if (!options.dragging || !newCenterPx.equals(centerPx)) { 1336 1342 var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx); 1337 1343 if (options.animate) { 1338 1344 this.panTo(newCenterLonLat); 1339 1345 } else { 1340 this.setCenter(newCenterLonLat );1346 this.setCenter(newCenterLonLat, null, options.dragging); 1341 1347 } 1342 1348 }
