zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jQuery根据纬度经度查看地图处理程序

jQuery 查看 根据 地图 处理程序
2023-06-13 09:14:53 时间
复制代码代码如下:

<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
//在这里要注意js的引入顺序
<linkhref="css/jquery.ui.base.css"rel="stylesheet"type="text/css"/>
<linkhref="css/jquery.ui.theme.css"rel="stylesheet"type="text/css"/>
<scriptsrc="http://maps.google.com/maps/api/js?sensor=false"type="text/javascript"></script>
<scriptsrc="js/jquery-1.9.1.js"type="text/javascript"></script>
<scriptsrc="js/jquery.mousewheel.js"type="text/javascript"></script>
<scriptsrc="js/jquery.ui.core.js"type="text/javascript"></script>
<scriptsrc="js/jquery.ui.widget.js"type="text/javascript"></script>
<scriptsrc="js/jquery.ui.button.js"type="text/javascript"></script>
<scriptsrc="js/jquery.ui.spinner.js"type="text/javascript"></script>
<linkhref="css/demos.css"rel="stylesheet"type="text/css"/>
<scripttype="text/javascript">
$(function(){
functionlatlong(){
returnnewgoogle.maps.LatLng($("#lat").val(),$("#lng").val());
}
functionposition(){
map.setCenter(latlong());
}
$("#lat,#lng").spinner({
step:.001,
change:position,
stop:position
});
varmap=newgoogle.maps.Map($("#map")[0],{
zoom:8,
center:latlong(),
mapTypeId:google.maps.MapTypeId.ROADMAP
});
});
</script>
<styletype="text/css">
#map{
width:500px;
height:500px;
}
</style>
</head>
<body>
<labelfor="lat">纬度</label>
<inputid="lat"name="lat"value="44.797"/>
<br>
<labelfor="lng">经度</label>
<inputid="lng"name="lng"value="-93.278"/>
<divid="map"></div>
<divclass="demo-description">
</div>
</body>
</html>