Creating A Basic Google Map

From Fishcakes Wiki

Jump to: navigation, search
Edit Menu

Image:Icon_Google_Maps_40px.png Creating a Basic Google Map

This page contains a guide to setting up a Basic Google Map.

Contents

Basic Google Map

How to setup a very basic Google Map on your website. This is the HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAYBB_NyS1YelEH_91Z4JRxRTPO8D1fuP4Dvehrkb7tbDtd9g_0xTVWArpb3eavxmG2-67-ZM8bD7Geg" type="text/javascript"></script>
      <meta name="gmapkey" content="ABQIAAAAYBB_NyS1YelEH_91Z4JRxRTPO8D1fuP4Dvehrkb7tbDtd9g_0xTVWArpb3eavxmG2-67-ZM8bD7Geg" />
      <script src="gmapez2.js" type="text/javascript"></script>
   </head>
 
   <body>
      <div class="GMapEZ GLargeMapControl GMapTypeControl GScaleControl" style="width: 400px; height: 400px;">
         <a href="http://maps.google.co.uk/maps?f=q&hl=en&q=fishcakes+media&sll=51.531236,-0.131021&sspn=0.007195,0.014892&ie=UTF8&z=16&ll=51.532602,-0.130935&spn=0.007195,0.014892&om=1&iwloc=A"></a>
      </div>
   </body>
 
</html>

The code in the HTML Head initialises the Google Maps API. The code in the HTML Body creates a DIV for displaying the Map.


Information about Advanced Google Maps functions such as externalising the API key, etc.

Storing Google Maps API Key in External PHP File

It's easiest to call the API key from an external file so you only have to enter it once on each site. 1. Find your root folder by inserting this code into an PHP map file:

Root = <?php echo $_SERVER['DOCUMENT_ROOT'] ?>

2. Save a file api_key_googlemaps.php to your root folder with the following code:

<?php $api_key = "YourApiKey"; ?>

3. Insert into the Header of your PHP Map file:

<?php include $_SERVER['DOCUMENT_ROOT'] . '/api_key_googlemaps.php'; ?>

4. Change your Google API script to:

<script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $api_key ?>" type="text/javascript"></script>


Image:Icon Resources 20px.png Google Maps Links

Official Google Maps Links

Unofficial Google Maps Links

Great Google Maps Sites

Other Google Applications

  • Google Trends — compare the world's interest in your favourite topics.


Personal tools