Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird rendering of google maps inside Bootstrap carousel
    primarykey
    data
    text
    <p>I am trying to load google map directions as one of the slides inside Bootstrap carousel. </p> <p>Not really sure why this map is loading the way it is. If I remove the first item in the carousel, then the map loads fine. Its only if the map is the second item does it load weirdly.</p> <p>Any ideas how to fix this and load the map correctly?</p> <p><a href="http://jsfiddle.net/ax9jF/4/" rel="nofollow">http://jsfiddle.net/ax9jF/4/</a></p> <p>HTML:</p> <pre><code>&lt;div id="carousel-1" class="carousel slide"&gt; &lt;ol class="carousel-indicators"&gt; &lt;li data-target="#carousel-1" data-slide-to="0" class="active"&gt;&lt;/li&gt; &lt;li data-target="#carousel-1" data-slide-to="1" &gt;&lt;/li&gt; &lt;/ol&gt; &lt;div class="carousel-inner"&gt; &lt;div class="item active" style="height: 450px; width: 100%;"&gt; ABC &lt;/div&gt; &lt;div class="item"&gt; &lt;div id="map-canvas" style="height: 450px; width: 100%;"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Carousel Controls --&gt; &lt;a class="left carousel-control" href="#carousel-1" data-slide="prev"&gt; &lt;span class="glyphicon glyphicon-chevron-left"&gt;&lt;/span&gt; &lt;/a&gt; &lt;a class="right carousel-control" href="#carousel-1" data-slide="next"&gt; &lt;span class="glyphicon glyphicon-chevron-right"&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; </code></pre> <p>Javascript</p> <pre><code>$(document).ready(function(){ var $canvas = $('#map-canvas'); var dstLatLng = new google.maps.LatLng(37.403867, -121.975405); var orgLatLng = new google.maps.LatLng(37.4321365, -122.0988141); var directionsRenderer = new google.maps.DirectionsRenderer(); var directionsService = new google.maps.DirectionsService(); var request = { origin: orgLatLng, destination: dstLatLng, travelMode: google.maps.TravelMode.DRIVING }; var mapOptions = { zoom: 8, center: dstLatLng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map($canvas[0], mapOptions); directionsRenderer.setMap(map); directionsService.route(request, function(result, status) { if (status === google.maps.DirectionsStatus.OK) { return directionsRenderer.setDirections(result); } }); $('.carousel').carousel(); </code></pre> <p>})</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload