Skip to content

Select marker #2361

Closed Answered by kleynjan
RichDijk asked this question in Q&A
Jan 12, 2024 · 4 comments · 12 replies
Discussion options

You must be logged in to vote

Edited 13/03/2024, cleaned up code, JS converted to camelCase, demo now deletes clicked marker.

// /static/markers.js

var markers = { 'initialized': false, 'featureGroup': null, 'icon': null };

function initMarkers(mapId) {
    // run after leaflet is loaded
    if ( ! markers.initialized ) {

        var map = getElement(mapId).map;       // see templates/index.html
        // map = window.app.$refs["r" + mapId].map;
        if ( ! map ) {
            console.log('Leaflet map object ' + mapId + ' not found');
            return;
        }  

        // group all markers in featureGroup and add to map
        markers.featureGroup = new L.featureGroup([]);
        map.addLayer(markers.fe…

Replies: 4 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
12 replies
@kyuhyong
Comment options

@kleynjan
Comment options

@kyuhyong
Comment options

@kyuhyong
Comment options

@kleynjan
Comment options

Answer selected by rodja
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants