這個代碼 function MapD() {
var obj = document.getElementById("txt_City");
var local = new BMap.LocalSearch(map, {
renderOptions: { map: map }
});
local.search(obj.value);
}
用BMap.Geocoder 查詢經緯度
function MapD() {
var obj = document.getElementById("txt_City");
var geo = new BMap.Geocoder();
geo.getPoint(obj.value, function (point) {
if (point) {
map.centerAndZoom(point, 15);
var marker = new BMap.Marker(point);
map.addOverlay(marker);
}
});
}