经纬度转位置
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>指定地理坐标定位</title>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
</head>
<body>
<div>
<p><label>经度</label><input id="lat" value="39.89477" /></p>
<p><label>纬度</label><input id="lng" value="116.35432" /></p>
<input type="button" value="search" onclick="geolocation_latlng()">
</div>
</body>
<script>
var citylocation = new qq.maps.CityService({
complete: function(results) {
console.log('结果', results)
}
});
function geolocation_latlng() {
let lat = document.getElementById('lat').value;
let lng = document.getElementById('lng').value;
console.log(lat,lng)
var latLng = new qq.maps.LatLng(lat, lng);
citylocation.searchCityByLatLng(latLng);
}
</script>
</html>