venky n

venky n

  • NA
  • 110
  • 38.6k

How to pass address value using dropdown control in java sc

Mar 12 2015 3:53 AM
process:Search Place In Google Map


How to pass address value using dropdown control in java script





<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
       <script type="text/javascript">
     $(document).ready(function () {
            $("#ddcity").SelectedIndexChanged(function () {

                var geocoder = new google.maps.Geocoder();
                var city = document.getElementById('ddcity').value;

                var com = city + "," + con;
                geocoder.geocode({ 'address': com }, function (results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {
                        var x = results[0].geometry.location.lat();
                        var y = results[0].geometry.location.lng();
                        var latlng = new google.maps.LatLng(x, y);
                        var myOptions = {
                            zoom: 8,
                            center: latlng,
                            mapTypeId: google.maps.MapTypeId.ROADMAP
                        };
                        map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
                        var marker = new google.maps.Marker({
                            position: new google.maps.LatLng(x, y),
                            map: map,
                            title: com
                        });

                        var infowindow = new google.maps.InfoWindow({
                            content: com
                        });
                        infowindow.open(map, marker);
                        google.maps.event.addDomListener(window, 'load');
                    } else {
                        res.innerHTML = "Enter correct Details: " + status;
                    }
                });
            });
        });
    </script>



</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td colspan="2">
                    Search Place In Google Map
                </td>
            </tr>
                    <tr>
                      <asp:DropDownList ID="ddcity" AutoPostBack="true" runat="server"
                        onselectedindexchanged="ddcity_SelectedIndexChanged">
                    <asp:ListItem Value="Chennai">Chennai</asp:ListItem>
                    <asp:ListItem Value="arni">arni</asp:ListItem>
                    <asp:ListItem Value="Vellore">vellore</asp:ListItem>
                    <asp:ListItem Value="thiruvannamalai">Thiruvannamalai</asp:ListItem>
                     <asp:ListItem Value="Kanchipuram">Kanchipuram</asp:ListItem>
                    </asp:DropDownList>
                    </td>
            </tr>
        </table>
    </div>
    <div id="map-canvas" style="height: 500px; width: 500px">
    </div>
    </form>
</body>
</html>


Answers (8)