opening josm will only load the current view if you are close enough,

opening josm will no longer trigger a constant loading symbol in
browsers
This commit is contained in:
DennisSchiefer 2012-04-25 15:01:20 +01:00
parent 94ca30c690
commit 369edbe9a7
2 changed files with 23 additions and 9 deletions

View File

@ -43,6 +43,14 @@ OSRM.MapView = L.Map.extend({
bounds.extend( this.unproject(ne_point,zoom) );
this.fitBounds( bounds );
},
getBoundsUI: function(unbounded) {
var bounds = this.getPixelBounds();
if( OSRM.GUI.visible == true )
bounds.min.x+=OSRM.GUI.width;
var sw = this.unproject(new L.Point(bounds.min.x, bounds.max.y), this._zoom, true),
ne = this.unproject(new L.Point(bounds.max.x, bounds.min.y), this._zoom, true);
return new L.LatLngBounds(sw, ne);
},
getCenterUI: function(unbounded) {
var viewHalf = this.getSize();
if( OSRM.GUI.visible == true )

View File

@ -78,16 +78,22 @@ inputChanged: function(marker_id) {
// click: button "open JOSM"
openJOSM: function() {
var x = OSRM.G.map.getCenterUI();
var ydelta = 0.01;
var xdelta = ydelta * 2;
var p = [ 'left=' + (x.lng - xdelta), 'bottom=' + (x.lat - ydelta), 'right=' + (x.lng + xdelta), 'top=' + (x.lat + ydelta)];
var url = 'http://localhost:8111/load_and_zoom?' + p.join('&');
var center = OSRM.G.map.getCenterUI();
var bounds = OSRM.G.map.getBoundsUI();
var frame = L.DomUtil.create('iframe', null, document.body);
frame.style.width = frame.style.height = "0px";
var xdelta = Math.min(0.02, Math.abs(bounds.getSouthWest().lng - center.lng) );
var ydelta = Math.min(0.01, Math.abs(bounds.getSouthWest().lat - center.lat) );
var p = [ 'left=' + (center.lng - xdelta), 'bottom=' + (center.lat - ydelta), 'right=' + (center.lng + xdelta), 'top=' + (center.lat + ydelta)];
var url = 'http://127.0.0.1:8111/load_and_zoom?' + p.join('&');
var frame = document.getElementById('josm-frame');
if(!frame) {
frame = L.DomUtil.create('iframe', null, document.body);
frame.style.display = "none";
frame.id = 'josm-frame';
}
frame.src = url;
frame.onload = function(e) { document.body.removeChild(frame); };
},
//click: button "open OSM Bugs"
@ -111,4 +117,4 @@ deleteMarker: function(marker_id) {
OSRM.G.markers.highlight.hide();
}
};
};