/** This demo illustrates the coordinate system used to display map tiles in the* API.** Tiles in Google Maps are numbered from the same origin as that for* pixels. For Google's implementation of the Mercator projection, the origin* tile is always at the northwest corner of the map, with x values increasing* from west to east and y values increasing from north to south.** Try panning and zooming the map to see how the coordinates change.*/classCoordMapTypeimplementsgoogle.maps.MapType{tileSize:google.maps.Size;alt:string|null=null;maxZoom:number=17;minZoom:number=0;name:string|null=null;projection:google.maps.Projection|null=null;radius:number=6378137;constructor(tileSize:google.maps.Size){this.tileSize=tileSize;}getTile(coord:google.maps.Point,zoom:number,ownerDocument:Document):HTMLElement{constdiv=ownerDocument.createElement("div");div.innerHTML=String(coord);div.style.width=this.tileSize.width+"px";div.style.height=this.tileSize.height+"px";div.style.fontSize="10";div.style.borderStyle="solid";div.style.borderWidth="1px";div.style.borderColor="#AAAAAA";returndiv;}releaseTile(tile:Element):void{}}functioninitMap():void{constmap=newgoogle.maps.Map(document.getElementById("map")asHTMLElement,{zoom:10,center:{lat:41.85,lng:-87.65},});// Insert this overlay map type as the first overlay map type at// position 0. Note that all overlay map types appear on top of// their parent base map.constcoordMapType=newCoordMapType(newgoogle.maps.Size(256,256))map.overlayMapTypes.insertAt(0,coordMapType);}declareglobal{interfaceWindow{initMap:()=>void;}}window.initMap=initMap;
/** This demo illustrates the coordinate system used to display map tiles in the* API.** Tiles in Google Maps are numbered from the same origin as that for* pixels. For Google's implementation of the Mercator projection, the origin* tile is always at the northwest corner of the map, with x values increasing* from west to east and y values increasing from north to south.** Try panning and zooming the map to see how the coordinates change.*/classCoordMapType{tileSize;alt=null;maxZoom=17;minZoom=0;name=null;projection=null;radius=6378137;constructor(tileSize){this.tileSize=tileSize;}getTile(coord,zoom,ownerDocument){constdiv=ownerDocument.createElement("div");div.innerHTML=String(coord);div.style.width=this.tileSize.width+"px";div.style.height=this.tileSize.height+"px";div.style.fontSize="10";div.style.borderStyle="solid";div.style.borderWidth="1px";div.style.borderColor="#AAAAAA";returndiv;}releaseTile(tile){}}functioninitMap(){constmap=newgoogle.maps.Map(document.getElementById("map"),{zoom:10,center:{lat:41.85,lng:-87.65},});// Insert this overlay map type as the first overlay map type at// position 0. Note that all overlay map types appear on top of// their parent base map.constcoordMapType=newCoordMapType(newgoogle.maps.Size(256,256));map.overlayMapTypes.insertAt(0,coordMapType);}window.initMap=initMap;
/** Always set the map height explicitly to define the size of the div element* that contains the map.*/#map{height:100%;}/** Optional: Makes the sample page fill the window.*/html,body{height:100%;margin:0;padding:0;}
<html>
<head>
<title>Overlay Map Types</title>
<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
</head>
<body>
<div id="map"></div>
<!--
The `defer` attribute causes the script to execute after the full HTML
document has been parsed. For non-blocking uses, avoiding race conditions,
and consistent behavior across browsers, consider loading using Promises. See
https://developers.google.com/maps/documentation/javascript/load-maps-js-api
for more information.
-->
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initMap&v=weekly"
defer
></script>
</body>
</html>
Git and Node.js are required to run this sample locally. Follow theseinstructionsto install Node.js and NPM. The following commands clone, install dependencies and start the sample application.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-12-11 UTC."],[],[]]