1

I JSON ノードのタイトルは同じですが、各ノードで緯度と経度の値が異なります。同じタイトルの値を確認する必要がありますが、緯度と経度の値をマップ API の URL にマージします。緯度、経度、緯度、経度などの順序である必要があります...この時点で何をすべきかわかりません。助けや提案をありがとう。

JS VAR

<img class="detail_map" src="http://open.mapquestapi.com/staticmap/v4/getplacemap?size=320,240&zoom=15&location=' + data.nodes.Latitude + ',' + data.nodes.Longitude + '&imagetype=jpeg&showicon=blue-1">

JSON オブジェクト

var data = fl({
"nodes":[
    {"node":{
        "title":"180","Address":"555 Market St. San Francisco, CA United States See map: Google Maps","
        Latitude":"37.789952","
        Longitude":"-122.400158"}},
    {"node":{
        "title":"180","Address":"Epic Roasthouse (399 Embarcadero) San Francisco, CA United States See map: Google Maps","
        Latitude":"37.797677","
        Longitude":"-122.394339"}},
    {"node":{
        "title":"180","Address":"Mason &amp; California Streets (Nob Hill) San Francisco, CA United States See map: Google Maps","
        Latitude":"37.791556","
        Longitude":"-122.410766"}},
    {"node":{
        "title":"180","Address":"Justin Herman Plaza San Francisco, CA United States See map: Google Maps","
        Latitude":"37.774930","
        Longitude":"-122.419416"}},
    {"node":{
        "title":"180","Address":"200 block Market Street San Francisco, CA United States See map: Google Maps","
        Latitude":"37.793133","
        Longitude":"-122.396560"}} 
]});

});

4

4 に答える 4

0

住所と緯度と経度をマージする関数を作成する必要がありました。jsFiddleをチェックして、動作を確認してください。

function fl(data){
//data = JSON.parse(data);
//Array to hold movie titles   
var movieTitles = []; 
//Assign Movies to to movies Array and ensure unique
for (var i=0; i < data.nodes.length; i++)
{
    //Look for the current title in the movieTitles array
    var movieIndex = movieTitles.indexOf(data.nodes[i].node.title);
    if (movieIndex>-1) //If the title already exists
    {
        //Merge all the properties you want here
        movies[movieIndex].Address += ", " + data.nodes[i].node.Address;
        if(!movies[movieIndex].Coords) movies[movieIndex].Coords = [];
        movies[movieIndex].Coords.push(
            data.nodes[i].node.Latitude + "," + data.nodes[i].node.Longitude
        );
    }
    else
    {
        //var address = movies[movieIndex].Address; movies[movieIndex].Address = address.replace(/^\s*/,'');
        //Add movie to movies array
        movies.push(data.nodes[i].node);
        //Add movie title to movieTitles array
        movieTitles.push(data.nodes[i].node.title);

    }
}

displayLinks(); //Load all the links
//showCast(0); //Display details for first item

}
//});

于 2013-04-19T23:55:01.913 に答える