How does the "German map API" get to the administrative region? How to make an administrative plan?

Source: Internet
Author: User
Tags comparison table

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.