refactor and fix leaflet display bug