1

我正在使用 json 从数据库中获取数据,但谷歌地图根本没有显示。我也想在 infowindow 中显示数据。但无法获取地图。我不知道我在脚本或代码中缺少什么。请帮我 My code

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <title>Show/Add multiple markers to Google Maps from database in asp.net website
 </title>


 <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-   
 2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
 </script>

 <script type="text/javascript">

 function SelectValue() 
  {
      var data1=  $.ajax
      ({ 
           type:'POST',
            url: 'MapDetais.aspx',
            data:'{}',
            dataType: 'json',
            async:false,
            success: function(data)
                {
                        for (var i = 0; i < data.length; i++)
                        {
                            var name=data[i].Name;
                            var lon=data[i].Longitude;
                            var lat=data[i].Latitude;
                            var desc=data[i].Description;
                            var photo=data[i].Photo;
                            alert(data1)
                        }
                        function initialize()
                         {
                                var mapOptions =
                                {
                                    center: new google.maps.LatLng(lat, lon),
                                    zoom: 5,
                                    mapTypeId: google.maps.MapTypeId.ROADMAP
                                };
                                var infoWindow = new google.maps.InfoWindow();
                                var map = new google.maps.Map(document.getElementById("map_canvas"), 
  mapOptions);
                         }
                }
               });
             }

 </script>

 </head>
 <body onload="SelectValue()">
 <form id="form1" runat="server">
 <div id="map_canvas" style="width: 500px; height: 400px">
 </div>
 </form>
 </body>
 </html>
4

0 回答 0