1/* 2 * Map Block 3 */ 4function renderMap(elementId, mapConfig, markerCoordinates) { 5 var mapType = mapConfig.mapType || window.google.maps.MapTypeId.ROADMAP; 6 var zoom = isNaN(mapConfig.zoom) ? 6 : mapConfig.zoom; 7 8 if (mapType === "streetview") { 9 mapType = window.google.maps.MapTypeId.ROADMAP; 10 } 11 12 // Create the map 13 var map = new window.google.maps.Map(document.getElementById(elementId), { 14 center: mapConfig.centerCoordinates, 15 zoom: zoom, 16 mapTypeId: mapType, 17 }); 18 19 if (typeof markerCoordinates !== "object" || markerCoordinates === null) return; 20 21 // Put a marker on the map 22 new window.google.maps.Marker({ 23 position: markerCoordinates, 24 map: map 25 }); 26 27 if (typeof mapConfig.streetview !== "object" || mapConfig.streetview === null) return; 28 29 // Change the map into streetview mode 30 var panorama = map.getStreetView(); 31 panorama.setPosition(mapConfig.streetview.coordinates); 32 panorama.setPov(mapConfig.streetview.pov); 33 panorama.setVisible(true); 34} 35 36// If mapBlocks have been populated with options, then render the maps 37if (window.mapBlocks && window.mapBlocks.length > 0) { 38 const apiKey = window.mapBlocks[0].mapConfig.apiKey; 39 // Create the script tag, set the appropriate attributes 40 const script = document.createElement('script'); 41 script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=onGMapReady`; 42 script.async = true; 43 44 // Attach your callback function to the `window` object 45 window.onGMapReady = function () { 46 for (var i = 0; i < window.mapBlocks.length; i++) { 47 const mapBlock = window.mapBlocks[i]; 48 renderMap(mapBlock.elementId, mapBlock.mapConfig, mapBlock.markerCoordinates); 49 } 50 }; 51 52 // Append the 'script' element to 'head' 53 document.head.appendChild(script); 54}
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.