• Resolved gaseous

    (@gaseous)


    Hi!

    me again. everything works mostly perfectly fine by now, but whenever I open a post with an existing marker for later editing the choice of marker reverts to the default.

    background information: I have customized my markers and deleted the default ones.

    I can save map points and my choice of marker with a post. and it shows on the map as expected. but when I return to that post and edit it, the marker still shows its position but has switched to the default marker. the really default in-the-admin-plugin-folder default. any idea why that happens?

    It happens to posts and custom post types alike. Gutenberg or classic editor doesn’t seem to make a difference either.

    it can be worked around by reselecting the marker everytime I edit a post, but my site has a couple of users who I have to remind to do this as the default marker looks vastly different from mine and really out of place when that happens.

    ————-
    another question I have is: is it possible to set a max zoom for the post edit screen? the tile layer I use does not show on the two highest zoom factors and when editing a post, the map zooms in to max and shows a marker on grey. – I don’t mind editing something in the plugin files, but while I can do php, I am completely helpless at js and so can’t find out where that bit is done.

    thanks again for such a great plugin!!!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter gaseous

    (@gaseous)

    Found the problem on my own.

    if the markers are less than 45px tall (which mine were because I use the map on the sidebar and 45px markers simply were half as big as the map itself), it keeps switching to the default.

    I simply used transparent height for mine now.

    ——-
    my second question (about the max zoom for the edit screen) still stands, though.

    Plugin Author Camille V

    (@socrapop)

    Dear @gaseous,

    Thank you for the bug report and the investigation, I will have a look as to why you have this strange behaviour.

    For your second question, if you have the knowledge to add a script on your backoffice, it would be better to do it and keep untouched the plugin files, so that you can update without losing your change.

    You can have a js function like this:

    document.addEventListener('cttm_map_loaded', function (e) {
        cttm_map.setMaxZoom(16); //You can change the number
    }, false);

    If you want to modify the plugin files, you can edit /includes/admin/js/travelersmap.admin.js line 38 :

    window.cttm_map = L.map('travelersmap-container').setView(
          [45.280712, 5.89],
          3 //Zoom 3
        ).setMaxZoom(16);

    Have a nice day 🙂

    Plugin Author Camille V

    (@socrapop)

    Have you changed your website protocol from http to https since you uploaded the small markers?
    Or did you migrate your website since the markers were set on the posts?

    I made a rookie mistake on the first draft of this plugin, and it’s coming back to me now : the plugin is saving the marker URL (not id) on the post metadata when you set a marker. And on page load, it checks if the image url is equal to the markers thumbnails url.
    So if you changed the URLs after setting a marker on a post, it would go back to default when loading the page (when the URL doesn’t match anything). And the markers images could be broken too, unless you set redirections on your server from the old to new URL.

    Thread Starter gaseous

    (@gaseous)

    Hey,

    thanks for the code snippets. I am figuring out how to add a javascript to my theme right now.

    I added a js file with your code (the documentEventListener snippet) and put some code into my functions.php to load it.

    Zooming still keeps its default maximum, though. Browser console shows an error. see screenshot link (https://www.winterwinde.de/Screenshot_2022-04-21_120555.png) – Unfortunately, I don’t know enough javascript to debug that :/

    —————–
    Regarding the switching markers:

    It seems I was wrong, using bigger markers still bugs out.

    I haven’t switched from http to https since installing the plugin, nor have I moved the site.

    I did stumble upon strange things happening if I changed the featured image of an existing marker, but now I understand why that happened. no problem.

    did you say, you the marker image url should be in the post meta data? – well…because for some very odd reason. it isn’t.

    I’ve tried completely removing all markers from a post. saving. and then re-setting them.

    but it looks like there’s nothing saved to post-meta data. I’ll investigate on my end if I have something interfering with that.

    Thread Starter gaseous

    (@gaseous)

    I also tried adding a completely new marker (so the url is fresh and new and definitely unchanged) and setting that as my marker. still switched back.

    the coordinates stay correct, btw. but I can’t see them either in the post meta fields.

    Thread Starter gaseous

    (@gaseous)

    sorry for another post, but I debugged my post metadata a bit and it seems, the data is actually saved in [_latlngmarker]. it just doesn’t show up in the post edit screen. had to get it via a get_post_meta() output.

    the marker urls saved in those meta data entries are completely correct, btw. I can copy and open them in a browser window, no problem.

    but I noticed something.

    all entries are somehow saved with a get variable timestamp. so the post meta-data says the marker is:
    …/uploads/2022/04/marker-red.png?_t=1650377591

    the marker entry in the plugin says the marker is:

    …/uploads/2022/04/marker-red.png?_t=1650538141

    well…..that can’t work.

    I’ll do the switch-off-all-your-plugins-dance routine to find out if that is core behaviour or something I added.

    would it be possible to maybe strip the marker urls of any stray get variables in the plugin code? just to be save?

    Thread Starter gaseous

    (@gaseous)

    Hurray!

    found the culprit! it was https://wordpress.org/plugins/replace-image/ this plugin. — and I can deal perfectly fine without it. so no worries there.

    might be a useful addition to your plugin to maybe strip marker urls before saving anyway? in case, that plugin isn’t the only one trying to use get variables on image urls?

    thanks a gazillion for your hint with the marker url and the meta data!

    now I only have to re-save all my posts to correct the markers.

    (and still get the zoom limit working)

    Plugin Author Camille V

    (@socrapop)

    Thank you for keeping me informed of your findings 🙂

    I think the whole marker url as a metadata is a bad idea and I wanted to rewrite that part and use marker ID. But the migration process between old metadata and new might be impredictible and kinda scares me ahah.

    Did you get your zoom limit working? Do you have the latest Travelers Map update installed? Because it’s in the last update that I added the access to the map object with javascript. (the snippet I gave you)

    Thread Starter gaseous

    (@gaseous)

    yes, thank you!

    admin panel zoom limit is working fine now.

    I tried getting the seperate js snippet bound in, but ended up changing the plugin code as you suggested. no whizz with js, me 😉 – but it works fine now and I’ll just remember to do it again after updates, no problem.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘marker keeps resetting to default on post edit’ is closed to new replies.