1let map; 2 3async function initMap() { 4 5 if(!document.querySelector(".mob-maps")) return; 6 7 // Request needed libraries. 8 const { Map, InfoWindow } = await google.maps.importLibrary("maps"); 9 const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary( 10 "marker", 11 ); 12 13 console.log(document.querySelector(".mob-maps")) 14 let data_location = JSON.parse(document.querySelector(".mob-maps").dataset.locations); 15 let zoom = document.querySelector(".mob-maps").dataset.zoom; 16 17 if (!data_location.length) return; 18 19 const head_location = data_location.filter((e) => e.center); 20 map = new Map(document.getElementById("maps"), { 21 center: new google.maps.LatLng(head_location[0].lat, head_location[0].long), 22 zoom: parseInt(zoom), 23 mapId: "79577c72ac6b03f9", 24 25 }); 26 27 const icons = { 28 parking: { 29 icon: global_vars.marker_parking, 30 }, 31 bus: { 32 icon: global_vars.marker_bus, 33 }, 34 metting: { 35 icon: global_vars.marker_metting, 36 }, 37 train: { 38 icon: global_vars.marker_train, 39 }, 40 head: { 41 icon: global_vars.marker, 42 }, 43 }; 44 45 let locations = data_location.map(obj => ({ ...obj, type: obj.center ? 'head' : obj.type })); 46 47 const infoWindow = new InfoWindow(); 48 49 for (let i = 0; i < locations.length; i++) { 50 const iconImage = document.createElement("img"); 51 iconImage.src = icons[locations[i].type].icon; 52 53 let zIndex = locations[i].center ? 99 : 1; 54 55 let pos = { 56 lat: parseFloat(locations[i].lat), 57 lng: parseFloat(locations[i].long), 58 }; 59 60 const marker = new AdvancedMarkerElement({ 61 map, 62 position: pos, 63 content: iconImage, 64 zIndex: zIndex 65 }); 66 67 let contentString = locations[i].name; 68 69 marker.addListener("click", () => { 70 infoWindow.close(); 71 infoWindow.setContent(contentString); 72 infoWindow.open(marker.map, marker); 73 }); 74 } 75} 76 77initMap();
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.