JavaScript - I Want To Draw Vector Paths On The The Google Map With Javascript
i want to draw vector paths on the the google map on my site that I want to add moving vehicles on the roads and i want to zoom the map
when the cars going somewhere. Can I do it? I do not want to take a screenshot of the google map adress. here is my javascript codes.Do you have an idea about google map zooming with animations? var options = { controls: { panControl: true, zoomControl: true, mapTypeControl: true, scaleControl: true, streetViewControl: true, overviewMapControl: true }, scrollwheel: true, maptype: 'TERRAIN', markers: [ { latitude: -2.2014, longitude: -80.9763, }, { address: "Guayaquil, Ecuador", html: "My Hometown", icon: { image: "images/gmap_pin_grey.png", iconsize: [26, 46], iconanchor: [12,46] } } ], icon: { image: "http://www.mobilyala.com/mapfiles/marker.png", iconsize: [37, 34], shadowsize: [37, 34], iconanchor: [9, 34], shadowanchor: [19, 34] }, latitude: -2.282, longitude: -80.272, zoom: 10 } Similar TutorialsJust wondering if anyone can help. Basically I'm trying to create a 'favourites' draw, much like the one he http://www.stellamccartney.com/default/shop-products/collections/looks/spring2012#!{"scrollableid":"coll_sp12rtw_01"} The idea is that people visiting the site will be able to bookmark products from an image gallery and then from anywhere else on the site, open the 'favourites' bar at the bottom and visit the individual products they have chosen in a store. Hope that makes sense and any advice you might be able to give would be much appreciated! Regards, Rob Is there a sample js that can dynamicaly draw line, without flickring,crossbrowser, etc. Like you have a point and another and dynamicaly draw line between as one of them move around with dragging. Tryed this (using images): http://www.p01.org/releases/Drawing_lines_in_JavaScript It turns out bad. The line could be dashed, dotted, no need for whole line. I need to draw like image 1 in file attach. But after i write code: 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <script type="text/javascript"> function Ve() { var n = document.getElementById("txtGiatri").value; var i,j; for(i=1;i<=n;i++) { for(j=0;j<n-i;j++) document.getElementById ("place").innerHTML +=" "; for(j=i;j>0;j--) { document.getElementById ("place").innerHTML +=j; } document.getElementById ("place").innerHTML +="<br/>"; } } </script> <body> <table> <tr> <td><input name="txtGiatri" type="text" id="txtGiatri" /></td> <td><input name="btnVe" type="button" value="Ve" onclick="Ve();" /></td> </tr> <tr> <td><div id="place"></div></td> <td></td> </tr> </table> </body> </html> i only have like image 2. How i fixed it? I have a working script and I want to add a toogleGroup command (which I have) to the end of the working script so that I can toggle map markers with radio buttons. Probably a simple addition. WORKING CODE: Code: //<![CDATA[ var iconPink = new GIcon(); iconPink.image = 'http://www.golfinggreys.com/img/ggmap_icon_attraction.png'; iconPink.shadow = ''; iconPink.iconSize = new GSize(24, 31); iconPink.shadowSize = new GSize(0, 0); iconPink.iconAnchor = new GPoint(11, 30); iconPink.infoWindowAnchor = new GPoint(5, 1); var iconOrange = new GIcon(); iconOrange.image = 'http://www.golfinggreys.com/img/ggmap_icon_accomm.png'; iconOrange.shadow = ''; iconOrange.iconSize = new GSize(24, 31); iconOrange.shadowSize = new GSize(0, 0); iconOrange.iconAnchor = new GPoint(11, 30); iconOrange.infoWindowAnchor = new GPoint(5, 1); var iconPurple = new GIcon(); iconPurple.image = 'http://www.golfinggreys.com/img/ggmap_icon_dining.png'; iconPurple.shadow = ''; iconPurple.iconSize = new GSize(24, 31); iconPurple.shadowSize = new GSize(0, 0); iconPurple.iconAnchor = new GPoint(11, 30); iconPurple.infoWindowAnchor = new GPoint(5, 1); var iconGreen = new GIcon(); iconGreen.image = 'http://www.golfinggreys.com/img/ggmap_icon_golf.png'; iconGreen.shadow = ''; iconGreen.iconSize = new GSize(24, 31); iconGreen.shadowSize = new GSize(0, 0); iconGreen.iconAnchor = new GPoint(11, 30); iconGreen.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'http://www.golfinggreys.com/img/ggmap_icon_golfr.png'; iconRed.shadow = ''; iconRed.iconSize = new GSize(24, 31); iconRed.shadowSize = new GSize(0, 0); iconRed.iconAnchor = new GPoint(11, 30); iconRed.infoWindowAnchor = new GPoint(5, 1); var iconGrey = new GIcon(); iconGrey.image = 'http://www.golfinggreys.com/img/ggmap_icon_services.png'; iconGrey.shadow = ''; iconGrey.iconSize = new GSize(24, 31); iconGrey.shadowSize = new GSize(0, 0); iconGrey.iconAnchor = new GPoint(11, 30); iconGrey.infoWindowAnchor = new GPoint(5, 1); var iconBlue = new GIcon(); iconBlue.image = 'http://www.golfinggreys.com/img/ggmap_icon_shopping.png'; iconBlue.shadow = ''; iconBlue.iconSize = new GSize(24, 31); iconBlue.shadowSize = new GSize(0, 0); iconBlue.iconAnchor = new GPoint(11, 30); iconBlue.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["attraction"] = iconPink; customIcons["accomm"] = iconOrange; customIcons["dining"] = iconPurple; customIcons["golf"] = iconGreen; customIcons["golfr"] = iconRed; customIcons["services"] = iconGrey; customIcons["shopping"] = iconBlue; var markerGroups = { "attraction": [], "accomm": [], "dining": [], "golf": [], "golfr": [], "services": [], "shopping": []}; function load() { if (GBrowserIsCompatible()) { var i = 0; // Create the map // Make sure this element has the same ID as your div map = new GMap2(document.getElementById("googlemap")); // Add controls for moving and zooming the map. Use GSmallMapControl for small maps map.addControl(new GSmallMapControl()); // Add controls for switching between regular and satellite views map.addControl(new GMapTypeControl()); // Set the starting position and zoom level when the map loads map.setCenter(new GLatLng(51.920556,-103.798828), 7); // Read the data from XML var request = GXmlHttp.create(); // Open the XML file request.open("GET", "east_central.xml", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = request.responseXML; // Obtain the array of markers and loop through it 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 GLatLng(lat,lng); var name = markers[i].getAttribute("name"); var phone = markers[i].getAttribute("phone"); var address = markers[i].getAttribute("address"); var city = markers[i].getAttribute("city"); var state = markers[i].getAttribute("state"); var url = markers[i].getAttribute("url"); var type = markers[i].getAttribute("type"); var marker = createMarker(point,name,phone,address,city,state,url,type); map.addOverlay(marker); } } } request.send(null); // Function to create the marker and set up the event window function createMarker(point,name,phone,address,city,state,url,type) { var marker = new GMarker(point, customIcons[type]); markerGroups[type].push(marker); var markerhtml = ""; if (name != "") markerhtml += "<b>" + name + "</b><br>"; markerhtml += address + ", " + city + ", " + state + "<br>"; if (phone != "") markerhtml += "p:" + phone + "<br>"; if (url != "") markerhtml += "<a href=\"" + url + "\">COURSE DETAILS</a>"; // Add a click event to each marker which will open the HTML window GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(markerhtml); }); i++; return marker; } } // Javascript alert for older browsers where Google Maps isn't supported else { alert("Sorry, the Google Maps API is not compatible with this browser"); } } //]]> THE ADDITION Code: function toggleGroup(type) { for (var i = 0; i < markerGroups[type].length; i++) { var marker = markerGroups[type][i]; if (marker.isHidden()) { marker.show(); } else { marker.hide(); } Just need to properly add that to the end. I am okay at editing and adapting codes, but I don't know the sytax. Tried JSLINT but still confused. Probably quite simple. Thanks Hey all, I was wondering if someone would be able to help me with a problem I've been having. I'm attempting to find coordinates for several addresses at a time. I'm using a for-loop to loop through an array of addresses. I figured it would be best to have a separate function to evaluate the coordinate given an address, and just call it in every loop. Note that my code below is simplified (I removed the for loop because that's not where I'm having trouble). I know that the issue is probably because I'm trying to return a value from an anonymous function... I tried making the variable global, I tried having a return line from within the anonymous function, nothing has worked... any tips? Thanks -- Code follows Code: function initialize(){ var geocoder = new google.maps.Geocoder(); // creating a new geocode object var locCood = findcood('44106', geocoder); } function findcood(addr, geocoder) { var cood; if (geocoder) { geocoder.geocode({'address': addr}, function(results, status, cood){ if (status == google.maps.GeocoderStatus.OK) cood = results[0].geometry.location; else { cood = null; alert("Geocode was not successful for the following reason: " + status); } }); } else { alert("No Geocode"); cood = null; } alert(cood); return cood; } 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. http://www.cricketcoachingclinics.com.au/ I am having a problem with site in IE7 this is identified as a problem?? Can someone at least rule out this js error? This is js generated when adding google maps Error Class is not defined <CODE>var GoogleMap=Class.create(Widget,{widgetIdentifier:"com-apple-iweb-widget-GoogleMap",initialize:function($super,instanceID,widgetPath,sharedPath,sitePath,preferences,runningI nApp) {if(instanceID){$super(instanceID,widgetPath,sharedPath,sitePath,preferences,runningInApp);}},mapReq uestTemplate:'center=#{center}&zoomLevel=#{zoomLevel}&showZoom=#{showZoom}&mapType=#{mapType}&locate dAddress=#{locatedAddress}&locatedAddressPoint=#{locatedAddressPoint}&showInfo=#{showInfo}&language= #{language}&showGoogleBar=#{showGoogleBar}',iframeTemplate:'<iframe id="#{instanceID}-iframe" name="#{instanceID}-iframe" src="#{mapURL}?#{mapRequest}" width="100%" height="100%" scrolling="no" marginheight="0" marginwidth="0" frameborder="0"></iframe>',mapURL:'http://www.me.com/st/1/sharedassets/maps/iweb2/',onload:function() {var mapRequestTemplate=new Template(this.mapRequestTemplate);var mapRequest=mapRequestTemplate.evaluate({center:this.escapedPreferenceForKey("center"),zoomLevel:this .escapedPreferenceForKey("zoomLevel"),showZoom:this.escapedPreferenceForKey("showZoom"),mapType:this .escapedPreferenceForKey("mapType"),locatedAddress:this.escapedPreferenceForKey("locatedAddress"),lo catedAddressPoint:this.escapedPreferenceForKey("locatedAddressPoint"),showInfo:this.escapedPreferenc eForKey("showInfo"),language:this.escapedPreferenceForKey("language"),showGoogleBar:this.escapedPref erenceForKey("showGoogleBar")});var iframeTemplate=new Template(this.iframeTemplate);var iframeText=iframeTemplate.evaluate({instanceID:this.instanceID,mapRequest:mapRequest,mapURL:this.map URL});this.div().innerHTML=iframeText;if(this.preferences&&this.preferences.postNotification) this.preferences.postNotification("BLWidgetIsSafeToDrawNotification",1);},escapedPreferenceForKey:fu nction(key) {var value=this.preferenceForKey(key);if(value!==undefined) value=encodeURIComponent(value);return value;}});</CODE> Hi, Not sure where to post this. I currently have a web app which utilises Google Maps & Directions, however some of these maps and directions will be used in pdf creation with tcpdf. The problem arises with the fact that tcpdf doesn't read javascript and therefore cant show the map. Any ideas on what I can do to compensate? Hi, i have 1 site with three different brands (three ID numbers). I have made a javascript if-statement but it doesnt work. Somebody see some wrong here, I think it should work properly. Thanks in advance $language and $brand is set... <script type="text/javascript"> var accountId; var url; if($language == 'test') { if($brand = '1') { accountId = 'UA-xxxxx-1' url = '1.com' } else if ($brand = '2') { accountId = 'UA-xxxxx-2' url = '2.com' } else if ($brand = '3') { accountId = 'UA-xxxxx-3' url = '3.com' } var _gaq = _gaq || []; _gaq.push(['_setAccount', accountId]); _gaq.push(['_setDomainName', url]); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview', '/' + window.location.host + '/' + window.location.pathname]); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> I started using the Google News Web Element on my website. The website for Google News Web Element is: http://www.google.com/webelements/#!/news I want the links to open in a new window, which cannot be done with the iframe version. Their website only allows me to generate an iframe. I was told that this can be done by using the javascript version, but I have not been able to figure it out. This is their link to the documentation: http://code.google.com/apis/newssearch/newsshow/ I know very little about javascript, and have been trying to get it to work but have been unsuccessful. I want to use the Medium Rectangle size and I want the only topic to be "Swainsboro". The only modification that I want to make is for the links to open in a new window. If anyone can help me do this, it would be appreciated. This is the iframe data that was generated by the wizard: Code: <iframe frameborder=0 marginwidth=0 marginheight=0 border=0 style="border:0;margin:0;width:300px;height:250px;" src="http://www.google.com/uds/modules/elements/newsshow/iframe.html?rsz=large&format=300x250&ned=us&hl=en&q=Swainsboro&element=true" scrolling="no" allowtransparency="true"></iframe> Hi folks, My website is located he http://maps.peachtree-city.org My search functions point to a mysql database and has been working since June 2008. All of sudden, and I credit my boss to this, it has become dysfunctional with a reoccuring error noted by Firefox: Syntax Error: 0Query was empty. I have a php within the server which pulls from my map file to call upon mysql: From the map.html Code: function submitAddress() { var address = document.getElementById('address').value; var searchUrl = 'http://maps.peachtree-city.org/google/parcelpin_genxml2.php?address=' + address; GDownloadUrl(searchUrl, function(data) { var xml = GXml.parse(data); var markers = xml.getElementsByTagName('marker'); if (markers.length == 0) { alert('Sorry, no Address matches found. Remember to check your spelling and format.'); return; } var address1 = markers[0].getAttribute('address') var point = new GLatLng(parseFloat(markers[0].getAttribute('lat')), parseFloat(markers[0].getAttribute('lng'))); if (point && ge != null) { var la = ge.createLookAt(''); la.set(point.y, point.x, 100, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 500); placemark.setName(address); var point1 = ge.createPoint(address1); point1.setLatitude(point.y); point1.setLongitude(point.x); placemark.setGeometry(point1); ge.getView().setAbstractView(la); } }); } The form from map.html Code: <center><p style="font-family:arial narrow" "color=green" size="1">Search <strong>Address</strong> Example: 1232 S Hwy 74</font></p></center> <form name='searchform2' id='searchform2' action="javascript:void(0);"> <input type=text size=21 id='address' ></input> <input type=submit button style="background-color:orange" value='Search Address' onClick='javascript:submitAddress();'> <input type=reset button style="background-color:orange" value='Clear Form'> </form> <br> The searchURL (parcelpin_genxml2.php) Code: <?php require ("phpsql_dbinfo.php"); function parseToXML($htmlStr) { $xmlStr=str_replace('<','<',$htmlStr); $xmlStr=str_replace('>','>',$xmlStr); $xmlStr=str_replace('"','"',$xmlStr); $xmlStr=str_replace("'",''',$xmlStr); $xmlStr=str_replace("&",'&',$xmlStr); return $xmlStr; } // Opens a connection to a mySQL server $connection=mysql_connect (localhost, $user, $password); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active mySQL database $db_selected = mysql_select_db('geocode', $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = ""; if ($address != null) { $tok = strtok($address, " "); $count = 0; $query = "SELECT * FROM address WHERE "; while ($tok !== false) { if ($count > 0) { $query = $query." and "; } $query = $query." address like '%$tok%'"; $tok = strtok(" "); $count = $count + 1; } } else if ($parcelpin != null) { $query = "SELECT * FROM parcel WHERE parcelpin='$parcelpin'"; } $result = mysql_query($query); if (!$result) { die("Invalid query " + $query . mysql_error()); } header("Content-type: text/xml"); // Start XML file, echo parent node echo '<markers>'; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; if ($address != null) { echo 'address="' . $row['address'] . '" '; } else if ($parcelpin != null) { echo 'parcelpin="' . $row['parcelpin'] . '" '; } echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo '/>'; } // End XML file echo '</markers>'; mysql_close(); ?> I am at a complete lost why the error. Boss says he didn't touch anything but I noticed he did add another table to mysql which led me finding out he also tried installing a CMS , SugarCMS. Upon research on this, I found some mentions of SugarCMS contributing to errors on other mysql databases. Hey Guys, I am building an application that uses Google Maps V3 and currently using JavaScript to show and hide markers. I have two check boxes, they have the same location but show if a user has been there or if they are going there. To hide the markers, I am doing the following function: Code: function hideMarker(location) { for (var i = 0; i < gmarkers.length; i++) { if (gmarkers[i].currentLocation == location) { gmarkers[i].setVisible(false); } } infowindow.close(); } Problem is, because two markers have the same location, it will hide both. I am passing a been and going value to gmarkers array (gmarkers[i].been etc) so wanted to say something like.. If been is unchecked only hide the been marker. Else if going is unchecked only hide the going marker. Else hide both markers. Anyone have any ideas how I can separate the been and going markers? I can't get my head around the logic Cheers. Hello chaps, I'm Nick I'm in the process of creating a web app using Google Maps. What the following code should do is retrieve some xml code from a page, then load it on to the map, using the geocoder to get lat/long values from the address. Most of it's just Google code I've mauled about with. The map loads, but none of the markers load on to the map. I've gone to the php page which generates the XML for the markers and all is fine there. I know the code is a messy crock of junk, I was sort of concentrating on trying to make it work then I'll sort out the nomenclature. Bad methodology, I know. Code: var id = null; var adress = null; var image = null; var point = null; var pointer = null; var geocoder = null; var iconBlue = new GIcon(); iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png'; iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconBlue.iconSize = new GSize(12, 20); iconBlue.shadowSize = new GSize(22, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png'; iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconRed.iconSize = new GSize(12, 20); iconRed.shadowSize = new GSize(22, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["restaurant"] = iconBlue; customIcons["bar"] = iconRed; function load() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(52.2725, -0.8825), 12); geocoder = new GClientGeocoder(); GDownloadUrl("phpsqlajax_genxml3.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { id = markers[i].getAttribute("ID"); address = markers[i].getAttribute("ADDRESS"); image = markers[i].getAttribute("IMAGE"); var point3 = showAddress(address); var marker = createMarker(pointer, id, address, image); map.addOverlay(marker); } }); } } function showAddress(address) { point = geocoder.getLatLng(address,function(point) { if (!point) { alert(address + " not found"); } else { pointer = new GLatLng(point); return pointer; } }); } function createMarker(pointer, id, address, image) { var marker4 = new GMarker(pointer); var html = "<b>" + id + "</b> <br/>" + address + "</b> <br/>" + image; GEvent.addListener(marker, 'click', function() { marker4.openInfoWindowHtml(html); }); return marker4; } Thanks in advance I am trying to use JavaScript to change the path to my pics on my web site at the same time that I change the css sheet. I found the code to change the css but I want to change the pic paths at the same timeI got the css changing code from http://javascript.internet.com/css/change-style.html thanks
Hi, i'm new to javascript, im managing to find out how to do most things, but i need to validate two paths. I want to know how to check whether path1 is a subpath of path2. e.g. 1: /files/stuff/mypics/anotherfolder/etc 2:/files/stuff/mypics i want to be able to return a boolean given whether i can move folder 1 in to folder 2 in this case yes. but if you swap them its a no. please help. oxide I pulled this code from Google's example section to make markers on a v3 Google Maps API (I have added my own lat/long points and corresponding event listeners, of course, but this is still the spirit of the code):
Code: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var map; function initialize() { var map_center = new google.maps.LatLng(39.2,-84.479381); var store1 = new google.maps.LatLng(39.112456,-84.574779); var store2 = new google.maps.LatLng(39.314153,-84.261379); var store3 = new google.maps.LatLng(39.197099,-84.667579); var store4 = new google.maps.LatLng(39.16836,-84.479381); var myOptions = { zoom: 10, center: map_center, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var marker1 = new google.maps.Marker({ position: store1, map: map, title:"Store 1" }); var marker2 = new google.maps.Marker({ position: store2, map: map, title:"Store 2" }); var marker3 = new google.maps.Marker({ position: store3, map: map, title:"Store 3" }); var marker4 = new google.maps.Marker({ position: store4, map: map, title:"Store 4" }); google.maps.event.addListener(marker1, 'click', function() { map.set_center(store1); map.set_zoom(16); }); google.maps.event.addListener(marker2, 'click', function() { map.set_center(store2); map.set_zoom(16); }); google.maps.event.addListener(marker3, 'click', function() { map.set_center(store3); map.set_zoom(16); }); google.maps.event.addListener(marker4, 'click', function() { map.set_center(store4); map.set_zoom(16); }); } </script> This works without fail, but when I try to use a javascript array to hold my values and loop my way through the marker creation like so: Code: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var map; function initialize() { var map_center = new google.maps.LatLng(39.2,-84.479381); var store_locations = new Array(); var temporary_stuff = new Array(); store_locations[0] = "39.112456,-84.574779"; store_locations[1] = "39.314153,-84.261379"; store_locations[2] = "39.197099,-84.667579"; store_locations[3] = "39.16836,-84.479381"; var myOptions = { zoom: 10, center: map_center, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); for(i=0;i<store_locations.length;i++){ var marker_string = "position: "+new google.maps.LatLng(store_locations[i])+", map: map, title:\"Store "+(i+1)+"\";"; temporary_stuff[i] = new google.maps.Marker(marker_string); } var markers = new Array(); for(i=0;i<temporary_stuff.length;i++){ var the_marker = "position: temporary_stuff[" + i + "], map: map, title:\"Store " + (i+1) + "\";"; markers[i]= new google.maps.Marker(the_marker); } } </script> I get a blank map. Here's a link to the test file: http://rowsdower.freehostia.com/map_test.php It's not throwing up any errors in Firefox's developer or in IE but there it sits, a blank map. I'm sure this isn't clean or optimized code, but it looks correct to me. I've color-coded the code above to show what "for" loops are being used to try to replace which code. Hopefully that makes this more sensible. I haven't even tried to add the listeners yet since I can't get the markers to appear. Can anyone tell me why this isn't working or point me in a more productive direction? Is there a better way already out there that I haven't noticed? Hi all, I'm desperately trying to figure out how to "transform" Javascript commands into HTML code. Excuse my noobness but I really know nothing about Javascript. Basically, I have this Google API Search code: 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> <title>My Google AJAX Search API Application</title> <script src="http://www.google.com/jsapi?key=CUT"></script> <script language="Javascript" type="text/javascript"> //<![CDATA[ google.load("search", "1"); function OnLoad() { // Create a search control var searchControl = new google.search.SearchControl(); // Add in a full set of searchers var localSearch = new google.search.LocalSearch(); searchControl.addSearcher(localSearch); searchControl.addSearcher(new google.search.WebSearch()); searchControl.addSearcher(new google.search.VideoSearch()); searchControl.addSearcher(new google.search.BlogSearch()); // Set the Local Search center point localSearch.setCenterPoint("New York, NY"); // Tell the searcher to draw itself and tell it where to attach searchControl.draw(document.getElementById("searchcontrol")); // Execute an inital search searchControl.execute("Google"); } google.setOnLoadCallback(OnLoad); //]]> </script> </head> <body> <div id="searchcontrol">Loading...</div> </body> </html> Now, what I'm desperately trying to do since 4-5 hours is to have the search results between the <div id="searchcontrol"></div> encoded as HTML in the loaded page. Currently, when the page is loaded and I look at the source code, I have the word 'Loading...' in the <div> tags, despite in the normal view there are G results listed. I need those results encoded as HTML for SEO reasons. Researching on this matter I thought the problem could be the OnLoad command, that makes the script load after all the other HTML elements are loaded. But I tried to make it load before all the elements in the page, and the problem persists. How can I solve this? Thanks in advance for any help! I'm new to the forum. So hi everyone. The code below works fine on IE and FF but not on Google Chrome. Can someone tell me where I'm doing wrong? Thank you for your answers in advance. Im really looking forward much to hearing from you. You can preview the below code by pasting it to Frontpage, Dreamweaver and etc. Quote: <!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> <script type="text/JavaScript"> <!-- function show(id) { if (document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = ''; } } //--> <!-- function hide(id) { document.getElementById(id).style.display = 'none'; } //--> </script> </head> <body> <div> <div> <table cellspacing="1" cols="3" border="0"> <tbody> <td><a onfocus="hide('tblB');hide('tblC');show('tblA');" href="#">A</a> <td><a onfocus="hide('tblA');hide('tblC');show('tblB');" href="#">B</a> <td><a onfocus="hide('tblB');hide('tblA');show('tblC');" href="#">C</a> </td> </tr> </tbody> </table> </div> <div> <table id="tblA" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select A, table tblA is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblB" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select B, table tblB is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblC" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select C, table tblC is shown </td> </tr> </tbody> </table> </div> </div> </body> </html> Firstly I know this is a PHP issue yet it is within javascript and IMO is the root cause of the problem. I'm trying to output markers from a search query of locations from my database, onto a Google Map (api v.3) using a tut I found http://tips4php.net/2010/10/use-php-...g-data-on-map/ When adding this to my page I'm getting Undefined index:errors. I have changed the variables in the php part of the script to suit my database yet have left everything else alone, cant figure out why I'm still getting a blank map???? Please help.... My code with errors being shown at bottom; Code: <script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script> <script type="text/javascript"> var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/blue.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 } }); <br /> <b>Notice</b>: Undefined index: name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br /> <br /> <b>Notice</b>: Undefined index: lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br /> <br /> <b>Notice</b>: Undefined index: info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br /> addMarker(53.994709, ,'<b></b><br/>'); <br /> <b>Notice</b>: Undefined index: name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br /> <br /> <b>Notice</b>: Undefined index: lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br /> <br /> <b>Notice</b>: Undefined index: info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br /> addMarker(53.985416, ,'<b></b><br/>'); <br /> <b>Notice</b>: Undefined index: name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br /> <br /> <b>Notice</b>: Undefined index: lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br /> <br /> <b>Notice</b>: Undefined index: info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br /> addMarker(53.985416, ,'<b></b><br/>'); <br /> <b>Notice</b>: Undefined index: name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br /> <br /> <b>Notice</b>: Undefined index: lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br /> <br /> <b>Notice</b>: Undefined index: info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br /> addMarker(0.000000, ,'<b></b><br/>'); <br /> <b>Notice</b>: Undefined index: name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br /> <br /> <b>Notice</b>: Undefined index: lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br /> <br /> <b>Notice</b>: Undefined index: info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br /> addMarker(0.000000, ,'<b></b><br/>'); center = bounds.getCenter(); map.fitBounds(bounds); } </script> How does one get inline styles placed by javascript to work in Google Chrome? Works in Firefox and Opera, I know that Chrome is receiving the correct data by using alerts, but it is not putting the style object in the HTML.
|