• Resolved HansTis

    (@hanstis)


    First of all thanks for sharing this plugin! I intend to use it to show the actual driving duration between two places. This is what Google sends on my request:

    `// 20180526113151
    // https://maps.googleapis.com/maps/api/distancematrix/json?origins=Dam,%20Amsterdam&destinations=Blaak,%20Rotterdam&departure_time=now&traffic_model=best_guess&key=************

    {
    “destination_addresses”: [
    “Blaak, Rotterdam, Nederland”
    ],
    “origin_addresses”: [
    “Dam, 1012 Amsterdam, Nederland”
    ],
    “rows”: [
    {
    “elements”: [
    {
    “distance”: {
    “text”: “79,6 km”,
    “value”: 79552
    },
    “duration”: {
    “text”: “1 uur 10 min.”,
    “value”: 4190
    },
    “duration_in_traffic”: {
    “text”: “1 uur 8 min.”,
    “value”: 4104
    },
    “status”: “OK”
    }
    ]
    }
    ],
    “status”: “OK”
    }’

    Tried to import the duration_in_traffic / value (4104 seconds in this sample) into my post but without succes so far. This value, preferable in minutes and not in seconds, is the only variable I need. Can you help me?

    • This topic was modified 6 years, 9 months ago by HansTis.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author berkux

    (@berkux)

    Hi,

    try this:

    [jsoncontentimporter url=https://wptest.kux.de/extra/json/mapg.json debugmode=10]
    {subloop-array:destination_addresses:1}destination_addresses:{0}{/subloop-array:destination_addresses}
    {subloop-array:origin_addresses:1}origin_addresses:{0}{/subloop-array:origin_addresses}
    {subloop-array:rows:1}
    {subloop-array:rows.elements:1}
    {subloop:rows.elements.duration:1}duration: {rows.elements.duration.value}
    {/subloop:rows.elements.duration}
    {/subloop-array:rows.elements}
    {/subloop-array:rows}
    [/jsoncontentimporter]
    Thread Starter HansTis

    (@hanstis)

    Hi,

    Thanks for your kind support! It works:

    {subloop-array:rows:1}
    {subloop-array:rows.elements:1}
    {subloop:rows.elements.duration_in_traffic:1}In huidig verkeer: {rows.elements.duration_in_traffic.value} seconden
    {/subloop:rows.elements.duration_in_traffic}
    {/subloop-array:rows.elements}
    {/subloop-array:rows}
    [/jsoncontentimporter]

    You have saved me a lot of time and frustration ?? My next job is to convert the duration_in_traffic value from seconds to minutes.

    Regards, Hans.

    Plugin Author berkux

    (@berkux)

    Hi,

    you can’t calc with the free version.
    The pro-version can do that. If this is an option switch your support-request to
    https://json-content-importer.com/legal-contact/

    Bernhard

    Thread Starter HansTis

    (@hanstis)

    Thanks again Berhard, I will consider the pro version.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Google Distance Matrix API’ is closed to new replies.