Created
June 22, 2017 12:43
-
-
Save bluvertigo/0f91350e70deac2e976f28dad353f04e to your computer and use it in GitHub Desktop.
Bootstrap Modal - Popup - Google Maps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <a href="#" data-lat="23, 18.33" data-toggle="modal" data-target="#myMapModal"> | |
| Launch Map Modal | |
| </a> | |
| <div class="modal fade" id="myMapModal"> | |
| <div class="modal-dialog"> | |
| <div class="modal-content"> | |
| <div class="modal-header"> | |
| <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
| <h4 class="modal-title">Modal title</h4> | |
| </div> | |
| <div class="modal-body"> | |
| <div class="container"> | |
| <div class="row"> | |
| <div id="map-canvas" class=""></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="modal-footer"> | |
| <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |
| <button type="button" class="btn btn-primary">Save changes</button> | |
| </div> | |
| </div> | |
| <!-- /.modal-content --> | |
| </div> | |
| <!-- /.modal-dialog --> | |
| </div> | |
| <!-- /.modal --> | |
| <script type='text/javascript'> | |
| var element = $(this); | |
| var map; | |
| function initialize(myCenter) { | |
| var marker = new google.maps.Marker({ | |
| position: myCenter | |
| }); | |
| var mapProp = { | |
| center: myCenter, | |
| zoom: 10, | |
| //draggable: false, | |
| //scrollwheel: false, | |
| mapTypeId: google.maps.MapTypeId.ROADMAP | |
| }; | |
| map = new google.maps.Map(document.getElementById("map-canvas"), mapProp); | |
| marker.setMap(map); | |
| }; | |
| </script> | |
| <script type='text/javascript'> | |
| $('#myMapModal').on('shown.bs.modal', function(e) { | |
| var element = $(e.relatedTarget); | |
| var data = element.data("lat").split(',') | |
| initialize(new google.maps.LatLng(data[0], data[1])); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment