如何启用谷歌地图标记

时间:2016-09-19 12:49:49

标签: html5 api

下面是用于在我的html页面上显示地图的jquery现在我想在这张地图上的特定位置显示标记然后我该如何启用它。请帮助我解决这个问题。

Result images of running map

tjq(document).ready(function() {

            tjq('a[href="#map-tab"]').on('shown.bs.tab', function (e) {
                var center = panorama.getPosition();
                google.maps.event.trigger(map, "resize");
                map.setCenter(center);
            });

            var map = null;
            var panorama = null;
            var fenway = new google.maps.LatLng(48.855702, 2.292577);
            var mapOptions = {
                center: fenway,
                zoom: 12
            };

            var panoramaOptions = {
                position: fenway,
                pov: {
                    heading: 34,
                    pitch: 10
                }
            };
            function initialize() {
                tjq("#map-tab").height(tjq("#hotel-main-content").width() * 0.6);
                map = new google.maps.Map(document.getElementById('map-tab'), mapOptions);
                panorama = new google.maps.StreetViewPanorama(document.getElementById('steet-view-tab'), panoramaOptions);
                map.setStreetView(panorama);
            }
            google.maps.event.addDomListener(window, 'load', initialize);




html code for showing the map 


     <div id="map-tab" class="tab-pane fade">

                                        </div>

1 个答案:

答案 0 :(得分:0)

你只需要为init函数中的标记添加新变量:

var marker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      title: 'Hello World!'
    });

参考:google maps Javascript API