javascript - Centering the map marker on a Reveal Modal Foundation -


it happens after opening modal, map not shown, forced solve script resizes map within application.js (i'm using rails framework)

$(document).ready(function(){   $(document).foundation();   $(document).on('open.zf.reveal', '[data-reveal]', function () {     window.dispatchevent(new event('resize'));   }); }); 

however, although shows map in modal, marker not displayed in middle, shown 1 side, this:

enter image description here

how can when image resized, center marker? thank help, here code:

index.html.erb

<div class="full reveal" id="mapmodal" data-reveal style="width: 100%;">   <div id="map" style="width: 100%; height: 280px;"></div>   <script type="text/javascript">     handler = gmaps.build('google');     handler.buildmap({ provider: { gesturehandling: 'greedy' }, internal: { id: 'map' }}, function(){     markers = handler.addmarkers(<%=raw @hash.to_json %>);     handler.bounds.extendwith(markers);     handler.fitmaptobounds();     handler.getmap().setzoom(16);     });   </script> </div> 

controller.rb

def index   @home = home.last   @hash = gmaps4rails.build_markers(@home) |home, marker|     marker.lat home.latitude     marker.lng home.longitude   end  end 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -