} padding: 10px; border: 1px solid #ccc; height: 400px; width: 600px; #map { } margin: 20px; font-family: Arial, sans-serif; body { /* Add some basic styling to our map */

Creating Custom Maps on Google My Maps

Create custom maps on Google My Maps by using the Map Viewer API. This article will guide you through the process of creating a customized map.

To start, create an account and enable the Map Viewer API in your Google Cloud Console (). Once enabled, click on "Maps" and then select "Map Viewers".

Preparing Your Map Data

Before you can display your custom map, you'll need to prepare the data. This includes creating a JSON file with your desired map layout, including markers, polygons, and labels.

<json>
{
  "map": {
    "center": {
      "lat": 37.7749,
      "lng": -122.4194
    },
    "zoom": 12,
    "scale": 1
  },
  "markers": [
    {
      "location": {
        "lat": 37.7858,
        "lng": -122.4364
      },
      "title": "First Markers"
    },
    {
      "location": {
        "lat": 37.7862,
        "lng": -122.4371
      },
      "title": "Second Markers"
    }
  ],
  "polygons": [
    {
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [[-122.4363, 37.7858], [-122.4356, 37.7862], [-122.4364, 37.7871], [-122.4356, 37.7858]]
        ]
      },
      "title": "Polygons"
    }
  ],
  "labels": [
    {
      "location": {
        "lat": 37.7749,
        "lng": -122.4194
      },
      "text": "Google My Maps Custom Map"
    }
  ]
}</json>

Displaying Your Custom Map

Once your map data is prepared, you can display it by uploading the JSON file to Google My Maps. To do this, click on "My Maps" and then select the map where you want to add the custom map.

<script>
  const map = new google.maps.Map(document.getElementById("map"), {
    center: {lat: 37.7749, lng: -122.4194},
    zoom: 12,
    scale: 1
  });

  // Add markers and polygons to the map
  const marker = new google.maps.Marker({
    position: {lat: 37.7858, lng: -122.4364},
    title: "First Markers"
  });
  
  const polygon = new google.maps_polygon({
    geometry: {type: "Polygon", coordinates: [[-122.4363, 37.7858], [-122.4356, 37.7862], [-122.4364, 37.7871], [-122.4356, 37.7858]]}
  });
  
  // Add labels to the map
  const label = new google.maps_label({
    position: {lat: 37.7749, lng: -122.4194},
    text: "Google My Maps Custom Map"
  });
  
  // Add markers and polygons and labels to the map
  map.set("markers", [marker, polygon, label]);
</script>

Customizing Your Map

Once your custom map is displayed, you can customize it as needed. This includes adding borders, changing colors, and modifying markers and polygons.

For more information on how to customize Google My Maps, visit the official documentation ().

https://www.google.com/maps/d/viewer?mid=1Tr_67pjwuY3G_9ZJzJAtXhlgJ-syu6kW