jquery - 如何让谷歌地图 API v3 显示点?

标签 jquery google-maps-api-3

我正在使用Google Maps Api v3显示 map 。

这是 JQuery:

<script type="text/javascript">
    var myOptions = {
         zoom: 8,
         center: new google.maps.LatLng($("#lat").val(), $("#long").val()),
          mapTypeId: google.maps.MapTypeId.HYBRID  
    };
    var map = new google.maps.Map(document.getElementById("map"), myOptions);

但是 map 没有突出显示这一点。它只是显示 map 上的区域...我希望它看起来像这样:

enter image description here

最佳答案

用标记看一下这个例子的源代码: http://code.google.com/apis/maps/documentation/javascript/examples/infowindow-simple.html

使用您的代码的示例:

    <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false"></script>

    <script type="text/javascript">
        function initialize() {

            var myLatlng = new google.maps.LatLng($("#lat").val(), $("#long").val());
            //var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
            var myOptions = {
                zoom: 8,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.HYBRID
            };
            var map = new google.maps.Map(document.getElementById("map"), myOptions);

            var contentString = '<div id="content">Info window html</div>';

            var infowindow = new google.maps.InfoWindow({
                content: contentString
            });

            var marker = new google.maps.Marker({
                position: myLatlng,
                map: map,
                title: 'Marker Title'
            });

            google.maps.event.addListener(marker, 'click', function() {
                infowindow.open(map, marker);
            });
        }

    </script>
</head>
<body onload="initialize()">
<div id="map" style="width: 400px; height: 300px;"></div>
</body>

关于jquery - 如何让谷歌地图 API v3 显示点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9664470/

相关文章:

google-maps-api-3 - 街景进入信息窗口

javascript - 谷歌地图顶部的路线多边形

javascript - jQuery 不需要的总和结果

javascript - For 语句使用 This 与 jQuery Each?

javascript - Google Geocoder - 将坐标添加到字段

javascript - 谷歌地图路线点击事件

javascript - 将 ID 添加到 Google Map Marker 然后定位它

php - jquery post() 不以动态形式工作

jquery - setTimeout 无法使用其中的函数

javascript - 如何在包装 div 中启用 Froala 编辑器?