Closed akorosov closed 3 years ago
that should work:
var footprints_layer_style = { "color": "#0000ff", "weight": 1, "opacity": 0.5, "fillOpacity": 0.1, }; function add_geojson_geometries(map) { var geoms = document.getElementsByClassName("geometry_ref"); for (var i = 0; i < geoms.length; i++) { all_geoms.push(new L.GeoJSON.AJAX( "https://web.nersc.no" + geoms.item(i).attributes.ajax_url.value, {style: footprints_layer_style}).addTo(map)); }; }; function map_init_callback(e){ map = e.detail.map; }; $(window).on('map:init', map_init_callback); var polygons = {}; $(document).ready(function(){ $(".geometry_ref").each(function(){ polygons[$(this).attr("ajax_url")] = new L.GeoJSON.AJAX( "https://web.nersc.no" + $(this).attr("ajax_url"), {style: footprints_layer_style}).addTo(map); }); $(".geometry_ref").hover( function(){ $(this).css("background-color", "#ffeeee"); polygons[$(this).attr("ajax_url")].setStyle({color: '#FF0000'}); polygons[$(this).attr("ajax_url")].options.style.color = '#FF0000'; }, function(){ $(this).css("background-color", "#ffffff"); polygons[$(this).attr("ajax_url")].setStyle({color: '#0000FF'}); polygons[$(this).attr("ajax_url")].options.style.color = '#0000FF'; }, ); });
that should work: