Google map Api google.maps.LatLng(). Can i change the "google.maps.LatLng() method" to location or address -
hi guys using following code load map of location
var map; function initialize() { var mapoptions = { zoom: 8, center: new google.maps.latlng(-34.397, 150.644) }; map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); }
i want use location string draw map this
google.maps.location(-34.397, 150.644)
if possible.
i guess want use latitude , longitude name of location, have use reverse geocoding service google map api . function need :
function codelatlng() { var input = document.getelementbyid('latlng').value; var latlngstr = input.split(',', 2); var lat = parsefloat(latlngstr[0]); var lng = parsefloat(latlngstr[1]); var latlng = new google.maps.latlng(lat, lng); geocoder.geocode({'latlng': latlng}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { if (results[1]) { map.setcenter(latlng); map.setzoom(11); if(marker){ marker.setposition(latlng); } else { marker = new google.maps.marker({ position: latlng, map: map }); } // adr latitude longitude place name after geocoding adr = results[1].formatted_address; document.getelementbyid("adresse").value = adr ; } else { alert('no results found'); } } else { alert('geocoder failed due to: ' + status); } }); }
Comments
Post a Comment