What is an administrative planning diagram? How do I get the boundary contour of each administrative region? Example: Zhongqing Jiangbei District.
Official Category reference: Http://developer.amap.com/javascript/reference/search#Partition
Administrative Planning Code:
function bydistrict () { varnew amap.partition (); // Create a new administrative planning class Partition.bydistrict (district,city,bydistricty_callback); // Administrative Planning Enquiry
After the query to the administrative planning diagram, you need to show the data, then use the callback function:
functionBydistricty_callback (data) {showTime ();d Ocument.getelementbyid ("Textuniqid"). Value =data.uniqid; varResultstr= ""; if(Data.status = = "E0") { varLineNum = Data.list.length;//returns the total. Resultcount=LineNum; varContent= ""; for(vari=0;i<linenum;i++) {content+ = "<div style=\" cursor:pointer;\ "Onmouseover=openmarkertipbyid1 (This) onmouseout=clearbackground (this) onclick =\ "DrawPolygon ('" +data.list[i].coords+ "', '" +data.list[i].name+ "') \" ><dl> "; Content+ = "<dt>" + "county Name:" +data.list[i].name+ "<dt> County Code:" +data.list[i].adcode+ "</dt>" + "<dt> District City Area code: "+data.list[i].citycode+" </dt> "; Content+ = "</dl></div>"; } resultstr+=content; } Else if(Data.status = = "E1") {ResultStr= "No results found!<br/> Recommendation: <br/>1. Make sure all words are spelled correctly. <br/>2. Try different keywords. <br/>3. Try a broader keyword. "; } Else{resultstr= "error message:" +data.state+ "Please look up the error type against the API Server v2.0.0 concise cue code Comparison table"; } document.getElementById ("Result"). InnerHTML =ResultStr; }
The administrative Region diagram is a polygon, so how do you show this polygon? Use the polygon paint function:
functionDrawPolygon (arr,name) {mapobj.clearmap (); varPolygonarr =NewArray (); vardistrict = Arr.split (";"); varLnglat =NewArray (); for(vare=0;e<district.length-1;e++){ varLnglat=district[e].split (","); Polygonarr.push (NewAmap.lnglat (lnglat[0],lnglat[1])); } Polygon=NewAmap.polygon ({path:polygonarr,//Set polygon boundary pathStrokecolor: "#0000ff",//Line Colorstrokeopacity:0.2,//Line TransparencyStrokeweight:3,//line widthFillColor: "#f5deb3",//Fill Colorfillopacity:0.35//Fill Transparency }); Polygon.setmap (Mapobj); Mapobj.setfitview (); }
Sample Link: http://zhaoziang.com/amap/partition.html
: