1

I've got a google map (gmaps addon) that I'm adding pins to via low search results. Unfortunately I cannot seem to get the lat/long to pass through to the tag.

My template is below. You can see a testing div which successfully outputs the lat/long as expected, but if I use the same code inside the parameter for gmaps nothing is output. However if I manually add in the lat/long the map works as expected.

I suspect that this is due to parse order but am unsure how to overcome this issue. This template is already in an embed so I really don't want to have a nested embed.

{exp:low_search:results query="{segment_3}" limit="1" dynamic="no" disable="member_data|comments|pagination"}

    {if low_search_no_results}
    <div style="width:100%;height:500px;padding:150px 40px 40px 40px;background:pink;">
        <h4 class="text-center">no search results</h4>

    </div>
    {/if}

    {exp:stash:set name="address" parse_tags="yes" type="snippet"} 
            {!--
            // stash markers to use in google map
            --}

            {if "{trip_map:marker:latlng}" !=""}
                {trip_map:marker:latlng}|
            {if:else}
                {map_points_original_site}
                    {map_points_original_site:point_location_latlng}{map_points_original_site:point_location}|
                {/map_points_original_site}
            {/if}
    {/exp:stash:set}

    {!-- here for testing only--}
    <div style="width:100%;min-height:20px;padding:{if count=='1'}125{if:else}30{/if}px 2px 10px 2px;background-color:rgba(250, 250, 131, 0.4);">
        <p class="text-center" style="margin:3px 0 0;">-- title: {title} --</p>
        <p>
        stash: {exp:stash:get name='address' type='snippet'}
        </p>
    </div> 
    {!--end testing--}

{/exp:low_search:results}

    {exp:gmaps:geocoding width="100%" marker="yes" width="100%" height="750px" map_type="terrain" zoom_control_position="LEFT_BOTTOM" zoom="8" latlng="{exp:stash:get name='address' type='snippet'}"}


    {/exp:gmaps:geocoding}

UPDATE

The testing div output is here:

stash: 39.008498,-106.243825|39.043544,-106.263701|38.9228982,-106.1695513|39.004257,-106.24123|

1

You need parse="yes" trim="yes" when you set the var (to fully parse the conditionals and remove whitespace), parse="inward" on the gmaps tag (so the parameters are parsed), and add 'random' to the 2nd use of stash get to stop EE replacing the second instance of the stash:get tag with a 'M0...' cache marker:

{exp:low_search:results query="{segment_3}" limit="1" dynamic="no" disable="member_data|comments|pagination"}
  {exp:stash:set name="address" parse="yes" trim="yes"}
            {if "{trip_map:marker:latlng}" !=""}
                {trip_map:marker:latlng}|
            {if:else}
                {map_points_original_site}
                    {map_points_original_site:point_location_latlng}{map_points_original_site:point_location}|
                {/map_points_original_site}
            {/if}
    {/exp:stash:set}

    {!-- here for testing only--}
    <div style="width:100%;min-height:20px;padding:{if count=='1'}125{if:else}30{/if}px 2px 10px 2px;background-color:rgba(250, 250, 131, 0.4);">
        <p class="text-center" style="margin:3px 0 0;">-- title: {title} --</p>
        <p>
        stash: {exp:stash:get name='address'}
        </p>
    </div> 
    {!--end testing--}

{/exp:low_search:results}

{exp:stash:parse process="end"}
    {exp:gmaps:geocoding width="100%" marker="yes" width="100%" height="750px" map_type="terrain" zoom_control_position="LEFT_BOTTOM" zoom="8" latlng="{stash:address}"}


    {/exp:gmaps:geocoding}
{/exp:stash:parse}

Note that sometimes trim="yes" won't remove all the whitespace so you may need to close it up manually.

| improve this answer | |
  • Mark, If I take this code the map doesn't show up. However if I do everything as you said except the parse="inward" then the map canvas appears with no map or pins. by manually removing whitespace do you mean no indenting the code inside the stash set tag? I've done that with no change.... – CreateSean Feb 16 '16 at 21:08
  • have updated original post with the output of the stash:get tag from the testing div. – CreateSean Feb 16 '16 at 21:10
  • I missed that you were setting the variable inside a low search tag pair, or did you update that? You just need to get the variable later in the parse order - see updated code. – Mark Croxton Feb 17 '16 at 12:43
  • stash:parse process="end" works perfectly. So many options it's hard to know what to do. Thank you for all your help. Oh and the low:search tag was in the original post, but probably easy to miss since the code block is somewhat largish. Thank you. – CreateSean Feb 17 '16 at 14:48

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.