The API http://zippopotam.us/ gives Citynames and Coorindates to a Zipcode. The JCI-PRO-Plugin can use that for a “Zipcode to City-Search”.
This done this way:
Found:
Examples: Houston, US, TX | Munich, DE, Germany
1. JCI-Shortcode:
httpstatuscodemustbe200=no tells the plugin to accept also non-ok-API-answers
[[jsoncontentimporterpro nameoftemplate="zip" httpstatuscodemustbe200=no]]
2. JCI template:
- url:
http://api.zippopotam.us/{% if urlparam.co %}{{urlparam.co}}{% else %}US{% endif %}/{% if urlparam.zip %}{{urlparam.zip}}{% else %}80636{% endif %}
- urlparam4twig: zip#co
- twig-template:
{% if urlparam.co %}{% set coun = urlparam.co %}{% else %}{% set coun = "DE" %}{% endif %} <form action=/pro-api-zippopotamus-shortcode-parameter-httpstatuscodemustbe200/> <select name="co" id=jciinput> <option value="DE" {% if coun =="DE" %}selected{% endif %}>Germany</option> <option value="US" {% if coun =="US" %}selected{% endif %}>United States</option> </select> <input type=text name=zip placeholder="Insert Zipcode" value="{% if urlparam.zip %}{{urlparam.zip}}{% else %}80636{% endif %}"> <input type=submit id=jciinput value="Search Zipcode for City"> </form> <hr> {% if places %} <strong>Found:</strong><br> <ol>{% for p in places %}<li> <a href="https://www.google.com/maps/search/{{p.latitude}},{{p.longitude}}" target="_blank">{{ attribute(p, 'place name') }} ({{ attribute(p, 'state abbreviation') }})</a> </li>{% endfor %}</ol> {% else %} {% if urlparam.zip %} no City to this Zipcode {{urlparam.zip}} found {% endif %} {% endif %} <style> #jciinput { border-radius: 5px; width: 320px; height:35px; background: #eee; color: black; } </style> <hr> Examples: <a href="/pro-api-zippopotamus-shortcode-parameter-httpstatuscodemustbe200/?co=US&zip=77004">Houston, US, TX</a> | <a href="/pro-api-zippopotamus-shortcode-parameter-httpstatuscodemustbe200/?co=DE&zip=80636">Munich, DE, Germany</a>