Make scrolling smoother
This commit is contained in:
parent
26eac396c0
commit
61a4877ecb
|
@ -15,9 +15,6 @@ $(function() {
|
||||||
var isWindowOpen = false;
|
var isWindowOpen = false;
|
||||||
var hydrantIds = [];
|
var hydrantIds = [];
|
||||||
function addMarker(hydrantId, point, color) {
|
function addMarker(hydrantId, point, color) {
|
||||||
if($.inArray(hydrantId, hydrantIds) != -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var image = new google.maps.MarkerImage(color,
|
var image = new google.maps.MarkerImage(color,
|
||||||
new google.maps.Size(27.0, 37.0),
|
new google.maps.Size(27.0, 37.0),
|
||||||
new google.maps.Point(0, 0),
|
new google.maps.Point(0, 0),
|
||||||
|
@ -85,38 +82,24 @@ $(function() {
|
||||||
} else {
|
} else {
|
||||||
$('#address_label').removeClass('error', 500);
|
$('#address_label').removeClass('error', 500);
|
||||||
$('#address').removeClass('error', 500);
|
$('#address').removeClass('error', 500);
|
||||||
var northMost;
|
var i = -1;
|
||||||
var eastMost;
|
|
||||||
var southMost;
|
|
||||||
var westMost;
|
|
||||||
var i = 0;
|
|
||||||
$(data).each(function(index, hydrant) {
|
$(data).each(function(index, hydrant) {
|
||||||
hydrant = hydrant.hydrant;
|
hydrant = hydrant.hydrant;
|
||||||
if(!northMost || northMost > hydrant.lat) {
|
if($.inArray(hydrant.id, hydrantIds) == -1) {
|
||||||
northMost = hydrant.lat;
|
i += 1;
|
||||||
}
|
} else {
|
||||||
if(!eastMost || eastMost > hydrant.lng) {
|
// continue
|
||||||
eastMost = hydrant.lng;
|
return true;
|
||||||
}
|
|
||||||
if(!southMost || southMost < hydrant.lat) {
|
|
||||||
southMost = hydrant.lat;
|
|
||||||
}
|
|
||||||
if(!westMost || westMost < hydrant.lng) {
|
|
||||||
westMost = hydrant.lng;
|
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
point = new google.maps.LatLng(hydrant.lat, hydrant.lng);
|
point = new google.maps.LatLng(hydrant.lat, hydrant.lng);
|
||||||
color = '/images/markers/' + (hydrant.user_id ? 'green' : 'red') + '.png';
|
color = '/images/markers/' + (hydrant.user_id ? 'green' : 'red') + '.png';
|
||||||
addMarker(hydrant.id, point, color);
|
addMarker(hydrant.id, point, color);
|
||||||
}, i * 100);
|
}, i * 100);
|
||||||
if($.inArray(hydrant.id, hydrantIds) == -1) {
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
southWest = new google.maps.LatLng(southMost, westMost);
|
center = new google.maps.LatLng(lat, lng);
|
||||||
northEast = new google.maps.LatLng(northMost, eastMost);
|
map.setCenter(center);
|
||||||
bounds = new google.maps.LatLngBounds(southWest, northEast);
|
map.setZoom(18);
|
||||||
map.fitBounds(bounds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue