function leafext_target_get_lanlng_js(lat,lng,target,mapid,zoom,debug){console.log("leafext_target_get_lanlng_js",lat,lng,target,mapid,zoom,debug);var map=leafext_get_map(mapid);var markerClusterGroup;thismapbounds=[];if(WPLeafletMapPlugin.markers.length>0){map.whenReady(function(){if(debug){L.circleMarker(L.latLng(lat,lng),{radius:3,color:"red"}).bindPopup("latlng").addTo(map);let mapbounds=map.getBounds();L.rectangle(mapbounds,{color:"yellow",weight:1}).addTo(map)}leafext_target_latlng_marker_do(map,lat,lng,target,zoom,debug)})}else{var geojsons=window.WPLeafletMapPlugin.geojsons;if(geojsons.length>0){var geocount=geojsons.length;for(var j=0,len=geocount;j<len;j++){var geojson=geojsons[j];if(map._leaflet_id==geojson._map._leaflet_id){geojson.on("ready",function(){let mapbounds=map.getBounds();if(mapbounds.contains(L.latLng(lat,lng))){leafext_target_latlng_geojson_do(map,lat,lng,this.layer,target,zoom,debug)}})}}}}}function leafext_target_same_lanlng_js(lat,lng,target,mapid,zoom,debug){console.log("leafext_target_same_lanlng_js",lat,lng,target,mapid,zoom,debug);window.WPLeafletMapPlugin=window.WPLeafletMapPlugin||[];window.WPLeafletMapPlugin.push(function(){var map=leafext_get_map(mapid);var markerClusterGroup;thismapbounds=[];if(WPLeafletMapPlugin.markers.length>0){if(debug){L.circleMarker(L.latLng(lat,lng),{radius:3,color:"red"}).bindPopup("latlng").addTo(map)}leafext_target_latlng_marker_do(map,lat,lng,target,zoom,debug)}else{var geojsons=window.WPLeafletMapPlugin.geojsons;if(geojsons.length>0){var geocount=geojsons.length;for(var j=0,len=geocount;j<len;j++){var geojson=geojsons[j];leafext_target_latlng_geojson_do(map,lat,lng,geojson,target,zoom,debug)}}}})}function leafext_target_latlng_marker_do(map,lat,lng,target,zoom,debug){console.log("leafext_target_latlng_marker_do",lat,lng,target,zoom,debug);var closest=Number.MAX_VALUE;var closestMarker;let latlng=L.latLng(lat,lng);let radius;var markergroups=window.WPLeafletMapPlugin.markergroups;Object.entries(markergroups).forEach(([key,value])=>{if(markergroups[key]._map!==null){if(map._leaflet_id==markergroups[key]._map._leaflet_id){markergroups[key].eachLayer(function(layer){if(layer instanceof L.Marker){if(layer._preSpiderfyLatlng){radius=layer._preSpiderfyLatlng.distanceTo(latlng)}else{radius=layer.getLatLng().distanceTo(latlng)}if(radius<closest){closest=radius;closestMarker=layer}}})}}});if(debug){L.circle(latlng,{radius:closest,color:"red"}).bindPopup("radius").addTo(map);L.circle(closestMarker.getLatLng(),{radius:closest,color:"blue"}).bindPopup("closestMarker").addTo(map)}leafext_zoom_to_closest("latlng",closest,closestMarker,target,zoom,map,debug);leafext_jump_to_map(map._leaflet_id)}function leafext_target_latlng_geojson_do(map,lat,lng,geolayer,target,zoom,debug){console.log("leafext_target_latlng_geojson_do",lat,lng,target,zoom,debug);let latlng=L.latLng(lat,lng);let mapbounds=map.getBounds();if(debug){L.circleMarker(latlng,{radius:3,color:"red"}).bindPopup("latlng").addTo(map)}var closest=Number.MAX_VALUE;var closestMarker;let radius;geolayer.eachLayer(function(layer){if(layer.feature.geometry.type=="Point"){if(layer._preSpiderfyLatlng){radius=layer._preSpiderfyLatlng.distanceTo(latlng)}else{radius=layer.getLatLng().distanceTo(latlng)}if(radius<closest){closest=radius;closestMarker=layer}}});if(debug&&closest<Number.MAX_VALUE){L.circle(latlng,{radius:closest,color:"red"}).bindPopup("radius").addTo(map);L.circle(closestMarker.getLatLng(),{radius:closest,color:"blue"}).bindPopup("closestMarker").addTo(map)}leafext_zoom_to_closest("geojson",closest,closestMarker,target,zoom,map,debug)}function leafext_target_same_title_js(title,target,mapid,zoom,debug){console.log("leafext_target_same_title_js",title,target,mapid,zoom,debug);let leaflet_id;window.WPLeafletMapPlugin=window.WPLeafletMapPlugin||[];window.WPLeafletMapPlugin.push(function(){var map=leafext_get_map(mapid);leaflet_id=map._leaflet_id;leafext_target_marker_title_do(map,title,target,zoom,debug)});return leaflet_id}function leafext_target_post_title_js(title,target,mapid,zoom,debug){console.log("leafext_target_post_title_js",title,target,mapid,zoom,debug);var map=leafext_get_map(mapid);map.whenReady(function(){leafext_target_marker_title_do(map,title,target,zoom,debug);leafext_jump_to_map(map._leaflet_id)})}function leafext_target_marker_title_do(map,title,target,zoom,debug){console.log("leafext_target_marker_title_do",title,target,zoom,debug);thismapbounds=[];var markerClusterGroup;var closest=Number.MAX_VALUE;var closestMarker;var markergroups=window.WPLeafletMapPlugin.markergroups;Object.entries(markergroups).forEach(([key,value])=>{if(markergroups[key]._map!==null){if(map._leaflet_id==markergroups[key]._map._leaflet_id){markergroups[key].eachLayer(function(layer){if(layer instanceof L.Marker){if(layer.options.title==title||layer.options.title_bak==title){if(debug){console.log(title)}closestMarker=layer;closest=0}}})}}});leafext_zoom_to_closest("title",closest,closestMarker,target,zoom,map,debug);leafext_jump_to_map(map._leaflet_id)}function leafext_target_same_geojson_js(geojsonproperty,geojsonvalue,target,mapid,zoom,debug){console.log("leafext_target_same_geojson_js",geojsonproperty,geojsonvalue,target,mapid,zoom,debug);window.WPLeafletMapPlugin=window.WPLeafletMapPlugin||[];var markerClusterGroup;window.WPLeafletMapPlugin.push(function(){var map=leafext_get_map(mapid);thismapbounds=[];var map_id=map._leaflet_id;var geojsons=window.WPLeafletMapPlugin.geojsons;var geocount=geojsons.length;if(geocount>0){for(var j=0,len=geocount;j<len;j++){var geojson=geojsons[j];if(map_id==geojson._map._leaflet_id){geojson.eachLayer(function(geolayer){leafext_target_geojson_do(geolayer,geojsonproperty,geojsonvalue,target,zoom,map,debug)});leafext_jump_to_map(map._leaflet_id)}}}})}function leafext_target_post_geojson_js(geojsonproperty,geojsonvalue,target,mapid,zoom,debug){console.log("leafext_target_post_geojson_js",geojsonproperty,geojsonvalue,target,mapid,zoom,debug);var map=leafext_get_map(mapid);thismapbounds=[];var map_id=map._leaflet_id;var geojsons=window.WPLeafletMapPlugin.geojsons;var geocount=geojsons.length;if(geocount>0){for(var j=0,len=geocount;j<len;j++){var geojson=geojsons[j];if(map_id==geojson._map._leaflet_id){geojson.on("ready",function(){this.eachLayer(function(geolayer){leafext_target_geojson_do(geolayer,geojsonproperty,geojsonvalue,target,zoom,map,debug)});leafext_jump_to_map(map._leaflet_id)})}}}}function leafext_target_geojson_do(geolayer,geojsonproperty,geojsonvalue,target,zoom,map,debug){if(geolayer.feature[geojsonproperty]==geojsonvalue){if(geolayer.__parent){if(debug){console.log("closest geojson marker in cluster")}var markerClusterGroup=geolayer.__parent._group;leafext_zoomto_clmarker(geolayer,target,markerClusterGroup,map,debug)}else{if(debug){console.log("closest geojson marker not in cluster")}leafext_zoomto_marker(geolayer,target,zoom,map,debug)}}};