sungpeng Posted May 7, 2009 Share Posted May 7, 2009 <!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>sgfairdeal</title> <script src="http://maps.google.com/maps?file=api&v=2.x&key=your key" type="text/javascript"></script> <script type="text/javascript"> var map = null; var geocoder = null; var map = null; var geocoder = null; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(1.3714, 103.8861), 13); map.addControl(new GSmallMapControl()); 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); } } ); } } </script> </head> <?php $map_address="australia"; ?> <body onload="initialize()" onunload="GUnload()" onload="showAddress('<?php$map_address?>')"> <div id="map_canvas" style="width: 250px; height: 200px"></div> </body> </html> Part of it is php. I need it to show the australia map straight away. Can anyone help pls? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Help with what? By the way, <body onload="initialize()" onunload="GUnload()" onload="showAddress('<?php$map_address?>')"> It should be <body onload="initialize()" onunload="GUnload()" onload="showAddress('<?php echo $map_address; ?>')"> instead. Quote Link to comment Share on other sites More sharing options...
sungpeng Posted May 7, 2009 Author Share Posted May 7, 2009 hi it is still not working after the change.. I need to show australia map. Quote Link to comment Share on other sites More sharing options...
trq Posted May 7, 2009 Share Posted May 7, 2009 Read the 'How to ask' link in my signature. Quote Link to comment Share on other sites More sharing options...
sungpeng Posted May 7, 2009 Author Share Posted May 7, 2009 I need the code to directly go to australia map. Currently it is showing default singapore map. Can anyone help pls? Quote Link to comment Share on other sites More sharing options...
Potatis Posted May 7, 2009 Share Posted May 7, 2009 This code looks like it is setting co-ordinates: map.setCenter(new GLatLng(1.3714, 103.8861), 13); Are they the latitude and longitude co-ordinates of Singapore? If so, try changing them to whatever the lat and long co-ordinates of Australia are. Although born and bred in Australia, I have no idea where I am on the globe in lat/long co-ordinates. Quote Link to comment Share on other sites More sharing options...
Adam Posted May 7, 2009 Share Posted May 7, 2009 If this is supposed to display Australia on the map, then it's not working as you can only have 1 onload call... onload="showAddress('<?php echo $map_address; ?>')" Use instead: <body onload="initialize(); showAddress('<?php echo $map_address; ?>');" onunload="GUnload();"> Quote Link to comment Share on other sites More sharing options...
sungpeng Posted May 7, 2009 Author Share Posted May 7, 2009 Solved Thank Quote Link to comment Share on other sites More sharing options...
sungpeng Posted May 8, 2009 Author Share Posted May 8, 2009 Can check with you again, I found that above code always go to the first map then it will go to my intended map(australia). Can bypass or disable the first map straight to the intended map(australia)? Quote Link to comment Share on other sites More sharing options...
Adam Posted May 8, 2009 Share Posted May 8, 2009 I imagine you'd need to change the JavaScript, specifically this line, to the Australian co-ordinates: map.setCenter(new GLatLng(1.3714, 103.8861), 13); Quote Link to comment Share on other sites More sharing options...
sungpeng Posted May 8, 2009 Author Share Posted May 8, 2009 No I need it to use php <?php $map_address="australia"; ?> to call out the location of map, instead of amending the longitude and latitude, pls help? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.