...

View Full Version : API javascript



sungpeng
05-07-2009, 08:55 AM
<!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&amp;v=2.x&amp;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 echo "$map_address"; ?>')">


<div id="map_canvas" style="width: 250px; height: 200px"></div>

</body>
</html>

I need to get it load australia map automatically. Can anyone help pls. About code is not working

TinyScript
05-07-2009, 09:31 AM
I tried this and it worked for me in firefox

I took a guess moved the map to my city.

then in the address bar I wrote

javascript:map.getCenter()

hit enter and bingo!!!

TinyScript
05-07-2009, 09:37 AM
http://i39.tinypic.com/2ylurd5.png

the location returned in this image is actually from down under. I didn't save the right map image

sungpeng
05-07-2009, 09:57 AM
it doesn't work for me in internet. http://www.sgfairdeal.com/tes1.php I want it to show australia map instead of default singapore pls help amend the coding above

TinyScript
05-07-2009, 10:35 AM
move the map to the place you want it to open up at.
put the
javascript:map.getCenter()
in the address bar and hit click
copy and paste the output in place of the current start location
http://i40.tinypic.com/w1xpjd.png

this is the map location of the image you see above
map.setCenter(new GLatLng(-34.894942447397305, 138.592529296875), 13);

TinyScript
05-07-2009, 10:53 AM
http://i41.tinypic.com/34j92ky.jpg



<!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&amp;v=2.x&amp;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(-26.273714024406416, 134.6484375), 3);
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 echo "$map_address"; ?>')">


<div id="map_canvas" style="width: 250px; height: 200px"></div>

</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum