Thanks Pallavi. I tried with your code.I successfully get the longitude and latitude of the marker postions when it drags.
But when i search to display a particular location...it showing an error that geocoder i snot define.Waht is this? Can you help me to get out of this Once again thank you very much for your valuable code and suggestions On Fri, Feb 20, 2009 at 3:25 AM, Pallavi Lad <[email protected]> wrote: > Hi, > > It is simple you can do this by following code: > > In below code: addresss is name of textbox in which user enters city name > > function showAddress(address) //call this function on search button > click > > { > > if (geocoder) > > { > > geocoder.getLatLng(address, > function(point) > > { > > if (!point) > > { > > alert( > "Sorry, we were unable to find " + address + "."); > > } > > else > > { > > var lat = point.lat(); > > var lng = point.lng(); > > map.setCenter( > new GLatLng(lat,lng), 13); > > if (marker) map.removeOverlay(marker); > > marker = > new GMarker(point, {draggable: true}); > > GEvent.addListener(marker, > "dragstart", function > () > > { > > map.closeInfoWindow(); > > }); > > GEvent.addListener(marker, > "dragend", function() { > > var lat = marker.getPoint().lat(); > > var lng = marker.getPoint().lng(); > > document.form1.latitude.value=lat; //here latitude is name of > textbox to show it > > document.form1.longitude.value=lng; //here longitude is name of > textbox to show it > > }); > > map.addOverlay(marker); > > } > > } > > ); > > } > > } > > > When you enter location name in addresss text box click on search buttton. > It will show you marker on that location on map.Then drag the marker it > will display latitude and longitude values in those two text boxes. > > > Hope,it will help you. > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
