What is an administrative planning diagram? How do I get the boundary contour of each administrative region? Example: Zhongqing Jiangbei District.
650) this.width=650; "src=" Http://images.cnitblog.com/i/249635/201406/031720153645210.png "style=" margin:0px; padding:0px;border:0px;width:658px; "/>
Official Category reference: Http://developer.amap.com/javascript/reference/search#Partition
650) this.width=650; "src=" Http://images.cnitblog.com/i/249635/201406/031558160369926.png "style=" margin:0px; padding:0px;border:0px;width:658px; "/>
Administrative Planning Code:
function bydistrict () {var partition = new Amap.partition (); Creation of a new administrative planning category Partition.bydistrict (District,city,bydistricty_callback); Administrative Planning Query}
After the query to the administrative planning diagram, you need to show the data, then use the callback function:
Function bydistricty_callback (data) { showtime (); document.getElementById ("Textuniqid") .value = data.uniqid; var resultstr= ""; if (data.status == "E0") { var linenum = data.list.length; //return Total . resultCount=lineNum; var content= ""; for (var i=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>" + "counties Name:" +data.list[i].name+ "<dt> County code: "+data.list[i].adcode+" </dt> "+" <dt> District-owned City area code: "+data.list[i].citycode+" </dt> "; content+= "</dl></div>"; } resultStr+=content; }&nbsP; 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 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:
Function drawpolygon (Arr,name) { Mapobj.clearmap (); var polygonarr = New array (); var district = Arr.split (";"); var lnglat = new array (); for (var e=0;e<district.length-1;e++) { var lnglat=district[e ].split (","); Polygonarr.push (New amap.lnglat (lnglat[0],lnglat[1)); } polygon=new amap.polygon ({ path:polygonarr,//Set polygon boundary path strokecolor: "#0000ff", //Line Color strokeopacity:0.2, //Line Transparency strokeWeight:3, //line width fillColor: "#f5deb3", //fill Color fillopacity: 0.35//fill transparency }); polygon.setmap (mapobj); mapobj.setfitview (); }
Sample Link: http://zhaoziang.com/amap/partition.html
:
650) this.width=650; "src=" Http://images.cnitblog.com/i/249635/201406/031720345676410.png "style=" margin:0px; padding:0px;border:0px;width:658px; "/>