Jump to content

[SOLVED] php and javascipt API


sungpeng

Recommended Posts

<!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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

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();">

Link to comment
Share on other sites

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

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...

Important Information

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