problem description
is that the area that I want to display by default when the page is opened is Guangzhou
.the environmental background of the problems and what methods you have tried
do not know how to set the default, do not display it again, ask for advice
related codes
/ / Please paste the code text below (do not replace the code with pictures)
< script type= "text/javascript" src= " https://webapi.amap.com/maps?.;key= key & plugin=AMap.Geocoder&plugin=AMap.DistrictSearch "> < / script >
var map = new AMap.Map ("container", {
zoom:11,//
center: [113.107901,22.995755],//
viewMode:"3D",//3D
mapStyle: "amap://styles/blue"//
});
/ / Administrative Division query
var opts = {
subdistrict: 1, //
showbiz:false //
};
district = new AMap.DistrictSearch(opts);//:
district.search("", function(status, result) {
if(status=="complete"){
getData(result.districtList[0]);
}
});
function getData(data,level) {
var bounds = data.boundaries;
if (bounds) {
for (var i = 0, l = bounds.length; i < l; iPP) {
var polygon = new AMap.Polygon({
map: map,
strokeWeight: 1,
strokeColor: "-sharpCC66CC",
fillColor: "-sharpCCF3FF",
fillOpacity: 0.2,
path: bounds[i]
});
polygons.push(polygon);
}
map.setFitView();//
}
}