Add your showAddress function in the javascript section.

Add this in the HTML section where you want the input box to appear:
<label for="startAddress">Your Location: </label><input type="input"
id="startAddress" size="40" value=""/><input name="button" type="button"
value="Find Station" onclick="javascript:showAddress(
document.getElementById('startAddress').value);"/>

Steve
On Sat, Jan 24, 2009 at 2:09 PM, mathiastheok <[email protected]>wrote:

>
> I've been working via the google maps API tutorial, I've got my map
> working with encoded polylines and it is all working great.
>
>
> The last thing I want to add to my map is a search box (geocoding
> search box) so that one can find out which sky train or subway station
> is closest to their destination.
>
> I just would like a search box that puts the marker on the map...
>
> I have tried to paste into my code the geocoding codes, but I just
> dont know enough to place it properly...or if I have a bracket out of
> place or what.
>
> This is the code I "think" is what I need:
>
> var map = new GMap2(document.getElementById("map_canvas"));
> var geocoder = new GClientGeocoder();
>
> function showAddress(address) {
>  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);
>
> Here is a link to a page where I have my map loaded (I have not
> inserted the code as I dont have a clue where to put it):
>
> http://www.thailandgentlemenstravelclub.com/googlemaptest.html
>
> Here is the link to my XML. file where I pull the polyline data etc...
> if you need to review it:
>
> http://www.thailandgentlemenstravelclub.com/googletestmap.xml
>
> If one of you gurus would be kind enough to tell me or show me or
> anything where to put the code for the geocodeing (if I have even got
> the right code).
>
> Thanks so much !!
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to