Home › Toolset Professional Support › [Closed] After switch from Google Maps to OSM, markers disappear when edited
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
This topic contains 5 replies, has 1 voice.
Last updated by Christopher Amirian 3 weeks, 4 days ago.
Assisted by: Christopher Amirian.
I am trying to: Update street addresses for entities in my directory
Link to a page where the issue can be seen: hidden link
I expected to see: A map marker for Greensburg Fire Department, at its new location
Instead, I got: A proper view with 10 results, but only 9 map markers. The marker for the Greensburg Fire Department no longer exists at either its old or new location.
I switched from Google Maps to OSM a few months ago once you made that option available.
I have one other department in another County that also has been edited, and it also now is missing its marker.
I believe these are the only 2 updates since I made the switch.
Of note: the individual Department page also lost its maps marker originally, but I was able to set lat/long coordinates to override the street address, and the marker does now show on the individual page:
hidden link
However, the marker does not appear on its District 10, Decatur County or Statewide maps.
The other Department experiencing the issue:
hidden link
The map appears on this page, with the lat/long override, but it does not appear on the District 14, Jackson County, or Statewide maps.
Hi,
Welcome to Toolset support. Am I correct to assume that if the address used the issue of markers shows and when the Lang/Lat is used the issue is not there?
Would you please do as follows?
Make sure you update Toolset to the latest version.
https://toolset.com/account/downloads/
After that please test by adding a new view and using the map there. It might be that there is a problem with the difference between the old view and the new codebase.
Thanks.
Christopher, thank you for the reply. You are helping me think through this. I built this site in 2018 and haven't had this problem previously, but your final thought "difference between the old view and the new codebase" got me to consider this in a different way.
I still don't have it figured out, but I am looking more closely at content template for the loop.
Right now I am just looking at the loop that generates the "District" map:
The two examples with missing map markers:
hidden link - "Greensburg" is in the listing but not the map
hidden link - "Hamilton Twp. Fire Dept." is in the listing but not the map
Here is the code I'm using for this content template. The opening div represents the listing at the top, which is fine. Then comes the wpv-map-marker shortcode, which appears to be the issue.
<div class="col-sm-6 sws">[wpv-post-title] ([types field='city'][/types])</div>
[wpv-map-marker map_id="map-3" marker_id="marker-[wpv-post-id]" address="[wpv-conditional if='( $(wpcf-address-override) ne "" )'][types field='address-override' format='FIELD_LATITUDE, FIELD_LONGITUDE'][/types][/wpv-conditional][wpv-conditional if='( $(wpcf-address-override) eq "" )'][types field='address1'][/types][/wpv-conditional] [types field='city'][/types] IN [types field='zip' format='FIELD_NAME: FIELD_VALUE'][/types]" marker_title="[wpv-post-title]" marker_icon="hidden link" marker_field='[wpv-post-title]' background_color="#ffffff"]<h4>[wpv-post-link]</h4>[types field='address1'][/types]<br />[types field='city'][/types] IN [types field='zip' format='FIELD_VALUE'][/types][/wpv-map-marker]
One thing I'm noticing - I have two conditions in the address field, for "ne" and "eq". Is it possible that there is a third status that is affecting these two posts which have been modified? Is there a way to do an "else" statement instead of just two opposite "if" statements?
This is my working theory on why the map marker isn't showing. Somehow these posts don't equal "", but also don't not equal "".
If we can get one of these maps to work, I think I should be able to fix the others in the same way.
Thank you for your help!
Hi,
Thank you for your answer. Let me see if I can point out some information that might help you here.
- With OSM, the geocoder is more picky. Passing a mixed “address” like
"[address1] [city] IN [ZIP: 47240]" often fails (labels like IN and FIELD_NAME: confuse it).
- Edited posts vanish because their marker gets re-geocoded now (OSM) and the new address string can’t be parsed, so no coordinates → no marker. Old, unedited posts still use cached coords.
- Lat/Lon inside address: Feeding "LAT, LON" via the address= attribute worked with Google in some cases, but for OSM you should provide lat and lon attributes explicitly.
I suggest that you use both lat/lon (from your override) and a clean address (no labels, no “IN”) in the same marker. If lat/lon exist, Toolset uses them; otherwise it geocodes the address.
As an example:
[wpv-map-marker map_id="map-3" marker_id="marker-[wpv-post-id]" lat='[types field="address-override" format="FIELD_LATITUDE" output="raw"][/types]' lon='[types field="address-override" format="FIELD_LONGITUDE" output="raw"][/types]' address='[types field="address1" output="raw"][/types], [types field="city" output="raw"][/types], [types field="state" output="raw"][/types] [types field="zip" format="FIELD_VALUE" output="raw"][/types], USA' marker_title='[wpv-post-title]' marker_icon='<em><u>hidden link</u></em>' ] <h4>[wpv-post-link]</h4> [types field='address1' output='raw'][/types]<br /> [types field='city' output='raw'][/types], [types field='state' output='raw'][/types] [types field='zip' format='FIELD_VALUE' output='raw'][/types] [/wpv-map-marker]
For your last question:
There isn’t a native “else” in [wpv-conditional], so use complementary conditions.
Something like this:
[wpv-conditional if="( $(wpcf-address-override) ne '' )"]
[wpv-map-marker map_id="map-3" marker_id="marker-[wpv-post-id]"
lat='[types field="address-override" format="FIELD_LATITUDE" output="raw"][/types]'
lon='[types field="address-override" format="FIELD_LONGITUDE" output="raw"][/types]']
...popup...
[/wpv-map-marker]
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-address-override) eq '' )"]
[wpv-map-marker map_id="map-3" marker_id="marker-[wpv-post-id]"
address='[types field="address1" output="raw"][/types], [types field="city" output="raw"][/types], [types field="state" output="raw"][/types] [types field="zip" format="FIELD_VALUE" output="raw"][/types], USA']
...popup...
[/wpv-map-marker]
[/wpv-conditional]
Hope I could help by clarifying the points above.
Thanks.
Christopher, thank you.
With some trial and error based upon your suggested code, I have a working solution that helps me in the short-term.
I found that your solution with separate wpv-map-marker shortcodes inside wpv-conditional shortcodes did work, but the page became very slow to load. Most of my maps have 20-40 markers.
What I ended up doing, for now, is a single wpv-map-marker shortcode, with the conditionals inside, basically the same as before but using your code for OSM to handle the address override. This works well and the pages load about as quickly as they always did. Only 1-2 OSM geocoding instances per page with the remainder continuing to use their cached Google data.
My next issue is to accommodate a 3rd scenario - the future entries that do not exist today, as well as simple edits to the Address field that don't require an override. Those will require geocoding but I don't have a provision in place - currently all overrides are OSM and all non-overrides are Google. I have an idea I'm going to try, and if I run into trouble I'll update the ticket.
Thank you for your help! Without your guidance I wouldn't have ended up with this solution, which does solve my immediate need.
Hi,
I'm glad that I could be a small part of the solution.
In most cases, when we encounter a Toolset support, we will not be able to provide a full working solution, as it is part of each individual case and a fact in web development.
Our role as the best help will be this, to provide a possible idea that then our clever customers will expand on and create their custom solutions.
The topic ‘[Closed] After switch from Google Maps to OSM, markers disappear when edited’ is closed to new replies.