修改baidumap\map.html
var map, geocoder,marker;
function initialize() {
map = new BMap.Map('map_canvas');
var point = new BMap.Point(121.473704, 31.230393);
map.centerAndZoom(point, 11);
map.addControl(new BMap.NavigationControl());
map.enableScrollWheelZoom();
marker = new BMap.Marker(point);
marker.enableDragging();
map.addOverlay(marker);
var gc = new BMap.Geocoder();
gc.getLocation(point, function(rs){
var addComp = rs.addressComponents;
var address = [addComp.city].join('');
parent.document.getElementById("kindeditor_plugin_map_address").value = address;
});
}
function search(address) {
if (!map) return;
var local = new BMap.LocalSearch(map, {
onSearchComplete: function (results){
if (results && results.getNumPois()) {
var points = [];
for (var i=0; i<results.getCurrentNumPois(); i++) {
points.push(results.getPoi(i).point);
}
if (points.length > 1) {
map.setViewport(points);
} else {
map.centerAndZoom(points[0], 13);
}
point = map.getCenter();
marker.setPosition(point);
} else {
alert('无法定位到该地址!');
}
}
});
local.search(address);
}
红字为不同的地方,请各位对应查验