Added Center Map Function
This commit is contained in:
Binary file not shown.
@@ -113,11 +113,11 @@ public class AirlineGraphController extends Controller{
|
|||||||
countries.put(airline.getCountryName(), 1);
|
countries.put(airline.getCountryName(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = 10;
|
int length = 10;
|
||||||
if (airlinesFiltered.length < 10){
|
if (airlinesFiltered.length < 10){
|
||||||
length = airlinesFiltered.length;
|
length = airlinesFiltered.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0 ; i < length; i ++) {
|
for (int i = 0 ; i < length; i ++) {
|
||||||
int max = 0;
|
int max = 0;
|
||||||
String maxCountry = null;
|
String maxCountry = null;
|
||||||
@@ -130,7 +130,7 @@ public class AirlineGraphController extends Controller{
|
|||||||
series.getData().add(new XYChart.Data<String, Integer>(maxCountry, max));
|
series.getData().add(new XYChart.Data<String, Integer>(maxCountry, max));
|
||||||
countries.remove(maxCountry);
|
countries.remove(maxCountry);
|
||||||
}
|
}
|
||||||
|
System.out.println(countries.size());
|
||||||
countryGraph.getData().add(series);
|
countryGraph.getData().add(series);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class Map {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map(WebView webView, final ArrayList<RoutePath> newRoute, final int type){
|
public Map(WebView webView, final ArrayList<RoutePath> newRoute, final int type){
|
||||||
|
|||||||
@@ -28,6 +28,10 @@
|
|||||||
center: {lat: 39.144684, lng: -84.510079},
|
center: {lat: 39.144684, lng: -84.510079},
|
||||||
zoom: 5
|
zoom: 5
|
||||||
});
|
});
|
||||||
|
google.maps.event.addListener(map, 'center_changed', function() {
|
||||||
|
checkBounds(map);
|
||||||
|
});
|
||||||
|
map.setOptions({ minZoom: 2, maxZoom: 18});
|
||||||
|
|
||||||
new google.maps.Marker({
|
new google.maps.Marker({
|
||||||
position: {lat: 39.144684, lng: -84.510079},
|
position: {lat: 39.144684, lng: -84.510079},
|
||||||
@@ -42,6 +46,12 @@
|
|||||||
zoom: 5
|
zoom: 5
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
google.maps.event.addListener(map, 'center_changed', function() {
|
||||||
|
checkBounds(map);
|
||||||
|
});
|
||||||
|
map.setOptions({ minZoom: 2, maxZoom: 18});
|
||||||
|
|
||||||
new google.maps.Marker({
|
new google.maps.Marker({
|
||||||
position: position[0],
|
position: position[0],
|
||||||
map: map,
|
map: map,
|
||||||
@@ -54,6 +64,11 @@
|
|||||||
center: positions[0],
|
center: positions[0],
|
||||||
zoom: 5
|
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 ++) {
|
for (var i = 0; i < positions.length; i ++) {
|
||||||
new google.maps.Marker({
|
new google.maps.Marker({
|
||||||
position: positions[i][0],
|
position: positions[i][0],
|
||||||
@@ -69,6 +84,11 @@
|
|||||||
center: {lat: 39.144684, lng: -84.510079},
|
center: {lat: 39.144684, lng: -84.510079},
|
||||||
zoom: 15
|
zoom: 15
|
||||||
});
|
});
|
||||||
|
|
||||||
|
google.maps.event.addListener(map, 'center_changed', function() {
|
||||||
|
checkBounds(map);
|
||||||
|
});
|
||||||
|
map.setOptions({ minZoom: 2, maxZoom: 18});
|
||||||
// CLEAR EXISTING MARKERS
|
// CLEAR EXISTING MARKERS
|
||||||
if (marker1 !== undefined && marker2 !== undefined && path !== undefined) {
|
if (marker1 !== undefined && marker2 !== undefined && path !== undefined) {
|
||||||
marker1.setMap(null);
|
marker1.setMap(null);
|
||||||
@@ -110,6 +130,11 @@
|
|||||||
center: {lat: 0, lng: 0},
|
center: {lat: 0, lng: 0},
|
||||||
zoom: 5
|
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++) {
|
for (var i = 0; i < flightPaths.length; i++) {
|
||||||
var tempMarker1 = null;
|
var tempMarker1 = null;
|
||||||
var tempMarker2 = null;
|
var tempMarker2 = null;
|
||||||
@@ -165,6 +190,31 @@
|
|||||||
|
|
||||||
map.fitBounds(bounds);
|
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>
|
||||||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBnt2PJyKZsh-qrsTkbZwSGuUNWPromlLg&callback=initMap" defer></script>
|
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBnt2PJyKZsh-qrsTkbZwSGuUNWPromlLg&callback=initMap" defer></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user