• Resolved leoriccio

    (@leoriccio)


    Hi everyone,

    I’m facing an issue with a project involving two maps. One of my maps has markers, and the other displays GPX tracks. The problem arises when I try to add links with marker targets. The created links are not functioning as expected.

    After investigating the JavaScript code, it seems that only the last map added is being considered. In my case, this is the map with the GPX tracks. As a result, the links with marker targets on the first map are not working.

    Has anyone encountered a similar problem or have any suggestions on how to resolve this? Any help would be greatly appreciated!

    Thanks in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author hupe13

    (@hupe13)

    targetmarker does work with one map on a post/page only. I put it on the wishlist.

    Plugin Author hupe13

    (@hupe13)

    How is your shortcode for targetmarker / targetlink?

    Thread Starter leoriccio

    (@leoriccio)

    This is the shortcode per the map (a snippet)

    [leaflet-map]
    [leaflet-extramarker lat=44.07375280310988 lng=11.689234549893753 icon=fa-utensils prefix=fa iconColor=white title=agriturismo-badia-della-valle color=red]Agriturismo Badia della Valle[/leaflet-extramarker]

    And this is the code i used for targetlink

    [targetlink title=agriturismo-badia-della-valle linktext="Agriturismo Badia della Valle" map=0]

    As you can see i added a parameter to specify the map i’m referring to (0 to n in the order of being added to the page). I have modified the source code to handle the new parameter, but it’s a hack.

    targetmarker.js (i changed this function adding the check for the map parameter)

    // targetmarker same site - search with title
    function leafext_target_same_title_js(mapID, title, target, zoom, debug) {
    console.log("leafext_target_same_title_js", title, target, zoom, debug);
    window.WPLeafletMapPlugin = window.WPLeafletMapPlugin || [];
    window.WPLeafletMapPlugin.push(
    function () {
    var map;
    if (mapID === '') {
    map = window.WPLeafletMapPlugin.getCurrentMap();
    } else {
    map = window.WPLeafletMapPlugin.maps[mapID];
    }
    leafext_target_marker_title_do(map, title, target, zoom, debug);
    }
    );
    }
    targetmarker.php (i added the map parameter in the handleing of the shortcode and creation of the link)

    ...
    $options = shortcode_atts(
    array(
    'lat' => '',
    'lng' => '',
    'property' => '',
    'value' => '',
    'title' => '',
    'link' => '',
    'linktext' => 'Target',
    'popup' => 'Target',
    'map' => '',
    'zoom' => false,
    'debug' => false,
    ),
    leafext_clear_params($atts)
    );
    ...
    } elseif ($options['title'] !== '') {
    // marker title on the same page / post
    $text = '<a href="javascript:leafext_jump_to_map();" onclick="leafext_target_same_title_js('
    . '\'' . $options['map'] . '\','
    . '\'' . $options['title'] . '\','
    . '\'' . $options['popup'] . '\','
    . $options['zoom'] . ','
    . wp_json_encode($options['debug'])
    . ')">' . $options['linktext'] . '</a>';
    return $text;
    }

    This hack seems to work in my case.

    Plugin Author hupe13

    (@hupe13)

    Thank you very much.

    map=0

    I have a more comfortable approach: mapid from leaflet-map.

    Thread Starter leoriccio

    (@leoriccio)

    No problem, i needed i quick solution since i was in hurry.
    I will wait for the official solution.

    Plugin Author hupe13

    (@hupe13)

    Released.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.