Added Center Map Function

main
YaFedImYaEatIm 9 years ago
parent 3374dd5da3
commit d93944fb76

Binary file not shown.

@ -113,11 +113,11 @@ public class AirlineGraphController extends Controller{
countries.put(airline.getCountryName(), 1);
}
}
int length = 10;
if (airlinesFiltered.length < 10){
length = airlinesFiltered.length;
}
for (int i = 0 ; i < length; i ++) {
int max = 0;
String maxCountry = null;
@ -130,7 +130,7 @@ public class AirlineGraphController extends Controller{
series.getData().add(new XYChart.Data<String, Integer>(maxCountry, max));
countries.remove(maxCountry);
}
System.out.println(countries.size());
countryGraph.getData().add(series);
}

@ -36,6 +36,7 @@ public class Map {
}
}
});
}
public Map(WebView webView, final ArrayList<RoutePath> newRoute, final int type){

@ -28,6 +28,10 @@
center: {lat: 39.144684, lng: -84.510079},
zoom: 5
});
google.maps.event.addListener(map, 'center_changed', function() {
checkBounds(map);
});
map.setOptions({ minZoom: 2, maxZoom: 18});
new google.maps.Marker({
position: {lat: 39.144684, lng: -84.510079},
@ -42,6 +46,12 @@
zoom: 5
});
google.maps.event.addListener(map, 'center_changed', function() {
checkBounds(map);
});
map.setOptions({ minZoom: 2, maxZoom: 18});
new google.maps.Marker({
position: position[0],
map: map,
@ -54,6 +64,11 @@
center: positions[0],
zoom: 5
});
google.maps.event.addListener(map, 'center_changed', function() {
checkBounds(map);
});
map.setOptions({ minZoom: 2, maxZoom: 18});
for (var i = 0; i < positions.length; i ++) {
new google.maps.Marker({
position: positions[i][0],
@ -69,6 +84,11 @@
center: {lat: 39.144684, lng: -84.510079},
zoom: 15
});
google.maps.event.addListener(map, 'center_changed', function() {
checkBounds(map);
});
map.setOptions({ minZoom: 2, maxZoom: 18});
// CLEAR EXISTING MARKERS
if (marker1 !== undefined && marker2 !== undefined && path !== undefined) {
marker1.setMap(null);
@ -110,6 +130,11 @@
center: {lat: 0, lng: 0},
zoom: 5
});
google.maps.event.addListener(map, 'center_changed', function() {
checkBounds(map);
});
map.setOptions({ minZoom: 2, maxZoom: 18});
for (var i = 0; i < flightPaths.length; i++) {
var tempMarker1 = null;
var tempMarker2 = null;
@ -165,6 +190,31 @@
map.fitBounds(bounds);
}
function checkBounds(map) {
var latNorth = map.getBounds().getNorthEast().lat();
var latSouth = map.getBounds().getSouthWest().lat();
var newLat;
if(latNorth<85 && latSouth>-85) /* in both side -> it's ok */
return;
else {
if(latNorth>85 && latSouth<-85) /* out both side -> it's ok */
return;
else {
if(latNorth>85)
newLat = map.getCenter().lat() - (latNorth-85); /* too north, centering */
if(latSouth<-85)
newLat = map.getCenter().lat() - (latSouth+85); /* too south, centering */
}
}
//re-centre the map
if(newLat) {
var newCenter= new google.maps.LatLng( newLat ,map.getCenter().lng() );
map.setCenter(newCenter);
}
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBnt2PJyKZsh-qrsTkbZwSGuUNWPromlLg&callback=initMap" defer></script>
</body>

Loading…
Cancel
Save