var geocoder, map, marker = null;
$(function() {
init();
$(".exit").click(function() {
$("#waiMap").hide();
});
$("#showMap").click(function() {
$("#waiMap").show();
});
});
var init = function() {
var center = new soso.maps.LatLng(39.916527, 116.397128);
map = new soso.maps.Map(document.getElementById('allmap'), {
center: center,
zoom: 15
});
geocoder = new soso.maps.Geocoder({
complete: function(result) {
map.setCenter(result.detail.location);
var marker = new soso.maps.Marker({
map: map,
position: result.detail.location
});
document.getElementById("txtPos").value = result.detail.location.toString().replace(" ", "");
}
});
//给map绑定mousemove事件
var label = new soso.maps.Label({
offset: new soso.maps.Size(15, 0)
});
soso.maps.event.addListener(map, "click", function(e) {
label.setContent(e.latLng.toString());
label.setPosition(e.latLng);
document.getElementById("txtPos").value = e.latLng.toString();
});
soso.maps.event.addListener(map, "mouseover", function(e) {
label.setMap(map);
});
soso.maps.event.addListener(map, "mouseout", function(e) {
label.setMap(null);
});
}
function codeAddress() {
var address = document.getElementById("address").value;
geocoder.getLocation(address);
}