/    Sign up×
Community /Pin to ProfileBookmark

Google maps API script

Hello

[CODE] <script src=”http://maps.google.com/maps?file=api&amp;v=2.x&amp;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> [/CODE]

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

[CODE]<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> [/CODE]

is there a way to eliminate this part and CALL FOR THE ACTION with the address (<?=$address?>

any help ?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@dannybrazilauthorAug 06.2009 — 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
×

Success!

Help @dannybrazil spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...