Reputation: 13300
Leaflet is rendering because I can see all of its elements in the DOM, but nothing else comes to life. All I see is gray.
The only way I can get map tiles to appear is if I delete the position:absolute on the map container, but that creates a bunch of jumbled map tiles. I checked the GIT history to see if I accidentally changed a style, but no luck.
Here's the code initializing the map:
// init everything on page show
$("#map").live('pageshow',function() {
if(window.localStorage.getItem("lat")!=undefined) { var lat = window.localStorage.getItem("lat")} else { var lat = '49.264'; }
if(window.localStorage.getItem("lng")!=undefined) { var lng = window.localStorage.getItem("lng")} else { var lng = '-123.123'; }
try {
var map = window.map
map = new L.Map('map-container');
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/006282296d334e66a593e55aca6b5ce0/54803/256/{z}/{x}/{y}.png';
var cloudmadeAttribution = 'Map Data © 2011 OpenStreetMap';
var cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
map.setView(new L.LatLng(lat, lng), 12).addLayer(cloudmade);
map.invalidateSize();
} catch(e) {console.log(e)}
userMarkers[1] = new L.Marker( new L.LatLng( lat,lng ) , {icon: new iconUser, clickable: true} );
map.addLayer( userMarkers[1] );
});
The environment includes jQuery mobile. Unfortunately, the console does not log any errors and the localStorage above indeed holds valid LatLng values when I inspect it.
A screenshot:
Any guesses?
Upvotes: 3
Views: 5306
Reputation: 13300
I'm not sure how the problem started, but to fix it I went and erased all map container styles and then declared:
#map-container {
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
margin: 0;
padding: 0;
}
And now the problem is fixed. I've never used such styling before so I cannot speculate on how the problem started.
Upvotes: 4