Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

geo-autocomplete not work after page refresh

I use geo-autocomplete in may asp.net application . My problem is that when first time i write something on my text box where i used geo-autocomplete this display the result. But i have one autopost back textbox event on my page, When they fire the google geo-autocomplete not working, My html for google-autocomplete is this :

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../lib/jquery.autocomplete_geomod.js"></script>

<script type="text/javascript" src="../js/geo_autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="../lib/jquery.autocomplete.css" />


<script type="text/javascript">
    $().ready(function() {

        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var myOptions = {
            zoom: 8,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById('<%=map_canvas.ClientID %>'), myOptions);

        // use all the autocomplete options as documented at http://docs.jquery.com/Plugins/Autocomplete
        /* additional geo_autocomplete options:
        mapkey : 'ABQ...' (required for Static Maps thumbnails, obtain a key for your site from http://code.google.com/apis/maps/signup.html)
        mapwidth : 100
        mapheight : 100
        maptype : 'terrain' (see http://code.google.com/apis/maps/documentation/staticmaps/#MapTypes)
        mapsensor : true or false
        */
        $('#<%=txtPickupCity.ClientID %>').geo_autocomplete(new google.maps.Geocoder, {
            mapkey: 'ABQIAAAAbnvDoAoYOSW2iqoXiGTpYBTIx7cuHpcaq3fYV4NM0BaZl8OxDxS9pQpgJkMv0RxjVl6cDGhDNERjaQ',
            selectFirst: false,
            minChars: 3,
            cacheLength: 50,
            width: 300,
            scroll: true,
            scrollHeight: 330
        }).result(function(_event, _data) {
            if (_data) map.fitBounds(_data.geometry.viewport);
        });

    });
</script>
<style>
.ac_results li img {
    float: left;
    margin-right: 5px;
}
</style>

Here is my text box on which i am using geo code

<asp:TextBox ID="txtPickupCity" runat="server" MaxLength="50" 
                                                            Width="140px"></asp:TextBox>
like image 212
A.Goutam Avatar asked Nov 24 '25 01:11

A.Goutam


1 Answers

Thanks all i expend 4 hours on google to find out ansqwer this problem at last this is simple

on your Page_load () you use this code that will help you

 ScriptManager.RegisterStartupScript(Page, this.GetType(), "delCty", "delCity();", true);

Here "delCty" is Key "delCity()" is function name . Yes means i give function name of function

     <script type="text/javascript">
    function delCity() 
{
}

Enjoy coding . I think this will help you

like image 71
A.Goutam Avatar answered Nov 25 '25 14:11

A.Goutam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!