Article Content
<html>
</body>
<style>
/* Customizing a Map on Google My Maps */
.map-title {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.map-container {
width: 100%;
height: 80vh;
}
.map-control {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
background-color: #f0f0f0;
border-bottom: 1px solid #ccc;
}
.map-title:hover, .map-control:hover {
background-color: #ddd;
}
/* Create a Custom Map */
.create-map-container {
width: 50%;
margin: auto;
}
.create-map-input {
width: 100%;
height: 40px;
padding: 10px;
font-size: 18px;
}
.create-map-submit {
width: 80%;
padding: 10px;
font-size: 16px;
cursor: pointer;
}
/* Customize the Map */
.map-image {
width: 50%;
height: 40vh;
}
.map-style {
background-color: #ccc;
border: 1px solid #ddd;
}
.map-info {
font-size: 18px;
margin-bottom: 20px;
}
/* Display the Map in Google My Maps */
.google-my-maps-container {
width: 100%;
height: 80vh;
border: 1px solid #ccc;
}
.map-control:hover {
background-color: #eee;
}
@media (max-width: 768px) {
.create-map-input {
padding: 10px;
}
.google-my-maps-container {
height: 60vh;
}
}
@media (max-width: 480px) {
.map-title {
font-size: 20px;
}
.create-map-input {
padding: 5px;
}
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD3uX8Yw1zQ&callback=initMap" async defer></script>
<script>
function initMap() {
const myMap = new google.maps.Map(document.getElementById("google-my-maps-container"), {
center: {
lat: 37.7749,
lng: -122.4194
},
zoom: 12,
styles: [
{
featureType: "water",
weight: 2,
color: "#66ccff"
},
{
featureType: "road",
weight: 1,
color: "#ccc"
}
]
});
const mapTitle = document.getElementById("map-title");
mapTitle.innerHTML = "Custom Map";
const createMapInput = document.getElementById("create-map-input");
createMapInput.addEventListener("input", function() {
const inputValue = this.value;
myMap.setStyle({
styles: [
{
featureType: "road",
weight: 1,
color: "#ccc"
},
{
featureType: "water",
weight: 2,
color: "#66ccff"
}
]
}, inputValue);
});
const mapStyle = document.getElementById("map-style");
mapStyle.innerHTML = "";
const createMapButton = document.getElementById("create-map-button");
createMapButton.addEventListener("click", function() {
const inputValue = document.getElementById("input-value").value;
myMap.setStyles([
{
featureType: "road",
weight: 1,
color: "#ccc"
},
{
featureType: "water",
weight: 2,
color: "#66ccff"
}
], inputValue);
});
}
function updateMap() {
const map = myMap;
map.setCenter({
lat: document.getElementById("center-lat").value,
lng: document.getElementById("center-lng").value
}, mapZoom);
const style = document.getElementById("style");
const inputValues = Array.from(style.children).map(child => child.value);
map.setStyles(inputValues, "custom");
}
</script>
<div class="google-my-maps-container" id="google-my-maps-container">
Create Map child.value);
map.setStyles(inputValues, "custom");
}
createMapButton.addEventListener("click", function() {
createMapInput.value = "";
updateCenter();
});
styleFeatureTypeSelect.addEventListener("change", function() {
updateStyle();
});
styleStyleInput.addEventListener("input", function() {
const inputValue = this.value;
map.setStyles([
{
featureType: "road",
weight: 1,
color: "#ccc"
},
{
featureType: "water",
weight: 2,
color: "#66ccff"
}
], inputValue, "custom");
});
updateStyle();
updateCenter();
</script>
<div class="map-info"></div>
<script>
function updateMap() {
const map = myMap;
map.setCenter({
lat: parseFloat(document.getElementById("center-lat").value),
lng: parseFloat(document.getElementById("center-lng").value)
}, mapZoom);
}
</script>
<div class="google-my-maps-container" id="google-my-maps-container">
https://www.google.com/maps/d/viewer?mid=1yDVtj2DnTnAylICKIq0yuCRISsZU5Cxd