[Talk-it] Caricare info/node OSM direttamente su OpenLayers.

sabas88 sabas88 a gmail.com
Mer 8 Maggio 2013 09:35:23 UTC


Il giorno 08 maggio 2013 10:48, pjhooker <lima.cityplanner a gmail.com> ha
scritto:

> ... ho modificato agiungendo isset ...
>
> ---------------------------------------
> <?php
> $url="
> http://overpass-api.de/api/interpreter?data=[out:json];node(45.59374,8.92399,45.60718,8.94424);out
> ;";
> $json = file_get_contents($url); $data = json_decode($json, TRUE);
>
> foreach($data['elements']  as $obj) {
>     if (isset($obj['tags'])) {
>     $lat=$obj['lat'];
>     $lon=$obj['lon'];
>
>         foreach($obj['tags'] as $obj1) {
>             if (isset($obj1['wikipedia'])) {
>             echo "lat:$lat; lon:$lon; ";
>             echo $obj1['wikipedia'];
>             echo "<br>";
>             }
>             else {}
>         }
>     }
>     else {}
> }
>
> ?>
> ---------------------------------------
> Funziona il primo for each, ma il secondo è come se mi restituisce la prima
> lettera e poi di tutti i tag, non solo quello con 'wikipedia'
>
> se provo a mettere al posto di echo $obj1['wikipedia']; solo echo $obj1; mi
> restituisce tutti i valori del tag completi ...
>
> l'esempio col codice aggiornato:
> http://host.logosloci.com/test/parse_json.php
> <http://host.logosloci.com/test/parse_json.php>
>
>
> KISS
$json = file_get_contents($url);
$data = json_decode($json, TRUE);

foreach($data['elements']  as $obj) {
    if (isset($obj['tags']["wikipedia"])) {
    $lat=$obj['lat'];
    $lon=$obj['lon'];
echo "lat:$lat; lon:$lon; ";
echo $obj['tags']["wikipedia"];
    echo "<br/>";
    }
    else {}
}

PS Ti conviene salvarti il json in locale invece che fare una richiesta
ogni volta mentre debugghi ;)



>
> --
> View this message in context:
> http://gis.19327.n5.nabble.com/Caricare-info-node-OSM-direttamente-su-OpenLayers-tp5759882p5760118.html
> Sent from the Italy General mailing list archive at Nabble.com.
>
> _______________________________________________
> Talk-it mailing list
> Talk-it a openstreetmap.org
> http://lists.openstreetmap.org/listinfo/talk-it
>
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.openstreetmap.org/pipermail/talk-it/attachments/20130508/ca6d739f/attachment-0001.html>


Maggiori informazioni sulla lista Talk-it