0

誰かが私がここで間違っていることを説明できますか?私はjQuery$.getJSONとGoogleマップを使用しています。どちらも初心者です。もともと私は標準のJavaScriptを使用していましたが、XMLHttpRequestがChromeまたはjsfiddle内で機能していなかったため、jQueryを使用することにしました。また、。$ 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文字列が機能しないため、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 に答える