1

first use of the Google Maps add-on for EE here so pardon any ignorance on my part.

I'm trying to set up a pretty standard store locator. I'm using this Sample Store Locator Code and tweaking with my field names (see below).

{address_geocoded} is the field set to store the return from Google.

I'm getting errors along the lines of:

‘address_geocoded’ is not valid post variable.

Firefox and Safari generate the error right away on template load. Chrome loads the form then errors after I enter my current location and submit.

Any idears?

<div>
    {exp:gmap:search
        channel="retailers"
        latitude_field="address_lat"
        longitude_field="address_long"
        geocode_field="address_geocoded"
        distance_field="distance_max"
        cache_post="false"
        return="/locations/test2#demo"}

        <ul>
            <!-- <li>
                <label for="title">Title</label>
                <input type="text" name="title_like" id="title" value="" />
            </li> -->
            <li>
                <label for="location">Location</label>
                <input name="location" id="location" value="{if post:location}{post:location}{/if}" type="text">
                {if error:location}<p class="error">{error:location}</p>{/if}
            </li>
            <li>
                <label for="location">Distance</label>
                <select name="distance_max">
                    <option value="" &#123;if="" !distance_max="" ||="" distance_max="=" ""}selected="selected" &#123;="" if}="">Any</option>
                    <option value="5" &#123;if="" distance_max="=" 5}selected="selected" &#123;="" if}="">5</option>
                    <option value="10" &#123;if="" distance_max="=" 10}selected="selected" &#123;="" if}="">10</option>
                    <option value="20" &#123;if="" distance_max="=" 20}selected="selected" &#123;="" if}="">20</option>
                    <option value="50" &#123;if="" distance_max="=" 50}selected="selected" &#123;="" if}="">50</option>
                    <option value="100" &#123;if="" distance_max="=" 100}selected="selected" &#123;="" if}="">100</option>
                </select>
            </li>

            <li>
                <button type="submit">Search</button>
            </li>
        </ul>       

    {/exp:gmap:search}
</div>

<div>

    {exp:gmap:init id="map" class="gmap" style="width:100%;height:200px"}

    {exp:gmap:results order_by="distance" sort="asc" parse="inward"}

        {if has_searched}
            <ul>
            {results}
                <li>{title} - {distance}</li>
            {/results}
            </ul>

            {results}                   
                {exp:gmap:marker id="map" latitude="{address_lat}" longitude="{address_long}"}
            {/results}

        {if:else}
            {exp:channel:entries channel="retailers" dynamic="no" disable="member_data|categories|category_fields|pagination" parse="inward"}

                {location_gmap id="map"}

            {/exp:channel:entries}
        {/if}

        {if absolute_count == 1}
        <p><em>Hint: Try searching for 'Hoosier National Forest' at a distance of 20 miles.</em></p>
        {/if}

        {if no_results}

            <p>No results found</p>

            {exp:channel:entries channel="retailers" dynamic="no" disable="member_data|categories|category_fields|pagination" parse="inward"}

                {location_gmap id="map"}

            {/exp:channel:entries}

        {/if}

    {/exp:gmap:results}

</div>
1

as I think you must you must use geocode_field param value as a name for your HTML input.

so in your code you change the geocode_field from location to address_geocoded but you keep the HTML field name as it "location".

so the code try to find $_post['address_geocoded'] and it not find it.

this is a guess , because I don't work on Google Maps add-on for EE before, but I almost sure if you change the HTML input name to address_geocoded this will solve the problem.

Update:

the address field is required but you can use more fields that will create an address string that will be geocoded as mention here :

https://www.objectivehtml.com/google-maps/documentation/tag/search#geocode_field

so if you want to use another field like "address_geocoded" you must change your code to:

    {exp:gmap:search
    channel="retailers"
    latitude_field="address_lat"
    longitude_field="address_long"
    geocode_field="address|address_geocoded"
    distance_field="distance_max"
    cache_post="false"
    return="/locations/test2#demo"}

