1(function(){ 2 const SRC_ID = 'src-multi_selected_roads'; 3 const LAYER_ID = 'multi_selected_roads'; 4 const STORE_KEY = '__multiSelectedRoads'; 5 6 function getMap(){ 7 try { return window.mapManager?.getCurrentMap?.() || window.mapManager?.getMap?.('3d') || null; } catch(_) { return null; } 8 } 9 10 function ensureLayer(){ 11 const map = getMap(); if (!map) return; 12 if (!map.getSource(SRC_ID)) map.addSource(SRC_ID, { type:'geojson', data:{ type:'FeatureCollection', features:[] } }); 13 if (!map.getLayer(LAYER_ID)) { 14 const beforeId = (()=>{ try { const layers=(map.getStyle()?.layers)||[]; for (let i=0;i<layers.length;i++){ if (layers[i].type==='symbol') return layers[i].id; } } catch(_){} return undefined; })(); 15 map.addLayer({ id:LAYER_ID, type:'line', source:SRC_ID, paint:{ 'line-color':'#22c55e', 'line-width':4, 'line-opacity':0.9 } }, beforeId); 16 } 17 } 18 19 function updateLayer(){ 20 const map = getMap(); if (!map) return; 21 ensureLayer(); 22 const items = window[STORE_KEY] || []; 23 const feats = items.map(it => ({ type:'Feature', properties:{ osm_id: it.id }, geometry: it.geometry })).filter(f => !!(f.geometry && (f.geometry.type==='LineString' || f.geometry.type==='MultiLineString'))); 24 map.getSource(SRC_ID).setData({ type:'FeatureCollection', features: feats }); 25 } 26 27 function add(feature){ 28 if (!feature || !feature.geometry) return; 29 const id = feature.properties?.osm_id ?? feature.properties?.road_id ?? feature.id ?? Math.random().toString(36).slice(2); 30 const items = (window[STORE_KEY] = window[STORE_KEY] || []); 31 if (items.find(x => String(x.id) === String(id))) return; // already in list 32 items.push({ id, geometry: feature.geometry }); 33 updateLayer(); 34 } 35 36 function clear(){ 37 try { window[STORE_KEY] = []; } catch(_) {} 38 const map = getMap(); if (!map) return; 39 try { if (map.getSource(SRC_ID)) map.getSource(SRC_ID).setData({ type:'FeatureCollection', features:[] }); } catch(_) {} 40 } 41 42 function getGeometries(){ 43 try { return (window[STORE_KEY] || []).map(x => x.geometry); } catch(_) { return []; } 44 } 45 46 // Listen road:selected and collect 47 window.addEventListener('road:selected', (evt) => { 48 try { add(evt?.detail?.feature); } catch(_) {} 49 }); 50 window.addEventListener('road:cleared', () => { try { clear(); } catch(_) {} }); 51 52 // Harita tıklamasında (seçim modu kapalıyken) temizle 53 const map = getMap(); 54 if (map) { 55 map.on('click', () => { 56 const selecting = !!(window.selectRoad && typeof window.selectRoad.isActive === 'function' && window.selectRoad.isActive()); 57 if (!selecting) clear(); 58 }); 59 map.on('styledata', ensureLayer); 60 } 61 62 window.MultiRoadSelect = { add, clear, getGeometries, updateLayer }; 63})(); 64 65
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.