fixed problem when leaflet is loaded externally