谷歌位置搜索 蹩脚结合jquery.ui.gmap

http://gmaps-samples-v3.googlecode.com/svn/trunk/localsearch/places.html

 

 var gLocalSearch = new GlocalSearch();

    gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);

    function OnLocalSearch() {

        if (!gLocalSearch.results) {

            window.alert("未找到,请手工查找");

            return;

        }

        //debugger;

        //console.log(gLocalSearch.results[0]);

        var result = gLocalSearch.results[0];

        var lat =result.lat;//$(item).attr("lat");

        var lng = result.lng;//$(item).attr("lng");

        var latlng = new google.maps.LatLng(lat, lng);

        $('#map_canvas').gmap('addMarker', {

            'position': latlng,

            'bounds': true,

            'draggable': true

        }, function (map, marker) {

            $('#map_canvas').gmap('get', 'map').setOptions({ 'center': latlng ,  'draggable': true});

            setTimeout(function () {

                $('#map_canvas').gmap('option', 'zoom', 15);

            }, 1000);

        }).click(function () {

        });

    }

 

 

function Search() {

        var text = '';



        if ($('#selectcounty').val() != '') {

            text += $("#selectcounty option:selected").text()+' ';



        }  

        if ($('#selectcity').val() != '') {

            text += $("#selectcity option:selected").text()+' ';



        }

        if ($('#selectprovince').val() != '') {

            text += $("#selectprovince option:selected").text()+' ';

        }

            

        text += $('#detailaddress').val();

            

            

        gLocalSearch.execute(text);

    }

你可能感兴趣的:(jquery)