
var panPercentage = 0.1;


function zoomIn() {
map.setZoom(map.getZoom() + 1);
}

function zoomOut() {
map.setZoom(map.getZoom() - 1);
}


function setMapType(mapType) {
	map.setMapType(mapType);
}

function aroundTheWorldLngSpan(NE,SW) {
	if (SW > NE) {
		NE = NE + 360;			
	}
	return Math.abs(NE - SW);
}	


function aroundTheWorldLngPan(lng) {
	if (lng < -180) {
		lng = lng + 360;			
	}
	else if (lng > 180) {
		lng = lng - 360;
	}
	return lng;
}	

function limitNS(lat) {
	if (lat > 85) {
		lat = 85;
	}
	else if (lat < -85) {
		lat = -85;
	}
	return lat;
}

function lngSpan() {
	var bounds = map.getBounds(); // the boundary coordinates for the current view
	var southWest = bounds.getSouthWest(); // the South-West corner of the boundary
	var northEast = bounds.getNorthEast(); // the North-East corner of the boundary
	return aroundTheWorldLngSpan(northEast.lng(), southWest.lng());
}

function latSpan() {
	var bounds = map.getBounds(); // the boundary coordinates for the current view
	var southWest = bounds.getSouthWest(); // the South-West corner of the boundary
	var northEast = bounds.getNorthEast(); // the North-East corner of the boundary
	return Math.abs(northEast.lat() - southWest.lat());		
}

function panWest () {
	map.panTo(new GLatLng(map.getCenter().lat(), aroundTheWorldLngPan(map.getCenter().lng() - (lngSpan() * panPercentage))));
}

function panEast () {
	map.panTo(new GLatLng(map.getCenter().lat(), aroundTheWorldLngPan(map.getCenter().lng() + (lngSpan() * panPercentage))));
}

function panNorth () {
	map.panTo(new GLatLng(limitNS(map.getCenter().lat() + (latSpan() * panPercentage)), map.getCenter().lng()));
}

function panSouth () {
	map.panTo(new GLatLng(limitNS(map.getCenter().lat() - (latSpan() * panPercentage)), map.getCenter().lng()));
}

