Baidu Map overlay-Custom search results. Default red overlay covers how to solve the new custom overlay.

clipboard.png


< html lang= "en" >
< head >

<meta charset="UTF-8">
<title>Title</title>
<style>
    body{
        padding: 0;
        margin: 0 auto;
    }
    -sharpdemo{
        width: 100%;

    }
</style>

< / head >
< body >

< div id= "demo" > < / div >
< select name= "" id= "province" value= ">

<option value=""></option>
<option value=""></option>
<option value=""></option>

< / select >
< select name= "" id= "city" disabled= "disabled" value= ">

<option value=""></option>
<option value=""></option>

< / select >
< select name= "" id= "area" disabled= "disabled" value= ">

<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>

< / select >
< input type= "button" class= "btn" value= "search

< div class= "add_result" > < / div >
< / body >
< script src= " http://code.jquery.com/jquery...;></script>
<script type= "text/javascript" src= ";ak=BNfhaSSFf3ZzQCpqXvqgWOeGFKty46cG"></script>
<script>

$("-sharpprovince").change(function () {
    if($("-sharpprovince").val()!=""){
        $("-sharpcity").removeAttr("disabled")
    }else{
        $("-sharpcity").attr("disabled","disabled")
    }
})
$("-sharpcity").change(function () {
    if($("-sharpprovince").val()!=""){
        $("-sharparea").removeAttr("disabled")
    }else{
        $("-sharparea").attr("disabled","disabled")
    }
})

$("-sharpdemo").height($(window).height()/1.2)
var map = new BMap.Map("demo");
function replaceIcon(iconPath, marker, sizeW, sizeH) {
    map.removeOverlay(marker);
    var icons = iconPath; //
    var icon = new BMap.Icon(icons, new BMap.Size(sizeW, sizeH)); //

    marker.setIcon(icon);//
    map.addOverlay(marker);//
}
map.enableScrollWheelZoom(true);
// var myIcon = new BMap.Icon("http://a.tiles.mapbox.com/v3/marker/pin-m-w+009f9f.png", new BMap.Size(50,50),{imageOffset:new BMap.Size(0,0)});
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
    if(this.getStatus() == BMAP_STATUS_SUCCESS){

        marker2= new BMap.Marker(r.point);
        map.centerAndZoom(r.point, 16);

        var iconPath="http://a.tiles.mapbox.com/v3/marker/pin-m-w+009f9f.png";
        replaceIcon(iconPath, marker2, 40, 40);

        map.addOverlay(marker2);
        // map.panTo(r.point);
    }
    else {
        alert("failed"+this.getStatus());
    }
});
var marker2;
function sear(addr) {
    var local = new BMap.LocalSearch(map, {
        renderOptions:{map: map},
        onSearchComplete:function (getLocalResult) {
            map.clearOverlays();
            console.log(getLocalResult)
            for(var i= 0;i<getLocalResult.Ar.length;iPP){

                $("<li>"+getLocalResult.Ar[i].title+"</li>").appendTo(".add_result");

                marker2 = new BMap.Marker(getLocalResult.Ar[i].point);  // 

                var iconPath="http://a.tiles.mapbox.com/v3/marker/pin-m-w+009f9f.png";
                replaceIcon(iconPath, marker2, 40, 40);
                map.addOverlay(marker2);
            }
        }
    });
    local.search(addr);

}

$(".btn") .click (function () {

)
   var addr=$("-sharpprovince").val()+$("-sharpcity").val()+$("-sharparea").val()+"";
   sear(addr);

})

< / script >
< / html >

Jun.06,2022

delete the map:map section


after the search results of the map, the custom tags are also marked, but the maps are not displayed very well, so they are all huddled together

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e941eb-14af.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e941eb-14af.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?