JavaScript - Multiple Google Maps On One Page With Advanced Directions
Hello,
I am trying to create multiple google maps with multiple directions that load on one page. I have tried duplicating the var and function names but I haven't been able to get it to work. Does anyone have any ideas? Any help or suggestions would be greatly appreciated! -Topianno 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" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Maps JavaScript API Example: Advanced Directions</title> <script src=" http://maps.google.com/?file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></script> <style type="text/css"> body { font-family: Verdana, Arial, sans serif; font-size: 11px; margin: 2px; } table.directions th { background-color:#EEEEEE; } img { color: #000000; } </style> <script type="text/javascript"> var map; var map2; var gdir; var gdir2; var geocoder = null; var geocoder2 = null; var addressMarker; var addressMarker2; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); gdir = new GDirections(map, document.getElementById("directions")); GEvent.addListener(gdir, "load", onGDirectionsLoad); GEvent.addListener(gdir, "error", handleErrors); setDirections("San Francisco", "Mountain View", "en_US"); setDirections2("San Francisco", "Mountain View", "en_US"); } } function setDirections(fromAddress, toAddress, locale) { gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale }); } function handleErrors(){ if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code); // else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong // alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_KEY) alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code); else alert("An unknown error occurred."); } function onGDirectionsLoad(){ // Use this function to access information about the latest load() // results. // e.g. // document.getElementById("getStatus").innerHTML = gdir.getStatus().code; // and yada yada yada... } </script> </head> <body onload="initialize()" onunload="GUnload()"> <h2>Maps API Directions Illustrated</h2> <form action="#" onsubmit="setDirections(this.from.value, this.to.value, this.locale.value); return false"> <table> <tr><th align="right">From: </th> <td><input type="text" size="25" id="fromAddress" name="from" value="San Francisco"/></td> <th align="right"> To: </th> <td align="right"><input type="text" size="25" id="toAddress" name="to" value="Mountain View" /></td></tr> <tr><th>Language: </th> <td colspan="3"><select id="locale" name="locale"> <option value="en" selected>English</option> <option value="fr">French</option> <option value="de">German</option> <option value="ja">Japanese</option> <option value="es">Spanish</option> </select> <input name="submit" type="submit" value="Get Directions!" /> </td></tr> </table> </form> <br/> <table class="directions"> <tr><th>Formatted Directions</th><th>Map</th></tr> <tr> <td valign="top"><div id="directions" style="width: 275px"></div></td> <td valign="top"><div id="map_canvas" style="width: 310px; height: 400px"></div></td> </tr> </table> <h2>Maps API Directions Illustrated 2nd Map</h2> <form action="#" onsubmit="setDirections2(this.from.value, this.to.value, this.locale.value); return false"> <table> <tr><th align="right">From: </th> <td><input type="text" size="25" id="fromAddress2" name="from" value="San Francisco"/></td> <th align="right"> To: </th> <td align="right"><input type="text" size="25" id="toAddress2" name="to" value="Mountain View" /></td></tr> <tr><th>Language: </th> <td colspan="3"><select id="locale" name="locale2"> <option value="en" selected>English</option> <option value="fr">French</option> <option value="de">German</option> <option value="ja">Japanese</option> <option value="es">Spanish</option> </select> <input name="submit" type="submit" value="Get Directions!" /> </td></tr> </table> </form> <br/> <table class="directions"> <tr><th>Formatted Directions</th><th>Map</th></tr> <tr> <td valign="top"><div id="directions" style="width: 275px"></div></td> <td valign="top"><div id="map_canvas" style="width: 310px; height: 400px"></div></td> </tr> </table> </body> </html> Similar TutorialsHi coding world! I am having some serious issues with getting multiple sets of coordinates to appear on google maps on my website. I have many items stored in a database, and each row has a field for latitude and a field for longitude. I get the data like this: PHP Code: $getdeals = "SELECT * FROM deals WHERE cityid='$cityid'"; $result = mysql_query($getdeals); while($row = mysql_fetch_array($result)){ $title = $row['title']; $lat = $row['lat']; $lng = $row['lng']; //THIS IS WHERE I THINK I WOULD TRY TO ADD THE POINT TO THE MAP } If anybody could steer me in the right direction that would be amazing!! Thanks! Hi, I'm not sure where I have translated this incorrectly. I have one google map embedded on my page which works fine. But I wanted to add a second one. I thought the easiest way to do this would be to have a second page which is called later on with all the details on it for the second map. However although I think (this I presume is where I went wrong) I have replicated the instructions correctly the place holder for the second map just remains blank. This is the code for my called page with the instructions for the second map: PHP Code: <?php echo $_POST['Map'] . '<br />'; ?> <div id="placemap_canvas"></div> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #placemap_canvas {width:100%; height:150px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM regions WHERE RegionPId='{$_POST['Map']}'"); while($row = mysql_fetch_array($result)){ echo $row['maplink']; } mysql_close($con); ?> ); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("placemap_canvas"), myOptions); } </script> And this is the script of the main page, just in case I would be better off keeping them both in one place. Code: <head> <script type="text/javascript"> function loadSubPlace(File,ID,Msg,Eile,EID,Esg){ loadXMLDoc1(File,ID,Msg); var mimer = setTimeout(function(){loadXMLDoc1(Eile,EID,Esg)},5000); } </script> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #map_canvas {width:30%; height:250px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> function initialize() { var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM countries WHERE Country='{$_SESSION['Country']}'"); while($row = mysql_fetch_array($result)){ echo $row['Map']; } mysql_close($con); ?>); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } </script> </head> <body onload="initialize()"> <div class="countryright" id="map_canvas"> include("dbconnect.php"); $snowball=explode(';',$_POST['syringa']); $turnsol=$snowball[1]; $violet =$snowball[2]; $wakerobin=$snowball[3]; global $turnsol; global $violet; global $wakerobin; echo '<center><b><big>' . $wakerobin. '</big></b></center><br /><br />'; $result=mysql_query("SELECT * FROM regions WHERE country='{$turnsol}' AND region='{$violet}' AND place='{$wakerobin}' AND sub !='' ORDER BY sub ASC"); while($row = mysql_fetch_array($result)){ $wheat="{$row['RegionPId']};{$turnsol};{$violet};{$wakerobin};{$row['sub']}"; $tigerlilly=$row['RegionPId']; echo '<input type="button" class="button3" name="place" id="place" value="' . $row['sub'] . '" onclick="loadSubPlace(\'getPlace.php\',\'txtHintPlaceSub\',\'hepatica=' . urlencode($wheat) . '\',\'getPlaceMap.php\',\'placemapcanvas\',\'Map=' . urlencode($tigerlilly) . '\');" />'; } echo '<input type="button" class="button3" name="addplace" id="addplace" value="Add Place" onclick="loadXMLDoc1(\'getAddPlaceSub.php\',\'txtHintPlaceSub\', encodeURI(\'addsubplace=' . $_POST['syringa'] . '\'));" />'; echo '<br /><br /><div id="txtHintPlaceSub"></div><br /><br />'; mysql_close($con); ?> I've cut out the script that doesn't relate to this so I hope I haven't missed anything important. Hi guys. I have posted about this before on here but I'm still having a lot of issues. MY GOAL - I have a database with a bunch of items and each has latitude, longitude and a category (all the items are within 1 city). I want to have a page that will show a google map, display a marker based on the lat/lng and the image of the marker should be customized based on the category of the row. For example, some rows have a 'food' category and some have a 'health' category - I have specific images I want displayed for each image. I need a script that will plot a marker for each item in my db. I have never used Google maps API before and I'm thinking V3 is what I need to use. Can someone help fill in the code below? PHP Code: $query=mysql_query("SELECT * FROM table"); while($row=mysql_fetch_array($query)){ $lat=$row['lat']; $lng=$row['lng']; $category=$row['category']; //SET MARKER PICTURE TO $category //ADD MARKER TO MAP } Can anybody help out with the code? I don't know javascript that well and I have tried about 40 different things and get nothing but a blank page! THANK YOU SO MUCH Hi, I have a table with FROM and TO columns and a column with MAP/DIRECTIONS link. When a user clicks on the link, it should display Map and Directions on the iframe on the same page. How can I achieve this using Google map and directions API? Thanks Hi everyone, I'm putting together a family tree type organization chart and looking to be able to drag it around to view different parts similar to google maps. I believe javascript is the way to handle this but need some help pointing me in the right direction. Any help would be greatly appreciated. Thanks, Mike Hi: I'm new to this forum and JS. I simply want to be able to use the Google Maps API v3 to allow a location value entered in my app (by the user) to show that location via Google maps. The code below accomplishes this via an onClick event. How to accomplish the same WITHOUT an onClick? To be clear, it appears I need to be able to perform the geocode lookup to get the long/lat coordinates and then apply them. That all needs to occur on page load. Any tips on how to re-arrange this code to accomplish the desire goal are appreciated. Thanks much. Bill Code: <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var geocoder; var map; function initialize() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } function codeAddress() { var address = document.getElementById("address").value; geocoder.geocode( { address: address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK && results.length) { // You should always check that a result was returned, as it is // possible to return an empty results object. if (status != google.maps.GeocoderStatus.ZERO_RESULTS) { map.set_center(results[0].geometry.location); var marker = new google.maps.Marker({ position: results[0].geometry.location, map: map }); } } else { alert("Geocode was unsuccessful due to: " + status); } }); } </script> </head> <body onload="initialize()"> <div id="map_canvas" style="width: 100%; height: 100%;"></div> <div> <input id="address" type="hidden" value="Chicago"> <input type="button" value="Geocode It!" onClick="codeAddress()"> </div> </body> Hi all , I need some help in altering the location tag and the View Larger Map links to open in a new window, currently it opens in the same window. I didn't set any links myself, they were already in the code that I got from Google Maps, I placed it on my page as a custom script. I tried to edit it myself and other frames on my page got all muddle up in preview !!!!! _THE CODE_ <iframe width="350" height="280" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&ll=37.109574,-8.030563&spn=0.011328,0.022724&t=h&z=16&output=embed"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&ll=37.109574,-8.030563&spn=0.011328,0.022724&t=h&z=16&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small> I'm still kinda new at this. Please bear with me..I'm trying to make all imgs move in different directions using the following code. I was givin the code and I need to insert something into it so this will work. I just can't understand it and WANT to ..driving me NUTTY. Code: <!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> <title>BUZZ</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> var widthMax = 0; var heightMax = 0; var buzzSpeed = new Array(3); buzzSpeed[0] = 10; var xPosition = new Array(3); xPosition = -20; var yPosition = new Array(3); yPosition[0] = 0; var xDirection = new Array(3); xDirection[0] = "right"; var yDirection = new Array(3); yDirection[0] = "down"; function setBug(newStartPoint) { widthMax = document.documentElement.clientWidth; heightMax = document.documentElement.clientHeight; setInterval("flyBug(0)", 30); } function flyBug(curBug) { var activeBug = document.getElementById("bugImage" + curBug); var activeElement = document.getElementById("bugElement" + curBug); if (xDirection[curBug] == "right" && xPosition[curBug] > (widthMax - activeBug.width - buzzSpeed[curBug])) xDirection[curBug] = "left"; else if (xDirection[curBug] == "left" && xPosition[curBug] <= 0) xDirection[curBug] = "right"; if (yDirection[curBug] == "down" && yPosition[curBug] > (heightMax - activeBug.height - buzzSpeed[curBug])) yDirection[curBug] = "up"; else if (yDirection[curBug] == "up" && yPosition[curBug] <= 0) yDirection[curBug] = "down"; if (xDirection[curBug] == "right") xPosition[curBug] = xPosition[curBug] + buzzSpeed[curBug]; else if (xDirection[curBug] == "left") xPosition[curBug] = xPosition[curBug] - buzzSpeed[curBug]; else xPosition[curBug] = xPosition[curBug]; if (yDirection[curBug] == "down") yPosition[curBug] = yPosition[curBug] + buzzSpeed[curBug]; else if (yDirection[curBug] == "up") yPosition[curBug] = yPosition[curBug] - buzzSpeed[curBug]; else yPosition[curBug] = yPosition[curBug]; activeElement.style.left = xPosition[curBug] + document.documentElement.scrollLeft + "px"; activeElement.style.top = yPosition[curBug] + document.documentElement.scrollTop + "px"; } window.onresize = setBug; </script> </head> <body onload="setBug()"> <div id="bugElement0" style="position:absolute; left:20px; top:0px;"> <img id="bugImage0" src="bug.jpg" alt="buggy" height="48" width="48" /></div> <div id="bugElement1" style="position:absolute; left:25%; top:75%;"> <img id="bugImage1" src="bug.jpg" alt="buggy1" height="48" width="48" /></div> <div id="bugElement2" style="position:absolute; left:40%; top:48%;"> <img id="bugImage2" src="bug.jpg" alt="buggy2" height="48" width="48" /></div> <div id="bugElement3" style="position:absolute; left:58%; top:58%;"> <img id="bugImage3" src="bug.jpg" alt="buggy3" height="48" width="48" /></div> <div id="bugElement4" style="position:absolute; left:90%; top:75%;"> <img id="bugImage4" src="bug.jpg" alt="buggy4" height="48" width="48" /></div> </body> </html> I have some problems with intergrating google maps into my page I cant seem to get a marker to appear on my map. I have tried numerous methods but non seem to work. I have integrated the google maps on my main site, repositioned and re-sized. The code below is a test page i work on to get code to work. It's just a map on a page entire code: <!DOCTYPE HTML> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height: 100%; margin: 25px; padding: 25px } #map_canvas { height: 100% } </style> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDrxZnpYBNIwzBFVYaDY__BMONEjNEGZaI&sensor=false"> </script> <script type="text/javascript"> function initialize() { var myLatlng = new google.maps.LatLng(-25.363882,131.044922); var myOptions = { zoom: 4, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);} var marker = new google.maps.Marker({ position: myLatlng, map: map, title:"Hello World!" }); </script> </head> <body onload="initialize()"> <div id="map_canvas" style="width:100%; height:100%"></div> </body> </html> can anybody tell my where i am going wrong and just the map appears with no marker? thanks Hey all I'm quite a newbie at javascript and I'm trying to have links to google maps markers. I have a page with my embeded google maps on it and some markers. What I'm basically looking to do is have a web page with a menu down the side and when you click the menu items, the google maps markers would pop up on the map. For example, city attractions down a side menu and when you click say restaurants, the markers would pop up the location restaurants in a certain place, then you could click pubs and the restaurant markers would dissapear and the pub markers would appear. Can anyboy help me with this or even direct me to some code that would help. Thanks all. Hey I'm quite new at javascript and am currently in the process of creating a site that embeds google maps using an xml document. What I'm trying to do is categories the markers on my map. I am trying to make it so there are check boxes at the bottom and when i check the boxes, i.e. theatres, the markers will appear for the theatres and disappear when unchecked. Using some example code i have modified, i have so far got the maps to pickup the markers from the xml with the check boxes but the markers are all just on the page and the check boxes dont do anything and I am stuck as to of why. here's my code: Code: <!DOCTYPE HTML> <html> <head> <title>Google Maps</title> <script src="mykey"></script> </head> <body style="margin:0px; padding:0px;" onload="initialize()"> <table border=1> <tr> <td> <div id="map" style="width: 550px; height: 450px"></div> </td> <td valign="top" style="width:150px; text-decoration: underline; color: #4444ff;"> <div id="side_bar"></div> </td> </tr> </table> <form action="#"> Theatres: <input type="checkbox" id="theatrebox" onclick="boxclick(this,'theatre')" /> Golf Courses: <input type="checkbox" id="golfbox" onclick="boxclick(this,'golf')" /> Tourist Information: <input type="checkbox" id="infobox" onclick="boxclick(this,'info')" /><br /> </form> <script type="text/javascript"> _uacct = "UA-162157-1"; urchinTracker(); </script> </body> <script type="text/javascript"> //<![CDATA[ if (GBrowserIsCompatible()) { var side_bar_html = ""; var gmarkers = []; var map = null; function createMarker(point,name,html,category) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); marker.mycategory = category; marker.myname = name; gmarkers.push(marker); side_bar_html += '<a href="javascript<b></b>:myclick(' + (gmarkers.length-1) + ')">' + name + '<\/a><br>'; return marker; } function show(category) { for (var i=0; i<gmarkers.length; i++) { if (gmarkers[i].mycategory == category) { gmarkers[i].setVisible(true); } } document.getElementById(category+"box").checked = true; } ensures the checkbox is cleared == function hide(category) { for (var i=0; i<gmarkers.length; i++) { if (gmarkers[i].mycategory == category) { gmarkers[i].setVisible(false); } } document.getElementById(category+"box").checked = false; that we just hid infowindow.close(); } function boxclick(box,category) { if (box.checked) { show(category); } else { hide(category); } makeSidebar(); } function myclick(i) { google.maps.event.trigger(gmarkers[i],"click"); } var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng( 53.8363,-3.03771), 11); GDownloadUrl("categories.xml", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new google.maps.LatLng(lat,lng); var address = markers[i].getAttribute("address"); var name = markers[i].getAttribute("name"); var html = "<b>"+name+"<\/b><p>"+address; var category = markers[i].getAttribute("category"); // create the marker var marker = createMarker(point,name,html,category); map.addOverlay(marker); } document.getElementById("side_bar").innerHTML = side_bar_html; show("theatre"); hide("golf"); hide("info"); }); } else { alert("Sorry, the Google Maps API is not compatible with this browser"); } </script> </body> </html> If anybody help with this and tell me where I am going wrong, it would be much appreciated. thanks Hi I have just started looking at the Google maps, and have atutorial that will get the co-ordinates. What I want this to do, is then populate two fields on a form one called longitude and one called latitude Code: function usePointFromPostcode(postcode, callbackFunction) { localSearch.setSearchCompleteCallback(null, function() { if (localSearch.results[0]) { var resultLat = localSearch.results[0].lat; var resultLng = localSearch.results[0].lng; var point = new GLatLng(resultLat,resultLng); callbackFunction(point); }else{ alert("Postcode not found!"); } }); localSearch.execute(postcode + ", UK"); } Any ideas/tips would be be much appreciated I am using jMapping(http://vigetlabs.github.com/jmapping/) for using jQuery with google maps. What I'm trying to do is add an event listener so that when you click on a marker it will call a function I made within the jMapping function. Does anyone have any clues? everything I've tried doesn't work.
I'm completely at a loss how to embed a map with the new google maps api setup. I found a snippet of code that I dropped in with some small database variables pulled in and was done. Then an error came that the API was no good. So I went in and set up an anaccount, got an api and now I just simply have no clue what their instructions are saying I need to do. Gah! Here's what I originally had: I now have a Client ID, client secret and stuff. But no clue how to set up this url, etc. Code: </script> <script src="//maps.google.com/maps?file=api&v=2&key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI" type="text/javascript"></script> <script type="text/javascript"> function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(<?php echo $c_row['location_longitude']; ?>,<?php echo $c_row['location_latitude']; ?>), 13); // Add the latitude/longitude marker to the map var point = new GLatLng(<?php echo $c_row['location_longitude']; ?>,<?php echo $c_row['location_latitude']; ?>); map.addOverlay(new GMarker(point)); map.setUIToDefault(); } } </script> <b>Map:<br><br><div id="map_canvas" style="width: 500px; height: 300px; z-index:4000;border-width:medium;border-color:#030;"></div></b> My google maps is showing a grey box and no map?! Please help me, I got my code from he http://www.powerhut.co.uk/googlemaps/custom_markers.php and uploaded everything to the right place but it's just grey?! http://79.170.40.235/affordableappli...uk/contact.php I have a google static map which I spent ages trying to work out what to put in it and now it will not work, or be valid, so I am doing something wrong? Can anyone help Have I set it out the right way, I know it is static but it is still JS I believe. Code: <p><img alt="google_static_map" src="http://maps.google.com/maps/api/staticmap?center=51.454863,0.011673&zoom=13&markers=United+Reformed+Church,+111+Burnt+Ash+Road,++Lee,+London+SE12+8RG,+UK&size=250x250&sensor=TRUE /></a></p> DO I need to put in it a div? I cant do iframes. My editor does not like it at all and it is not showing on the website. I am using XHTML Hello i have a problem i need to resolve here is the script Code: script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></script> <script type="text/javascript"> var map = null; var geocoder = null; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); geocoder = new GClientGeocoder(); } } function showAddress(address) { if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(address); } } ); } } </script> </head> <body onload="initialize()" onunload="GUnload()"> <form action="#" onsubmit="showAddress(this.address.value); return false"> <p> <input type="text" size="60" name="address" value="1600 Amphitheatre Pky, Mountain View, CA" /> <input type="submit" value="Go!" /> </p> <div id="map_canvas" style="width: 500px; height: 300px"></div> </form> </body> its all working well but i need to use it differently. Is there a way to make the form submit automatically , i already have the address and i will <php> it from my database. i want that the map will show in the page as soon as the user clicked on an ad(real estate ad). Basically what we need here is: To know how to call the functions and give the address from the database. <body onload="initialize()" onunload="GUnload()"> <form action="#" onsubmit="showAddress(this.address.value); return false"> <p> <input type="text" size="60" name="address" value="1600 Amphitheatre Pky, Mountain View, CA" /> <input type="submit" value="Go!" /> </p> <div id="map_canvas" style="width: 500px; height: 300px"></div> </form> </body> Is there a way just to use this command without the form onsubmit="showAddress(this.address.value); return false">? And give the address as a variable ? and when the page is uploading it will have already passed the address and the map will show Danny Hi, Not sure how difficult this will be but im working on a javascript/HTML5 game, and thought it would be interesting to allow for people to add their score to a google map at their location. I can get the google map and allow people to add their own markers but i dont no how i would store them, and then reload them when someone plays the game. any ideas? Thanks, Luke hello all, what i would like to implement is the following : http://mon.grnet.gr/network/maps/lite/?load&ip but, the problem is that, although the numerical data that show the traffic volume passing through a link are available to me, i do not have clue on how i can display them onto the map ... ? i would be thankful, if you could give me a piece of advice. |