Skip to content

Instantly share code, notes, and snippets.

@marcus-at-localhost
Last active November 7, 2017 19:24
Show Gist options
  • Save marcus-at-localhost/4964348 to your computer and use it in GitHub Desktop.
Save marcus-at-localhost/4964348 to your computer and use it in GitHub Desktop.
[Bootstrap Tabs reveal $.goMap] google map with a glitch. trigger resize didn't work, so I had to set showing the tab with display:block before rendering the map. maybe the css transition delays it?! anyway here is the fiddle:http://jsfiddle.net/8kdpY/2/
$('a[data-toggle="tab"]').on('show', function (e) {
var $target = $(e.target.hash);
var h = e.target.hash.indexOf('map-');
if(h != -1 ){
var loc = $target.parents('.tab-content').find('address').data('address');
var id = $target.find('.google-maps').attr('id');
/* set the active class here, because the map init doesn't wait for the .fade.in
css trasition from bootstrap
*/
// uncomment this
$(e.target.hash).addClass('active');
$('#'+id).goMap({
scaleControl: true,
maptype: 'ROADMAP',
zoom:17,
address: loc,
hideByClick: false,
markers:[{address: loc}]
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment