Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add files via upload
  • Loading branch information
JunaTeresMartin authored Oct 29, 2023
commit 08b2ebd90272225272633a3fb6ad06ddeea131a0
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Add Map</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>

<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="module" src="main.js"></script>
</head>
<body>
<center><h2>AfterHours</h2></center>
<!--The div element for the map -->
<div id="map"></div>
<!-- Add a location input field -->
<input type="text" id="locationInput" placeholder="Enter a location" />
<button onclick="searchLocation()">Search</button>

<!-- prettier-ignore -->
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyDy1a-eEAO2-F00bAHH6LlgonEwutrVkS4", v: "beta"});</script>
</body>
</html>
41 changes: 41 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Initialize and add the map
let map;

async function initMap() {
// The location of Uluru
const position = { lat: -25.344, lng: 131.031 };
// Request needed libraries.
//@ts-ignore
const { Map } = await google.maps.importLibrary("maps");
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");


// Define a map style for dark mode
const darkModeStyle = [
{
featureType: "all",
elementType: "labels.text.fill",
stylers: [{ color: "#ffffff" }],
},
// Add more style configurations as needed.
];


// The map, centered at Uluru
map = new Map(document.getElementById("map"), {
zoom: 4,
center: position,
mapId: "DEMO_MAP_ID",
styles: darkModeStyle,
});

// The marker, positioned at Uluru
const marker = new AdvancedMarkerElement({
map: map,
position: position,
title: "Uluru",
});
}

initMap();

20 changes: 20 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Always set the map height explicitly to define the size of the div element
* that contains the map.
*/
#map {
height:80%;
width: 80%;
align-items: center;
margin-left: 150px;
}

/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}