title: how to implement a search location box in google map in asp.net
body: <p>this code save the longitude and latitude of a current location ..i need to know how i will apply the search button for finding different location to save their longitude and latitude  </p>
  
  <pre><code>     &lt;script type="text/javascript"&gt;
           var long = 0;
           var lat = 0;
           if (navigator.geolocation) {
               navigator.geolocation.getCurrentPosition(function (p) {
                   var LatLng = new google.maps.LatLng(p.coords.latitude, p.coords.longitude);
                   var mapOptions = {
                       center: LatLng,
                       zoom: 13,
                       mapTypeId: google.maps.MapTypeId.ROADMAP
                   };
                   var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
                   var marker = new google.maps.Marker({
                       position: LatLng,
                       map: map,
                       title: "&lt;div style = 'height:60px;width:200px'&gt;&lt;b&gt;Your location:&lt;/b&gt;&lt;br /&gt;Latitude: " + p.coords.latitude + "&lt;br /&gt;Longitude: " + p.coords.longitude
                   });
                   google.maps.event.addListener(marker, "click", function (e) {
                       var infoWindow = new google.maps.InfoWindow();
                       infoWindow.setContent(marker.title);
                       infoWindow.open(map, marker);
                       long = e.latLng.lng();
                       lat = e.latLng.lat();
                       document.getElementById("lat").value = lat;
                       document.getElementById("lng").value = long;
                   });
               });
               google.maps.event.addDomListener(window, 'load', function () {
                   var places = new google.maps.places.Autocomplete(document.getElementById('txtPlaces'));
                   google.maps.event.addListener(places, 'place_changed', function () {
                       var place = places.getPlace();
                       var address = place.formatted_address;
                       var latitude = place.geometry.location.k;
                       var longitude = place.geometry.location.D;
                       var mesg = "Address: " + address;
                       mesg += "\nLatitude: " + latitude;
                       mesg += "\nLongitude: " + longitude;
                       alert(mesg);
                   });
               });
  
           } else {
               alert('Geo Location feature is not supported in this browser.');
           }
  &lt;/script&gt;
  
  
  
  
      &lt;form id="form1" runat="server"&gt;
  
  
  &lt;div id="dvMap" style="width: 800px; height: 600px"&gt;
     &lt;/div&gt;
     &lt;asp:HiddenField ID="lat" ClientIDMode="Static" runat="server" /&gt;
     &lt;asp:HiddenField ID="lng" ClientIDMode="Static" runat="server" /&gt;
  
     &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /&gt;
  
  
          &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
          &lt;span&gt;Location:&lt;/span&gt;
      &lt;input type="text" id="txtPlaces" style="width: 250px" /&gt;
  
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>server side code ::</p>
  
  <pre><code>public partial class _Default : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
  
      }
      protected void Button1_Click(object sender, EventArgs e)
      {
  
           Double latitude = Convert.ToDouble(lat.Value);
          Double longitude = Convert.ToDouble(lng.Value);
              string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
              SqlConnection con = new SqlConnection(constr);
  
  
          string query1 = "insert into tbl(longi,lati) values (@lati, @longi)";
  
          SqlCommand cmd1 = new SqlCommand(query1, con);
          cmd1.Parameters.AddWithValue("@lati", latitude);
          cmd1.Parameters.AddWithValue("@longi", longitude);
  
                  con.Open();
  
                  cmd1.ExecuteNonQuery();
  
  
                  con.Close();    
      }
  
      }
  </code></pre>