First, you'll need to get the bounds of your polygon. Use the getBounds
function described here to get the bounds of your polygon.
// This will return an L.LatLngBounds object
var polygonBounds = polygon.getBounds();
Then, check to see if the bounds of your polygon are contained within the bounds of your map.
// Getting the bounds of the map (you know how to do this)
var mapBounds = map.getBounds();
// Now, determine if the polygon bounds are within the map bounds
var contains = mapBounds.contains(polygonBounds);
This contains
boolean will now be true if the map bounds completely contains your polygon, and false if it does not.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…