Leaflet: map invalidatesize not working
<p>I've been working on this all night: please don't tell me to go to google. I've read every duplicate question, all of the leaflet documentation that I can find, and just can't figure out why this isn't working. I had to change over to the new Mapquest tiles and everything is working fine except that I'm only getting one corner of my tiles to load. I know that the answer is map invalidate size. That's what worked before and that's what every article and question/answer I've read tonight says is the answer. I'm missing something obvious. Please help. Here's my script:  </p>

<pre><code>    &lt;script&gt;
$('#locModal').on('show.bs.modal', function (event) {

    var button = $(event.relatedTarget);
    var mapinfo = button.data('whatever');
    var pos = mapinfo.position;
    var lat = pos.substring(0,7);
    var ling = pos.substring (10,17);
    var map = L.map('mapdiv').setView([lat, ling], 6)
    var name = mapinfo.name;
    var contact = mapinfo.contact;
    var address = mapinfo.address;
    var city = mapinfo.city;
    var state = mapinfo.state;
    var zip = mapinfo.zip;
    var phone = mapinfo.phone;
    var p1 = phone.substring(0,3);
    var p2 = phone.substring(3,6);
    var p3 = phone.substring(6,10);

if (map != undefined) { map.remove(); }

window.setTimeout(function() { 
    map.invalidateSize();
}, 1000);    

 var basemap = L.map('mapdiv', {
    layers: MQ.mapLayer(),
    center: [ lat, ling ],
    zoom: 12,
     });

L.marker([lat, ling]).addTo(map);   

$("#mapModalHeader").html("&lt;button type='button' class='close' data-dismiss='modal' aria-hidden='true'&gt;X&lt;/button&gt;&lt;h2&gt;" + "Map to " + name + "&lt;/h2&gt;");


$("#mapModalFooter").html("Mailing Address: " + contact + " " + address + " " + city + ", "  + state + " " + zip
    + " " + "(" + p1 + ") " + p2 + "-" + p3 );

 $('body').on('hidden.bs.modal', '.modal', function () {
   document.location.reload();
});  
 }); 
&lt;/script&gt;
</code></pre>

<p>I've also tried the map invalidatesize like this:</p>

<pre><code>(function() { 
    map.invalidateSize();
}, 1000);
</code></pre>

<p>A key function on my live website is broken and I could please use any help you can give me.</p>