3

5月のasp.netアプリケーションでgeo-autocompleteを使用しています。私の問題は、ジオオートコンプリートを使用したテキストボックスに初めて何かを書いたときに、結果が表示されることです。しかし、私は自分のページに1つのオートポストバックテキストボックスイベントを持っています。彼らがGoogle geo-autocompleteを起動すると、動作しません.google-autocompleteの私のhtmlはこれです:

    <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>

これは、ジオコードを使用しているテキストボックスです

<asp:TextBox ID="txtPickupCity" runat="server" MaxLength="50" 
                                                            Width="140px"></asp:TextBox>
4

2 に答える 2

0

これが私が一度経験したのと同じケースかどうかはわかりませんが、これを試すことができます: 緯度および/または緯度が設定されていない場合 (つまり、値がない場合)、私の JavaScript は単にそうではありませんでした仕事。だから私は条件を追加しました(コードは特定のプログラミング言語ではありません)、私の問題はなくなりました:

If Latitude = "" then Latitude = 0
If Langitude = "" then Langitude = 0
于 2012-10-11T10:04:36.050 に答える