0

我有以下 flickr 查询,我想打印所有值,但特别显示图像、图像标题、图像 url 和图像经纬度。所以我可以将经纬度插入谷歌地图。

我该怎么做呢?

这是我下面的代码

谢谢

<!DOCTYPE html>
<html>
<head>

  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <div id="images">

</div>
<script>            
var url = "http://api.flickr.com/services/rest/?method=flickr.photos.search&per_page=100&nojsoncallback=1&format=json&tags=paris&media=photos&api_key=00af42177056c5b71bda9bd49938c1df&has_geo=1&text=paris&&extras=geo";
var src;
$.getJSON(url + "&format=json&jsoncallback=?", function(data){
    $.each(data.photos.photo, function(i,item){
        src = "http://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret +"_m.jpg";
        $("<img/>").attr("src", src).appendTo("#images");               
    });
});
</script>

</body>
</html>

JSONP

{ "photos" : { "page" : 1,
      "pages" : 17601,
      "perpage" : 100,
      "photo" : [ { "accuracy" : "15",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7700340476",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.782974000000003,
            "longitude" : 2.4095240000000002,
            "owner" : "12542184@N03",
            "place_id" : "bu5MqeZUV7LtyGRx1A",
            "secret" : "307b2660e2",
            "server" : "8027",
            "title" : "Rebase entre RER's",
            "woeid" : "55863622"
          },
          { "accuracy" : "11",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7706302634",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.856918,
            "longitude" : 2.3412090000000001,
            "owner" : "31450016@N06",
            "place_id" : "EsIQUYZXU79_kEA",
            "secret" : "4a05d533be",
            "server" : "7259",
            "title" : "París 031 Museo del Louvre",
            "woeid" : "615702"
          },
          { "accuracy" : "11",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7706304774",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.856918,
            "longitude" : 2.3412090000000001,
            "owner" : "31450016@N06",
            "place_id" : "EsIQUYZXU79_kEA",
            "secret" : "76b651f4ff",
            "server" : "7253",
            "title" : "París 024 Torre Eiffel",
            "woeid" : "615702"
          },
          { "accuracy" : "11",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7706300720",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.856918,
            "longitude" : 2.3412090000000001,
            "owner" : "31450016@N06",
            "place_id" : "EsIQUYZXU79_kEA",
            "secret" : "5ce48df86a",
            "server" : "7268",
            "title" : "París 035 Reloj Orsay",
            "woeid" : "615702"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7706223818",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.866321999999997,
            "longitude" : 2.3141690000000001,
            "owner" : "23733615@N07",
            "place_id" : "WU8qo85UV7J7dLZuCw",
            "secret" : "69255ed956",
            "server" : "8012",
            "title" : "Paris",
            "woeid" : "55843784"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7706186726",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.869444000000001,
            "longitude" : 2.307922,
            "owner" : "23733615@N07",
            "place_id" : "WU8qo85UV7J7dLZuCw",
            "secret" : "168b7316e0",
            "server" : "8142",
            "title" : "Paris",
            "woeid" : "55843784"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7706196346",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.866052000000003,
            "longitude" : 2.3139989999999999,
            "owner" : "23733615@N07",
            "place_id" : "WU8qo85UV7J7dLZuCw",
            "secret" : "e347aed0cb",
            "server" : "7123",
            "title" : "Paris",
            "woeid" : "55843784"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7706211062",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.866540999999998,
            "longitude" : 2.3136999999999999,
            "owner" : "23733615@N07",
            "place_id" : "WU8qo85UV7J7dLZuCw",
            "secret" : "10413bf052",
            "server" : "8164",
            "title" : "Paris",
            "woeid" : "55843784"
          },

          { "accuracy" : "16",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705462234",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "147d569a64",
            "server" : "7264",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705492248",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "4cf313b4e5",
            "server" : "7110",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705465586",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "c2f1747c51",
            "server" : "7266",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705463942",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "ce8586f5a8",
            "server" : "7129",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705467020",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "70d16fc4d4",
            "server" : "8286",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705481944",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "e86709d9a5",
            "server" : "8011",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705494846",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "32991e9f52",
            "server" : "8026",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705456730",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "cbec88b40d",
            "server" : "8158",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705476904",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "4511920f26",
            "server" : "8016",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705485932",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "67b83351db",
            "server" : "8150",
            "title" : "Columbarium. Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },

          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705493494",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "3dcf1d9fa6",
            "server" : "8142",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705487256",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "7e943318b2",
            "server" : "8285",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705480418",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "d24d3e52dd",
            "server" : "8294",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705454360",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "01488a2416",
            "server" : "8148",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705440852",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "e87f0d530d",
            "server" : "8005",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705439844",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "0e1d800781",
            "server" : "7124",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 8,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705430268",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.922527000000002,
            "longitude" : 2.2818299999999998,
            "owner" : "41583834@N03",
            "place_id" : "8wSB0PdUV7KBx1hi.A",
            "secret" : "06e8d1fee7",
            "server" : "7248",
            "title" : "Asnières sur Seine, Paris, France",
            "woeid" : "55863481"
          },
          { "accuracy" : "16",
            "context" : 0,
            "farm" : 9,
            "geo_is_contact" : 0,
            "geo_is_family" : 0,
            "geo_is_friend" : 0,
            "geo_is_public" : 1,
            "id" : "7705347074",
            "isfamily" : 0,
            "isfriend" : 0,
            "ispublic" : 1,
            "latitude" : 48.858333000000002,
            "longitude" : 2.3421660000000002,
            "owner" : "31029248@N00",
            "place_id" : "36CFHdZUV7KNOKK4LQ",
            "secret" : "655a601535",
            "server" : "8159",
            "title" : "Paris plages",
            "woeid" : "55843752"
          }
        ],
      "total" : "1760053"
    },
  "stat" : "ok"
}
4

1 回答 1

2

您可以通过以下方式访问纬度和经度:

$.getJSON(url + "&format=json&jsoncallback=?", function(data){
    $.each(data.photos.photo, function(i,item){
        src = "http://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret +"_m.jpg";
        $("<img/>").attr("src", src).appendTo("#images");
        console.log(item.latitude); //gives latitude in console
        console.log(item.longitude); //gives longitude in console
    });
});

小提琴

于 2012-08-03T21:54:22.623 回答