0

谁能解释我在这里做错了什么?我正在使用 jQuery $.getJSON 和谷歌地图,我都是新手。最初我使用的是标准 JavaScript,但决定使用 jQuery,因为 XMLHttpRequest 在 Chrome 或 jsfiddle 中不起作用,据我了解,我不必担心使用 .$getJSON 的这些问题,但是我现在必须重建我的代码在 jQuery 中正常工作。

        <!DOCTYPE html>
    <html> 
    <head> 
      <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
      <title>Google Maps Multiple Markers - jQuery JSON</title> 
      <script src="http://maps.google.com/maps/api/js?sensor=false" 
              type="text/javascript"></script>
      <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
      <script type="text/javascript" src="js/jquery.ui.map.js"></script>
    </head> 
    <body>
      <div id="map_canvas" style="width: 800px; height: 600px;"></div>

      <script type="text/javascript">
          $(function(){
    $('#map_canvas').gmap().bind('init', function(){
        $.getJSON('http://www.artectodesignstudios.com/RSSData.txt', function(data){
            $.each(data.title, function(i, marker){
                $('#map_canvas').gmap('addMarker',{
                    'position': new google.maps.LatLng(marker[i]["geo:lat"], marker[i]["geo:long"]),
                    'bounds':true
            }).click(function(){
                $('#map_canvas').gmap('openInfoWindow', {'content': marker.content}, this);
            });

           });
        });
    });
});
    <script>
        </body>
        </html>

​</p>

4

1 回答 1

0

您需要处理您的 url 字符串,因为它不起作用。我建议你从一些简单的东西开始,比如(http://jquery-ui-map.googlecode.com/svn/trunk/demos/json/demo.json),然后使用 JSON 格式来编辑你的测试数据。来自您想要的 http://www.artectodesignstudios.com/RSSData.txt请求的响应。希望能帮助到你。:)

于 2013-09-05T21:32:59.040 回答