Jump to content

Help with Google Maps


ryanfc

Recommended Posts

I am trying to put Google Maps into my web site and for some reason it is not working.

 

Explanation of what is happening on the page:  When a user click on a client on a previous page it takes them to client_detail.php.  Here it loads the information just for that client.  I am attempting to pull the address, city and state from the database and feed that to the google maps.  But when the page loads it gives me an error saying I have not entered the correct API Key for this web site.  However I am copying and pasting it straight from the page it generates.  So I am wondering if the problem is in my code or if I need to contact google.  Can anyone take a look and tell me if I am doing anything wrong?  Thanks.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>myevvspace.com | premium local listings</title>

<link href="myevvspace_style.css" rel="stylesheet" type="text/css" />
<script src="navigation.js" type="text/javascript" language="javascript"></script>

<?php
//database info taken out


$category_num = (int)$_GET['category'];
$sub_category_num = (int)$_GET['sub_category'];

$key = "ABQIAAAA_xQ_dEBiJhTWuUYd_GnQCxRhPeVs-Y5MVG7J1BB2XI6iFoNTnBT7lQQVb07RhoCpKomWQg7UmVesPww";

// Collects data from "friends" table
$data = mysql_query("SELECT * FROM client WHERE category = '$category_num' AND sub_category = '$sub_category_num' order by name")
or die(mysql_error());

$filtertext = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

$categorycrumb = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

$subcategorycrumb = mysql_query("SELECT * FROM sub_category WHERE id = '$sub_category_num'")
or die(mysql_error());

$sub_list = mysql_query("SELECT * FROM sub_category WHERE category = '$category_num' order by title")
or die(mysql_error());

$location = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

mysql_close ($conn);
?>

<?php
while (list($id, $address, $city, $state) = mysql_fetch_row($data))
   {
      $mapaddress = urlencode("$address $city $state");


      $url = "http://maps.google.com/maps/geo?q=$mapaddress&output=xml&key=$key";


      $page = file_get_contents($url);

    
      $xml = new SimpleXMLElement($page);


      list($longitude, $latitude, $altitude) = explode(",", $xml->Response->Placemark->Point->coordinates);


      //echo "latitude: $latitude, longitude: $longitude <br />";

   }
?>

<script src="http://maps.google.com/maps?file=api&v=2&key=mykey"
      type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());

        map.setCenter(new GLatLng(<?php echo "$latitude"; ?> ?>, <?php echo "$longitude"; ?>), 13);
      }
    }
    //]]>
    </script>

</head>

<body onload="load()" onunload="GUnload()">
<div id="header"><?php include("includes/header.php"); ?></div>
<div id="navigation"><?php include("includes/navigation.php"); ?></div>
<div id="banner"><?php include("includes/ads/banner.php"); ?></div>
<div id="leftcontent">


<p><form class="filter" method="GET" action="client_filter.php"><?php

$cat1 = "Select a Cuisine:<br />";
$cat2 = "Select a Bar Type:<br />";
$cat3 = "Select your Entertainment:<br />";
$cat4 = "Select an Art:<br />";
$cat5 = "Select a Lodging:<br />";
$cat6 = "Select a Community:<br />";
$cat7 = "Select a Real Estate:<br />";
$cat8 = "Select a Service:<br />";

$current_category = $category_num;

if ($current_category == 1) {
echo $cat1;
}
elseif ($current_category == 2) {
echo $cat2;
}
elseif ($current_category == 3) {
echo $cat3;
}
elseif ($current_category == 4) {
echo $cat4;
}
elseif ($current_category == 5) {
echo $cat5;
}
elseif ($current_category == 6) {
echo $cat6;
}
elseif ($current_category == 7) {
echo $cat7;
}
elseif ($current_category ==  {
echo $cat8;
}

echo "<select class=\"filter\" name=subcat>\n"; 
while($sub = mysql_fetch_array( $sub_list ))
{
  echo "<option name=\"sub_category\" value=\"".$sub['id']."\">".$sub['title']."</option>\n";
}
echo "</select><input type=hidden name=category value=
$category_num />\n<br /><div align=\"right\"><input class=\"filter\" type=\"submit\" name=\"Search\" value=\"Search\" /></div>"; ?></form></p></div>
<div id="centercontent">
<div id="breadcrumb" align="right"><?php
Print "<a href=index.php class=breadcrumb>Home</a> :: ";
while ($crumb1 = mysql_fetch_array( $categorycrumb))
{
echo "<a href=client_list.php?category=$category_num class=breadcrumb>{$crumb1['title']}</a> :: ";
}
while ($crumb2 = mysql_fetch_array( $subcategorycrumb))
{
echo "{$crumb2['title']}";
} // end while
?>
</div><p><img src="images/welcome.gif" alt="Welcome" width="106" height="21" /></p>
  <p><?php
while($info = mysql_fetch_array( $data )) {
echo $info['name'], '<br />Address: ', $info['address'], '<br />Phone: ', $info['phone'], '<br /><img src=', $info['logo'], ' alt=United Bank /><br /><br />';
}
?>
<div id="map" style="width: 500px; height: 300px"></div></p>
</div></p>
</div>

<div id="searchbox" align="center"><form method="POST" action="search.php"><img src="images/spacer.gif" width="10" height="8" /><br /><input type="text" id="keyword" name="keyword" value="search" class="search" /></form></div>
<div id="rightcontent" align="center"><p>text</p></div>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.