Permalink
Browse files

A moveend event in the init and a try/catch in getBounds recommended by

  • Loading branch information...
1 parent 1f5128a commit a22445e159108f7a7fd84282b007576018536eb4 @palewire committed Dec 19, 2011
Showing with 13 additions and 5 deletions.
  1. +13 −5 source/mxn.leaflet.core.js
View
18 source/mxn.leaflet.core.js
@@ -4,9 +4,13 @@ Mapstraction: {
init: function(element, api) {
if (typeof(L) != 'undefined') {
+ var me = this;
var map = new L.Map(element.id, {
zoomControl: false
});
+ map.addEventListener('moveend', function(){
+ me.endPan.fire();
+ });
this.layers = {};
this.features = [];
this.maps[api] = map;
@@ -126,11 +130,15 @@ Mapstraction: {
getBounds: function () {
var map = this.maps[this.api];
- var ne, sw, nw, se;
- var box = map.getBounds();
- sw = box.getSouthWest();
- ne = box.getNorthEast();
- return new mxn.BoundingBox(sw.lat, sw.lng, ne.lat, ne.lng);
+ try {
+ var box = map.getBounds();
+ var ne, sw, nw, se;
+ sw = box.getSouthWest();
+ ne = box.getNorthEast();
+ return new mxn.BoundingBox(sw.lat, sw.lng, ne.lat, ne.lng);
+ } catch(e){
+ return;
+ }
},
setBounds: function(bounds){

0 comments on commit a22445e

Please sign in to comment.