

Google Maps provides buttons for switching between different map types. Second Step: Add a Cached Basemap to Google Maps as a Map-Type Button The Google map is centered and zoomed at the location specified. Save the page and load it into a browser (double-click on the file in a browser, or access it through the web server's URL). This is a Google Maps function designed to prevent memory leaks. When the page unloads, it should call GUnload. When the page loads, it should run the initialize function from the previous step. It then centers the map on the coordinates named earlier, at zoom level 11.įinally, in the body tag, tell the page what to do when it loads and unloads: It adds a large map control (navigation buttons and a zoom level slider) and a map type control (buttons that allow you to switch between Map, Satellite, and Hybrid maps). The function then does three things to the map. In this case, the coordinate 38.897000, -77.02000 is where the code will center the map when it opens (Washington DC). It's a way to specify a set of coordinates. The centerat variable is a GLatLng object. The initialize function creates a map and connects it with the DIV tag created in the previous step. Gmap = new GMap2(document.getElementById("gmap")) In the head of the page, add a script block with a function to create the Google map: The width and height of the map are specified in the style attribute of the div: Inside the page body, add a div element that will contain the map. In this example the key is shown as “abcdefg.” Replace it with a unique key.

It also includes a unique Google Maps API key. This line tells the page where to find the JavaScript file that includes all of the symbols and definitions needed for using the Google Maps API. Load the Google Maps API by adding the following line in the header section, just after the meta tag (see the complete code at the bottom of this page if unsure where it goes): Paste or type the following content to create an outline for the HTML page:ĪrcGIS JavaScript Extension for the Google Maps API Example Create the page in a web server's folders, or in any location on the hard disk.

In an HTML or text editor, create a new web page or file. This example shows how to display a Google map inside a web page. First Step: Create a Basemap with Google Maps
