您的位置:首页 > Web前端 > JQuery

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

2013-05-07 19:15 169 查看
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 () {
});
}


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

 

 

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);
}


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: