PHP - Link Product List To Google Maps
Hi,
I am just wondering if there is any way that I can link Google Maps which will then link to my product stocklist - see attachment for what I am trying to achieve. Please let me know if this is possible. Thanks, Similar TutorialsI have an existing PHP array ($products) with various fields in it.... id / title / description / link / image link etc. etc. as per requirements for a Google Products feed (https://support.google.com/merchants/answer/7052112). My issue is that, for clothing, Google want a separate record for each size available. My array includes the "size" field as a comma separated list e.g. 6,8,10,12,14 or XS,S,M,L,XL etc. etc. So before creating the feed (a text file, which is currently outputting fine except for the size field issue) I need to duplicate each id where there's more than 1 size in that field, for each size, and then manipulate the fields a little so that (ignoring all the duplicated fields that would remain unchanged) instead of the single record : -
id size item group id I'd have 11 records, item group id would be what the id is, the size appended to the id, and the size field only one (in sequence of those from the original), so: - id size item group id
52-6 6 52 That's just one product....there are quite a lot, each with multiple sizes, but all in the same format within the $products array. As always, any help / pointers / solutions much appreciated! I'm having trouble loading this kind of KML with PHP http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#RetrievingFeatures example <atom:entry xmlns='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005'> <atom:id> http://maps.google.com/maps/feeds/features/userID/mapID/full/featureID</atom:id> <atom:published>2008-08-14T17:46:06.462Z</atom:published> <atom:updated>2008-08-14T18:12:31.589Z</atom:updated> <atom:category scheme='http://schemas.google.com/g/2005#kind' ..... it seems like the column in atom:entry, etc is causing this. $response = simplexml_load_string($response); print_r($response); the above just gives an empty SimpleXMLElement Object() Any ideas Hi guys Mods please move if this is the wrong place to ask. I have a google maps api added to my web site but i want to be able to position "pins" on the map to show all the the registered clubs in an area... eg the user searches dublin and all teh clubs pop up... My question is.. is there anyway to do this without needing the user to supply the long/lat.. ie can it be gotten automatically?? I really just want it to work off the addrees/area they supplied when they registered. thanks tt i have code that i found and modified slightly that pulls data from mysql and plots it on a google map. this works fine as is. what i want to do is change the pin colour depending on a value from mysql. the java is outside of the while loop and i can not get it to work from inside the loop. this line of code changes the pin colour var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/red.png", im crap with javascript and sorry if this is better in java forum. any help greatly appreciated Code: [Select] $dbcnx = mysql_connect ("$dbserver", "$dbuser", "$dbpass"); mysql_select_db("$dbname") or die(mysql_error()); ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Map API V3 with markers</title> <style type="text/css"> body { font: normal 10pt Helvetica, Arial; } #map { width: 700px; height: 600px; border: 0px; padding: 0px; } </style> <script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script> <script type="text/javascript"> //Sample code written by August Li var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/red.png", new google.maps.Size(32, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 32)); var center = null; var map = null; var currentPopup; var bounds = new google.maps.LatLngBounds(); function addMarker(lat, lng, info) { var pt = new google.maps.LatLng(lat, lng); bounds.extend(pt); var marker = new google.maps.Marker({ position: pt, icon: icon, map: map }); var popup = new google.maps.InfoWindow({ content: info, maxWidth: 300 }); google.maps.event.addListener(marker, "click", function() { if (currentPopup != null) { currentPopup.close(); currentPopup = null; } popup.open(map, marker); currentPopup = popup; }); google.maps.event.addListener(popup, "closeclick", function() { map.panTo(center); currentPopup = null; }); } function initMap() { map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(0, 0), zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR }, navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL } }); <?php $query = mysql_query("SELECT * FROM poi_example"); while ($row = mysql_fetch_array($query)){ $name=$row['name']; $lat=$row['lat']; $lon=$row['lon']; $desc=$row['desc']; echo ("addMarker($lat, $lon,'<b>$name</b><br/>$name');\n"); } ?> center = bounds.getCenter(); map.fitBounds(bounds); } </script> </head> <body onload="initMap()" style="margin:0px; border:0px; padding:0px;"> <div id="map"></div> </html> Hi all I am trying to get the lat and long properties from the googlemaps geocoding api. $xml=simplexml_load_file($url); if ($xml === false) { echo "Failed loading XML\n"; foreach(libxml_get_errors() as $error) { echo "\t", $error->message; } } else{ $path = $xml->xpath( "/GeocodeResponse/result/geometry/location"); $lat = $path->lat; $lng = $path->lng; echo $lat; echo $lng; $sql1 = "UPDATE tbl_clubs set lat='$lat',lng='$lng' where club_id =$id"; echo $sql1; $result1 = mysqli_query($dbConn,$sql1) or die($mysqli_error($dbConn)); } This is the XML I am using <GeocodeResponse> <status>OK</status> <result> <type>establishment</type> <type>point_of_interest</type> <type>stadium</type> <formatted_address>Aldridge Rd, Perry Barr, Birmingham B42 2ET, UK</formatted_address> <address_component> </address_component> <address_component> </address_component> <address_component> </address_component> <address_component> <long_name>West Midlands</long_name> <short_name>West Midlands</short_name> <type>administrative_area_level_2</type> <type>political</type> </address_component> <address_component> <long_name>England</long_name> <short_name>England</short_name> <type>administrative_area_level_1</type> <type>political</type> </address_component> <address_component> <long_name>United Kingdom</long_name> <short_name>GB</short_name> <type>country</type> <type>political</type> </address_component> <address_component> <long_name>B42 2ET</long_name> <short_name>B42 2ET</short_name> <type>postal_code</type> </address_component> <geometry> <location> <lat>52.5196698</lat> <lng>-1.8986236</lng> </location> <location_type>GEOMETRIC_CENTER</location_type> <viewport> <southwest> <lat>52.5183208</lat> <lng>-1.8999726</lng> </southwest> <northeast> <lat>52.5210188</lat> <lng>-1.8972746</lng> </northeast> </viewport> </geometry>
But I am getting the following response Notice: Trying to get property of non-object in /home/sites/1a/9/95f15f28a6/public_html/results/getLatLng.php on line 22 I am guessing my path is wrong, any guidance would be great Hello! I am trying to find a way to assign the JSON value Google Map's API Returns when passed an address. I would search Google, but I am only a few month deep into PHP and really don't know what keywords to use. I really don't even know what a JSON is? Anyway, I found this article that explains how to query Google Maps with an address and have it return a GPS Location. When I tested it in my browser, the text appears. I just don't know what to use to take what the browser is displaying and assign in to an Object in a PHP page. This is the Google Maps Query: Code: [Select] http://maps.google.com/maps/geo?q="ADDRESS"&output=csv&oe=utf8 This my function where I want to use this: Code: [Select] //Querries Google Map's API with an address and assigns the returned GPS Location //to this Object public function build_me($this_address) { //Builds the query from the address array to send to the Goole Maps API $query = $this_address["Line1"].",".$this_address["Line2"].",". $this_address["City"].",".$this_address["State"].",".$this_address["Zip"]; //Location_Array = http://maps.google.com/maps/geo?q=$query&output=csv&oe=utf8 $this->latitude = //Location_Array['Something']; $this->longitude = //Location_Array['Something']; } This is the article that I am referring to: http://martinsikora.com/how-to-get-gps-coordinates-from-an-address My question is, how would I go about doing this? Are there any good tutorials on this? Thanks in advance for anyone pointing me in the right direction! Hi All, I have code to generate a route in google maps on my site. The code works great in Firefox but not in IE8. It works in IE8 if you just have just a start and finish only but whe you add a waypoint in the route does not show. Any ideas? Code: [Select] <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"> </script> <script type="text/javascript"> var directionDisplay; var geocoder; var directionsService = new google.maps.DirectionsService(); var latlng = new google.maps.LatLng(54.559322587438636, -4.1748046875); function load() { geocoder = new google.maps.Geocoder(); directionsDisplay = new google.maps.DirectionsRenderer(); var myOptions = { zoom: 6, mapTypeId: google.maps.MapTypeId.ROADMAP, center: latlng, mapTypeControl: true, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, position: google.maps.ControlPosition.TOP_RIGHT }, navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.ZOOM_PAN, position: google.maps.ControlPosition.TOP_LEFT} }; var map = new google.maps.Map(document.getElementById('map'), myOptions); directionsDisplay.setMap(map); var directionRendererOptions ={ suppressMarkers: true, polylineOptions:{ strokeColor: "#FF0000", strokeOpacity: 1, strokeWeight: 3 } }; directionsDisplay.setOptions(directionRendererOptions); var start = '<?php echo $start; ?>'; var end = '<?php echo $end; ?>'; <?php if($via != null){ echo "var points = ["; foreach($via as $point){ if($point != ""){ echo "{location:"; echo " '".$point."'"; echo "},"; } } echo "];\n"; } ?> var request = { origin:start, waypoints: points, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); geocoder.geocode( { 'address': start}, function(results, status) { var routeStart = new google.maps.Marker({ map: map, position: results[0].geometry.location, icon: './images/motorcycling.png', shadow: './images/motorcycling.shadow.png' }); }); geocoder.geocode( { 'address': end}, function(results, status) { var routeEnd = new google.maps.Marker({ map: map, position: results[0].geometry.location, icon: './images/motorcyclingend.png', shadow: './images/motorcycling.shadow.png' }); }); <?php $adverts = mysql_query("SELECT * FROM adverts WHERE ad_area = '$county' AND ad_visible='1' "); while($ad_row = mysql_fetch_array($adverts)){ $position = $ad_row[ad_postcode]; $type = $ad_row[ad_type]; echo "var position".$ad_row[ad_id]." = '".$position."'\n"; $ad_id = $ad_row[ad_id]; $pics = mysql_query("SELECT * FROM photos WHERE ad_id = '$ad_id' AND main_pic = '1'"); $pic_row = mysql_fetch_array($pics); $pic_name = $pic_row[photo_name]; $pic_name = str_replace(' ', '%20', $pic_name); ?> geocoder.geocode( { 'address': position<?php echo $ad_row[ad_id]; ?>}, function(results, status) { var marker<?php echo $ad_row[ad_id]; ?> = new google.maps.Marker({ map: map, position: results[0].geometry.location, <?php if ($type == 'accommodation'){ echo "icon: 'images/hotel.png'\n"; }elseif($type == 'fooddrink'){ echo "icon: 'images/bar.png'\n"; }elseif($type == 'essentials'){ echo "icon: 'images/motorcycle.png'\n"; } ?> }); var content = "<p><\a style='color:black;' href='./advert.php?advert=<?php echo $ad_row[ad_id]; ?>'><?php echo $ad_row[ad_company]; ?><\/a></p><img src='./thumbs/<?php echo $pic_name; ?>' />"; var infowindow<?php echo $ad_row[ad_id]; ?> = new google.maps.InfoWindow({ content: content }); google.maps.event.addListener(marker<?php echo $ad_row[ad_id]; ?>, "click", function() { infowindow<?php echo $ad_row[ad_id]; ?>.open(map,marker<?php echo $ad_row[ad_id]; ?>); }); }); I am attempting to create a Map on my web page that will have the directions (which will be dynamically pulled from a database) however I have been unable to find a good tutorial on how to achieve this, also there doesn't seem to be any PHP classes available out there (for free anyway) to create this easily. Any suggestions? Need help with this, has anyone does this before? Here is the tutorial I have been following: https://developers.google.com/maps/articles/phpsqlajax#outputxml The part I am on from the tutorial is where it says Checking that XML output works it is meant to display the data from the database but i just get a blank page, no data is shown from my database on the page? I just have a php file with the code from the tutorial. Hello, I've created a page search to return results from my database inventory. On top of these results I would like to display a seperate list of five products not included in the search results but share the same sub_category_b (a column in my SQL table). Posted below is my primary query of the database. If anyone can help me out with this it would be appreciated. Code: [Select] $colname_product = "-1"; if (isset($_GET['title'])) { $colname_product = $_GET['title']; } mysql_select_db($database_inventory, $inventory); $query_product = sprintf("SELECT * FROM inventory WHERE item_name LIKE %s OR item_desc LIKE %s ", GetSQLValueString("%" . $colname_product . "%", "text"),GetSQLValueString("%" . $colname_product . "%", "text")); $product = mysql_query($query_product, $inventory) or die(mysql_error()); $row_product = mysql_fetch_assoc($product); I've fooled around with this one for some time and haven't come up with a clear cut answer. Thank you in advance! Hi there i have a big issues which is starting to cause me lots of stress. I have two tables one which is products and contains the following below and the other which is additionalCategories which the contains is also below. products id name image1 image2 image3 image4 image5 description department category subcategory Price additonalCategories id departmentID categoryID subcategoryID productID i have made a products upload script to my site where i can add products too it saves the category and subcategory id's in the fields above then if i wish to add the product to additional categories i do so and again this adds all the data to the addiotnalCategories table. however i can seems to be able to display this on the view products page i tried the below code but get no luck Code: [Select] <?php session_start(); $username=$_SESSION['username']; include_once"../includes/db_connect.php"; $cat=$_GET['cat']; ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $query("SELECT products.name AS name, products.price AS price, addtionalCategories.productID AS productID FROM products, addtionalCategories WHERE category='$cat' AND products.id = addtionalCategories.productID"); while($fetch=mysql_fetch_object($query)){ echo"$fetch->name"; } ?> </body> </html> i need a way in which on the page it check the category id then finds all the products that are saved in the additionalCategories table then to find the data saved in the products table such as the name and price etc please any help will be appreciated thank you for reading Hello all, I am a relative newbie, and have been recently trying to get to grips with the Google Maps v3 API. I'm hoping someone here will be kind enough to take pity and help me with some difficulty I am having. First, let me set the scene. I'm helping a friend develop a website for a hobby. It's a simple, PHP / MySQL based site which lists different establishments. There is a database of companies, which includes a name, address, long lats, etc. I have managed to write the SQL query to poll the database, and return a list of markers on a map of London: http://datanalyst.co.uk/dev/flmap/mapexample7a.php However, I am getting confused regarding the markers, it would seem like my code (which can be found below) is iterating through all of the companies, and then setting just one marker for all points? The code can be found at http://paste.bradleygill.com/index.php?paste_id=348277 I am hoping you can see what I'm doing here. The PHP script is printing HTML / JavaScript code to the page, which includes a foreach loop, which grabs the long lats and puts them into google.maps.LatLng I am just just struggling with the markers - and I cannot see where I've gone wrong! Thanks so much in advance for any help you can provide me! All the best, and Merry Christmas, Michael I'm not a new comer to web design, but to date all of my experience has been in content management based systems (Joomla, Wordpress etc...) I was recently approached by a client to add a page to his existing website and after some research I think that using Google Maps API would be the easiest way to implement what he needs. Basically he wants to have a map of the USA with an icon for each of his office locations. (There are about 70 across the states) Once clicked on, each of the locations will pop up with all the info for that office, and if there are any job openings there. I would like for it to be all in one page, dynamically changing as the user manipulates the map. I found the perfect example for this at ZipCar.com http://www.zipcar.com/nyc/find-cars Everything fits within one simple page, the user can zoom in and out, and all the pertinent information shows up with along the side without anything reloading. I was basically hoping someone could point me in the right direction as to the steps that would be needed to get this done. I don't want someone to hold my hand through the whole process, I'm just fairly new to PHP and HTML and wondering what all will be involved with completing a project like this. Consider my first born child yours for the person who can help me out with this... Hi there, So the below code is working for 1 entry, however there is 2 entries in the database which are different postcodes and I cannot get to show in Google Maps. When I do it without Mysql and just do it direct it works, but really want to do it from MYSQL - both postcodes are valid and tested as well.
<?php $sql4 = "SELECT * FROM MK_migration_details"; $result4 = $conn->query($sql4); ?> function initialize() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(40.768505,-111.853244); var myOptions = { mapTypeControl: false, fullscreenControlOptions: false, zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); <?php while($row4 = $result4->fetch_assoc()) { $mig_postcode = $row4["postcode"]; } echo 'addPostCode("'.$mig_postcode.'")'; ?> } I know the issue lies with the PHP / Mysql Loop and the Javascript element 'addpostcode' when I put into the loop does not work, but works for a single address outside the loop.
Really appreciate your help guys!
Thanks you I finally got my kml to display through the static maps api thinking I could then display my map on the pdf I'm generating using mpdf. But, it is not displaying the image in the pdf. It works fine on a blank test page.
$kmlMap = "<img src=\"http://maps.googleapis.com/maps/api/staticmap?zoom=15&size=500x300&maptype=hybrid&path=color:0xff0000ff|weight:3|$correctedCoords \" /><br />";Any ideas on how I could make this work with mpdf? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=328756.0 Hi, I currently have a google map which shows a marker where the postcode is for a certain pub (converts postcodes to coords lat/long) I would like to loop through all my pubs in my database as place a marker for each on one map, I am uncertain of how to loop through and show each marker for each postcode either PHP or JavaScript. here is my code for a single pub / postcode: Code: [Select] <!doctype html> <?php include "../config.php"; $loggedIn = (isset($_COOKIE['loggedin']) && $_COOKIE['loggedin'] == 'true')?true:false; $PUBID = intval($_REQUEST['PUBID']); $PUB = mysql_query("SELECT * FROM pubs WHERE PUBID = '".$PUBID."'"); $pubdetails = mysql_fetch_array($PUB); ?> <html> <head> <meta charset="UTF-8" /> <title><?php echo $pubdetails['rsPubName']; ?>, <?php echo $pubdetails['rsTown']; ?>, <?php echo $pubdetails['rsCounty']; ?></title> <style type="text/css" media="screen">@import "jqtouch/jqtouch.min.css";</style> <style type="text/css" media="screen">@import "themes/jqt/theme.min.css";</style> <script src="jqtouch/jquery.1.3.2.min.js" type="text/javascript" charset="utf-8"></script> <script src="jqtouch/jqtouch.min.js" type="application/x-javascript" charset="utf-8"></script> <script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAAAM17e4xGXwO4sBd_QYtRiSRQXB4T7UHWaz4zUQgLx9muJZW0c3hS8jRMJg733CHqOihn7BVfhZTkLiA" type="text/javascript"></script> <script type="text/javascript"> function initialize() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.G_NORMAL_MAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } </script> <script type="text/javascript" charset="utf-8"> var jQT = new $.jQTouch({ icon: 'jqtouch.png', addGlossToIcon: false, startupScreen: 'jqt_startup.png', statusBar: 'black', preloadImages: [ 'themes/jqt/img/back_button.png', 'themes/jqt/img/back_button_clicked.png', 'themes/jqt/img/button_clicked.png', 'themes/jqt/img/grayButton.png', 'themes/jqt/img/whiteButton.png', 'themes/jqt/img/loading.gif' ] }); </script> </head> <body onLoad="ukPostcodeTest(); return false"> <!-- TOWNS --> <div id="pub" class="current"> <div class="toolbar"> <h1>View Pub</h1> <a class="back" href="index.php" rel="external">Home</a> </div> <h2><?php echo $pubdetails['rsPubName']; ?></h2> <?php echo $pubdetails['rsAddress']; ?><br /> <?php echo $pubdetails['rsTown']; ?><br /> <?php echo $pubdetails['rsCounty']; ?><br /> <?php echo $pubdetails['rsPostCode']; ?><br /> <?php echo $pubdetails['Region']; ?><br /> <?php echo $pubdetails['rsTel']; ?><br /> <?php echo '<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.mypubspace.com/pub_info.php?PUBID='.$pubdetails['PUBID'].'&layout=box_count&show_faces=true&width=450&action=like&colorscheme=light&height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:60px; height:65px; float:right;" allowTransparency="true"></iframe>';?> <div id="map" style="width: 250px; height: 250px"></div> <form name="mapform" onsubmit="ukPostcodeTest(); return false" action="#"> <input id="search" type="hidden" value="<?php echo $pubdetails["rsPostCode"]; ?>" /> </form> <div id="message"></div> <noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b> However, it seems JavaScript is either disabled or not supported by your browser. To view Google Maps, enable JavaScript by changing your browser options, and then try again. </noscript> <script type="text/javascript"> //<![CDATA[ if (GBrowserIsCompatible()) { var map = new GMap(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(51.520593197675446,-0.19775390625),16); // ====== Is the search string a UK Postcode ====== function ukPostcodeTest() { var search = document.getElementById("search").value; // take a copy and convert to upper case var s = search.toUpperCase(); // Replace punctuation and whitepsace by a single space s = s.replace(/\W+/g, " "); // Remove and trailing leading spaces s = s.replace(/^ /, ""); s = s.replace(/ $/, ""); // Perform the check var match = s.match(/^[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}$/); if (!match) { // Its not a UK Postcode, so perform a standard GClientGeocoder call on the original search string showAddress(search); } else { // It is a UK Postcode, so call GDirections on the reformatted search string showPostcode(s); } } // ====== Code for handling search strings that are not UK Postcodes ======= // ====== Use the GClientGeocoder in the normal way ====== // ====== Create a Client Geocoder ====== var geo = new GClientGeocoder(); // ====== Array for decoding the failure codes ====== var reasons=[]; reasons[G_GEO_SUCCESS] = "Success"; reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value."; reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address: No corresponding geographic location could be found for the specified address."; reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address: The geocode for the given address cannot be returned due to legal or contractual reasons."; reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given"; reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded."; reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed."; // ====== Geocoding ====== function showAddress(search) { // ====== Perform the Geocoding ====== geo.getLocations(search, function (result) { // If that was successful if (result.Status.code == G_GEO_SUCCESS) { // How many resuts were found document.getElementById("message").innerHTML = "Found " +result.Placemark.length +" results"; // Loop through the results, placing markers for (var i=0; i<result.Placemark.length; i++) { var p = result.Placemark[i].Point.coordinates; var marker = new GMarker(new GLatLng(p[1],p[0])); document.getElementById("message").innerHTML += "<br>"+(i+1)+": "+ result.Placemark[i].address + marker.getPoint(); map.addOverlay(marker); } // centre the map on the first result var p = result.Placemark[0].Point.coordinates; map.setCenter(new GLatLng(p[1],p[0]),14); } // ====== Decode the error status ====== else { var reason="Code "+result.Status.code; if (reasons[result.Status.code]) { reason = reasons[result.Status.code] } alert('Could not find "'+search+ '" ' + reason); } } ); } // ====== Create a Client Geocoder ====== var gdir = new GDirections(null); // ====== Using GDirections to process a UK postcode ====== function showPostcode(search) { // Call GDirections gdir.loadFromWaypoints([search,search],{getPolyline:true}); // Wait for the reply to come back GEvent.addListener(gdir,"load", function() { var poly = gdir.getPolyline(); var point = poly.getVertex(0); //document.getElementById("message").innerHTML = "Found a UK Postcode"; // Process the result var marker = new GMarker(point); //document.getElementById("message").innerHTML += "<br>" + search + " = " + point.toUrlValue(5); map.addOverlay(marker); // centre the map on the result map.setCenter(point,16); }); } } // display a warning if the browser was not compatible else { alert("Sorry, the Google Maps API is not compatible with this browser"); } // This Javascript is based on code provided by the // Community Church Javascript Team // http://www.bisphamchurch.org.uk/ // http://econym.org.uk/gmap/ //]]> </script> </div> </body> </html> I am trying to use Google's map API to dynamically create new maps. For example, I would like to be able to make a replica of this page using PHP. I just don't see where in the API it allows you to add all this information, such as adding categories, details, pictures, videos, etc. I've been researching for quite a while, and can't seem to come up with something that is similar to what I'm trying to do. Here is a link I found that shows you how to create maps, but I still don't see how to add all the information that you could if you did it manually! http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#CreatingMaps It would be great if someone can point me in the right direction. Thanks! I had bought a script from he php google maps and have been using the attached php script. It was working and than apparently stopped working with this error "602: Unable to Geocode this address" Can anyone tell me if there is another solution? Or if I can use another method besides $gmap->showLocation($cross,$town,$county$state); Thanks! Code: [Select] <?php require_once('gmap.php'); $gmap = new GMap(); $cross = $result['cross_streets']; $county = $result['county']; $town = $result['town']; $state = 'New York'; $gmap->showLocation($cross,$town,$county$state); ?> |