notice geocode_field="address|address_geocoded" and you must add a new HTML field with address_geocoded name.

I hope this will do the trick

Regard's.

| improve this answer | |
  • Tried that, no dice. Same error but with "address" rather than address_geocoded. – Michael Boyink Mar 17 '14 at 16:27
  • just for check, if you use the same document code did you have the same error , if yes can you give me a test url so I can see what happened? – Ahmad Saad Mar 17 '14 at 16:35
  • check the updates – Ahmad Saad Mar 17 '14 at 16:51
  • No dice. I read in the docs that a field with the name of "location" is expected - which I had a question about because that's a reserved field name in EE so I can't name a channel field 'location') At any rate I added the multiple fields with the change d HTML name and same error as before. – Michael Boyink Mar 17 '14 at 16:56
  • I don't know what else you can do , anyway just to make sure you tell me you have the same error but with "address" what you do when you get this error , did you change the param value to "address" or you change the HTML input name to "address_geocoded"?? – Ahmad Saad Mar 17 '14 at 17:14
0

I think my issue was mainly the browser caching the post variables, so when I would make a code change and reload the page the same error would generate. I got past the post variable related errors with this code:

 <div>
    {exp:gmap:search
        channel="retailers"
        latitude_field="address_lat"
        longitude_field="address_long"
        geocode_field="address_map|address_geocoded"
        distance_field="distance_max"
        cache_post="false"
        return="/locations/test2#demo"}

        <ul>
            <li>
                <label for="address_geocoded">Location</label>
                <input name="address_geocoded" id="address_geocoded" value="{if post:address_geocoded}{post:address_geocoded}{/if}" type="text">
                {if error:address_geocoded}<p class="error">{error:address_geocoded}</p>{/if}
            </li>
            <li>
                <label for="distance_max">Distance</label>
                <select name="distance_max">
                    <option value="" &#123;if="" !distance_max="" ||="" distance_max="=" ""}selected="selected" &#123;="" if}="">Any</option>
                    <option value="5" &#123;if="" distance_max="=" 5}selected="selected" &#123;="" if}="">5</option>
                    <option value="10" &#123;if="" distance_max="=" 10}selected="selected" &#123;="" if}="">10</option>
                    <option value="20" &#123;if="" distance_max="=" 20}selected="selected" &#123;="" if}="">20</option>
                    <option value="50" &#123;if="" distance_max="=" 50}selected="selected" &#123;="" if}="">50</option>
                    <option value="100" &#123;if="" distance_max="=" 100}selected="selected" &#123;="" if}="">100</option>
                </select>
            </li>

            <li>
                <button type="submit">Search</button>
            </li>
        </ul>       

    {/exp:gmap:search}
</div>

<div>

    {exp:gmap:init id="map" class="gmap" style="width:100%;height:200px"}

    {exp:gmap:results order_by="distance" sort="asc" parse="inward"}

        {if has_searched}
            <ul>
            {results}
                <li>{title} - {distance}</li>
            {/results}
            </ul>

            {results}                   
                {exp:gmap:marker id="map" latitude="{address_lat}" longitude="{address_long}"}
            {/results}

        {if:else}
            {exp:channel:entries channel="retailers" dynamic="no" disable="member_data|categories|category_fields|pagination" parse="inward"}

                {address_map id="map"}

            {/exp:channel:entries}
        {/if}

        {if absolute_count == 1}
        <p><em>Hint: Try searching for 'Hoosier National Forest' at a distance of 20 miles.</em></p>
        {/if}

        {if no_results}

            <p>No results found</p>

            {exp:channel:entries channel="retailers" dynamic="no" disable="member_data|categories|category_fields|pagination" parse="inward"}

                {address_map id="map"}

            {/exp:channel:entries}

        {/if}

    {/exp:gmap:results}

</div>

Now onto other issues - like the search not returning results...;)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.