html Bootstrap Modal - Popup - Google Maps

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Bootstrap Modal - Popup - Google Maps相关的知识,希望对你有一定的参考价值。

<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>

以上是关于html Bootstrap Modal - Popup - Google Maps的主要内容,如果未能解决你的问题,请参考以下文章

html 带有HTML5视频的Bootstrap 3 Modal

html Bootstrap Modal - Popup - Google Maps

html BootStrap Modal对象中的MVC表单。

html 关闭Modal(BootStrap)时停止Youtube视频

html Bootstrap modal + ladda btn loader

新手问题,AngularJS,bootstrap modal 怎么获取数据