微信小程序原生高德地图显示行政区域

位置:首页 / 技术中心 / 微信小程序原生

微信小程序原生 Admin 2025-10-29 16:40:30 111


//components\resources\resources.wxml

  <map id="mapId" class="map" markers="{{markers}}" polygons="{{polygons}}" scale="{{scale}}" bindmarkertap="getPoint" wx:if="{{ mapShow }}" show-location="true" ></map>

 


//components\resources\resources.js

    // 从高德地图API获取边界数据

    getDistrictBoundaryFromAmap(districtName, level) {

      const that = this;

      // 使用高德地图行政区划查询API

      const key = '1234567910'; // 需要替换为实际的高德地图API密钥

      

      wx.request({

        method: "GET",

        data: {

          key: key,

          keywords: districtName,

          subdistrict: "0",

          extensions: "all",

          output: "JSON",

          level: level

        },

        url: "https://restapi.amap.com/v3/config/district?parameters",

        header: {

          'content-type': 'application/json',

        },

        success: (res) => {

          if (res.statusCode == 200 && res.data.info == "OK" && res.data.districts && res.data.districts.length > 0) {

            const district = res.data.districts[0];

            const polyline = district.polyline;

            

            if (polyline) {

              const boundsList = polyline.split(";\n");

              const polygons = [];

              

              boundsList.forEach((boundary, index) => {

                const bounds = [];

                boundary.split(";").forEach(item => {

                  const lonlats = item.split(",");

                  if (lonlats.length === 2) {

                    bounds.push({

                      longitude: Number(lonlats[0]),

                      latitude: Number(lonlats[1])

                    });

                  }

                });

                

                if (bounds.length > 0) {

                    polygons.push({

                      points: bounds,

                      strokeWidth: 3,

                      strokeColor: '#5583FF',

                      fillColor: 'rgba(85, 131, 255, 0.3)',

                      fillOpacity: 0.3,

                      zIndex: 1

                    });

                  }

              });

              

              that.setData({

                polygons: polygons

              });

              console.log('从高德地图API获取边界数据成功');

              // 调整地图视野以显示整个区域

              setTimeout(() => {

                that.includePolygonArea();

              }, 300);

            } else {

              console.log('高德地图API未返回边界数据');

              that.useBackupBoundary();

            }

          } else {

            console.log('高德地图API查询失败:', res.data.info || '未知错误');

            that.useBackupBoundary();

          }

        },

        fail(err) {

          console.log('高德地图API请求失败:', err);

          // 如果API请求失败,使用备用坐标

          that.useBackupBoundary();

        }

      });

    },

    

    // 使用备用边界坐标(当API请求失败时使用)

    useBackupBoundary() {

      console.log('使用备用边界坐标数据');

      // 黄山徽州区的备用边界坐标点

      const huizhouPoints = "118.298626,30.071074;118.298609,30.069242;118.298908,30.067759;118.299155,30.067176;118.299903,30.066642;118.30076,30.065726;118.301284,30.064422;118.301626,30.063812;118.301653,30.063452;118.301189,30.062019;118.300497,30.060464;118.300204,30.059997;118.299246,30.059258;118.298497,30.058463;118.29772,30.05753;118.297653,30.057226;118.29768,30.056839;118.297929,30.05645;118.298529,30.056086;118.299196,30.055942;118.299353,30.055775;118.299092,30.05528;118.29963,30.054632;118.299689,30.053896;118.299412,30.052917;118.298923,30.052037;118.298443,30.051395;118.298271,30.050492;118.298432,30.047154;118.298728,30.04647;118.298916,30.046275;118.299934,30.046211;118.300506,30.046069;118.300914,30.045706;118.302328,30.045076;118.302456,30.044311;118.302763,30.043451;118.303266,30.042922;118.303482,30.042451;118.30317,30.040463;118.302558,30.037605;118.302664,30.036029;118.302559,30.035311;118.302041,30.034597;118.30194,30.034156;118.301964,30.033603;118.302417,30.031719;118.303311,30.031368;118.304894,30.031132;118.306636,30.030069;118.308433,30.028233;118.309322,30.026683;118.309605,30.025816;118.309631,30.025401;118.309145,30.024769;118.308383,30.022907;118.307904,30.022155;118.30752,30.021651;118.307034,30.021542;118.306458,30.02119;118.305166,30.01874;118.304518,30.016944;118.303501,30.015777;118.303274,30.014869;118.30275,30.014637;118.302086,30.014593;118.300875,30.014733;118.298294,30.013738;118.297107,30.013091;118.296524,30.012106;118.296201,30.011374;118.295977,30.011319;118.295971,30.011708;118.295206,30.012346;118.295177,30.012466;118.295179,30.012652;118.295717,30.013801;118.295762,30.014497;118.295062,30.014661;118.292322,30.014353;118.29213,30.014299;118.292157,30.013939;118.292594,30.012842;118.292981,30.011282;118.293582,30.010543;118.294382,30.010128;118.296051,30.009993;118.298079,30.009412;118.298716,30.009462;118.299357,30.009788;118.299939,30.010474;118.300298,30.011162;118.300651,30.011353;118.301636,30.011262;118.302205,30.010953;118.302483,30.010315;118.302764,30.007751;118.303043,30.007564;118.303573,30.007841;118.304459,30.008031;118.305385,30.008008;118.306136,30.00779;118.307568,30.009776;118.307849,30.009982;118.30805,30.009837;118.308853,30.008204;118.30999,30.007559;118.310082,30.007309;118.309874,30.006012;118.309896,30.005238;118.31008,30.004656;118.310822,30.003825;118.311586,30.003418;118.31162,30.002918;118.311525,30.002729;118.311266,30.002711;118.310868,30.003114;118.310315,30.003291;118.309902,30.003248;118.309355,30.002837;118.308043,30.002268;118.30728,30.002357;118.306301,30.00289;118.305667,30.003116;118.304968,30.003177;118.30267,30.002644;118.302544,30.002783;118.302626,30.004109;118.302502,30.004414;118.302248,30.004444;118.301322,30.004231;118.301602,30.001298;118.301266,29.999919;118.301372,29.998315;118.301244,29.998233;118.30083,29.998237;118.299881,29.998604;118.299155,29.99908;118.296435,30.001567;118.296086,30.001625;118.295668,30.001652;118.294638,30.000421;118.291796,30.002049;118.291605,30.001995;118.291122,30.001529;118.290673,30.001284;118.2901,30.001206;118.288778,30.001573;118.287628,30.002086;118.2848,30.002136;118.28309,30.001486;118.282257,30.001051;118.281429,30.000919;118.281111,30.00095;118.280853,30.001148;118.28027,30.002284;118.279426,30.003304;118.278497,30.005179;118.27808,30.006449;118.277882,30.007753;118.277927,30.008026;118.275309,30.009052;118.272451,30.009899;118.272105,30.010178;118.271857,30.010706;118.271636,30.010791;118.271226,30.010337;118.269695,30.009089;118.269506,30.008267;118.269084,30.007673;118.269066,30.006954;118.269194,30.006252;118.268421,30.005717;118.268018,30.004638;118.267902,30.00396;118.268422,30.003053;118.268758,30.001972;118.26946,30.001227;118.269599,30.000665;118.268168,29.998107;118.267986,29.997587;118.268341,29.997114;118.268812,29.996755;118.271021,29.9967;118.271357,29.996509;118.271504,29.996164;118.272594,29.99642;118.273137,29.996444;118.273645,29.996263;118.274216,29.995756;118.274687,29.995486;118.275502,29.995449;118.276422,29.995648;118.277687,29.996316;118.279085,29.996716;118.280345,29.996942;118.280922,29.996907;118.281089,29.996729;118.28115,29.996167;118.2811,29.992307;118.280772,29.990966;118.280497,29.990285;118.281241,29.989954;118.281576,29.989655;118.282207,29.987329;118.281606,29.985522;118.281613,29.984576;118.281751,29.983628;118.281992,29.983204;118.282889,29.982144;118.284162,29.980136;118.284423,29.979064;118.285136,29.97803;118.285648,29.977764;118.286861,29.977487;118.287638,29.977155;118.28953,29.977049;118.29006,29.976447;118.290275,29.975731;118.290366,29.975121;118.289924,29.974212;118.289133,29.973304;118.289034,29.972954;118.289189,29.97142;118.288753,29.968261;118.28844,29.96681;118.288646,29.965944;118.289343,29.965441;118.29078,29.964759;118.295265,29.962292;118.299737,29.960175;118.303484,29.957452;118.304319,29.956403;118.304394,29.954889;118.301246,29.947919;118.300812,29.947201;118.300882,29.946271;118.301563,29.944591;118.304338,29.941852;118.308432,29.93856;118.31054,29.936619;118.314988,29.934433;118.32275,29.931021;118.329465,29.929088;118.331576,29.927988;118.333488,29.926272;118.336541,29.923034;118.339451,29.918801;118.342495,29.914861;118.346771,29.909689;118.348809,29.906458;118.350172,29.90305;118.349777,29.901462;118.348946,29.900317;118.34795,29.899528;118.346683,29.8988;118.34368,29.896544;118.342918,29.895799;118.342916,29.89561;118.342597,29.895044;118.342677,29.894846;118.342811,29.894772;118.34294,29.894347;118.342614,29.893213;118.342687,29.89176;118.342858,29.891335;118.343166,29.891071;118.343296,29.890727;118.343165,29.890232;118.342931,29.88981;118.34292,29.888971;118.343183,29.888509;118.343264,29.887633;118.343438,29.887406;118.343566,29.886945;118.343968,29.886707;118.344092,29.885949;118.344936,29.885446;118.344927,29.884832;118.344748,29.884608;118.344744,29.884338;118.345449,29.884296;118.34558,29.883988;118.345982,29.883831;118.346111,29.883451;118.347041,29.883182;118.347356,29.882719;118.347664,29.882446;118.348246,29.882559;118.348731,29.882401;118.348864,29.882283;118.348943,29.881985;118.348947,29.881489;118.349121,29.881334;118.349743,29.881283;118.350148,29.881361;118.351425,29.880737;118.351789,29.880815;118.352324,29.881226;118.353349,29.881145;118.353714,29.881331;118.353848,29.881294;118.353928,29.881068;118.353609,29.880457;118.354092,29.879379;118.353723,29.878887;118.353496,29.878284;118.353754,29.877398;118.353834,29.876405;118.353557,29.875875;118.35364,29.875116;118.353586,29.874919;118.353049,29.874355;118.352635,29.873637;118.352721,29.873059;118.352893,29.872796;118.353119,29.872641;118.35374,29.872518;118.353954,29.872291;118.354216,29.871675;118.354085,29.871216;118.354165,29.87099;118.354299,29.870908;118.354666,29.870953;118.354771,29.870244;118.356583,29.869898;118.356921,29.869747;118.357121,29.869479;118.357161,29.869039;118.356804,29.868495;118.355651,29.867236;118.355494,29.867161;118.35495,29.867191;118.350611,29.866061;118.349562,29.865641;118.344917,29.862815;118.341527,29.860028;118.341151,29.859913;118.339388,29.860134;118.332068,29.86245;118.329949,29.862869;118.329003,29.86326;118.327713,29.8633;118.3271,29.863157;118.326654,29.862807;118.32664,29.861773;118.326896,29.860619;118.327814,29.858102;118.327996,29.856344;118.327908,29.854809;118.327462,29.854337;118.327514,29.853277;118.327678,29.852862;118.328128,29.852042;118.329422,29.851164;118.32994,29.85017;118.331288,29.848896;118.332512,29.84807;118.335732,29.845282;118.335928,29.84469;118.336052,29.843833;118.335971,29.842859;118.335586,29.842006;118.334654,29.840832;118.333541,29.838964;118.335217,29.840237;118.337191,29.841504;118.338006,29.842043;118.3385,29.842378;118.338865,29.842582;118.339594,29.843122;118.340731,29.843886;118.342598,29.84396;118.342319,29.843421;118.343656,29.842071;118.346768,29.845662;118.350072,29.844693;118.351832,29.84328;118.349402,29.837917;118.348914,29.836839;118.348227,29.834642;118.347969,29.832857;118.348141,29.831814;118.348484,29.831181;118.348441,29.830696;118.349113,29.830689;118.352209,29.83105;118.353423,29.831866;118.355088,29.833284;118.357537,29.835034;118.35854,29.8361;118.359064,29.836861;118.359654,29.837276;118.359717,29.837506;118.359694,29.83765;118.359582,29.838072;118.35962,29.838186;118.359991,29.838436;118.35998,29.838471;118.360037,29.838468;118.360718,29.838941;118.360722,29.838968;118.360755,29.838967;118.360933,29.839092;118.361803,29.839699;118.361808,29.839727;118.361835,29.839721;118.363213,29.840669;118.365798,29.842504;118.36593,29.842541;118.366463,29.841983;118.367969,29.842634;118.369207,29.843414;118.369577,29.84356;118.371493,29.843649;118.372303,29.843621;118.37262,29.843469;118.373198,29.842673;118.375307,29.840774;118.375502,29.840644;118.375706,29.840629;118.378106,29.83924;118.380125,29.837015;118.380255,29.836504;118.380205,29.835977;118.379764,29.835416;118.378896,29.835161;118.377432,29.835039;118.377141,29.834795;118.377174,29.83269;118.377375,29.831633;118.377174,29.830355;118.377391,29.829092;118.378083,29.827453;118.378727,29.82649;118.378947,29.825993;118.379188,29.825298;118.379173,29.824735;118.379041,29.824354;118.378621,29.823798;118.376999,29.823604;118.373472,29.822463;118.372136,29.822456;118.370653,29.820998;118.369776,29.82029;118.368995,29.820058;118.36831,29.820064;118.366898,29.820474;118.366442,29.820518;118.365165,29.820101;118.364782,29.819834;118.364124,29.819692;118.363456,29.819431;118.361669,29.819088;118.359917,29.818887;118.359639,29.818611;118.359493,29.817976;118.359922,29.816281;118.36041,29.814974;118.360879,29.812696;118.362556,29.811837;118.365015,29.811136;118.366354,29.810858;118.366571,29.810714;118.36739,29.810468;118.369943,29.810048;118.371355,29.809717;118.371648,29.809551;118.372849,29.807623;118.373311,29.8074;118.37488,29.807589;118.377089,29.808697;118.379732,29.810841;118.383007,29.812218;118.384531,29.813516;118.385792,29.815339;118.385939,29.816054;118.38574,29.818124;118.385566,29.818762;118.385116,29.819491;118.384722,29.820521;118.384464,29.821572;118.384473,29.822184;118.385034,29.823605;118.392053,29.831912;118.392443,29.832053;118.397306,29.832266;118.401485,29.832223;118.405388,29.831567;118.411866,29.828696;118.416788,29.826402;118.418434,29.825059;118.418432,29.824888;118.417318,29.822284;118.416953,29.82045;118.415168,29.816349;118.413023,29.813181;118.409444,29.809953;118.409111,29.809757;118.408328,29.808034;118.407522,29.806746;118.407191,29.806383;118.407126,29.805899;118.407187,29.803965;118.407078,29.802439;118.407126,29.801726;118.407713,29.799879;118.407817,29.799013;118.407742,29.798492;118.40782,29.797327;118.406711,29.794035;118.405378,29.79289;118.403938,29.790511;118.402716,29.786608;118.401458,29.783347;118.401364,29.782916;118.401615,29.782048;118.402012,29.781204;118.401974,29.780738;118.401618,29.78019;118.399858,29.779547;118.399656,29.779752;118.399491,29.780441;118.398999,29.780776;118.398037,29.780863;118.397772,29.780713;118.397739,29.780382;118.397847,29.77977;118.398186,29.778953;118.398005,29.778765;118.396196,29.77781;118.395478,29.777542;118.394462,29.777769;118.393512,29.778735;118.392316,29.779154;118.390607,29.778842;118.387905,29.777714;118.386124,29.776554;118.384178,29.775429;118.383198,29.775104;118.382264,29.775457;118.381424,29.775957;118.380952,29.776769;118.378897,29.776858;118.378093,29.777056;118.377704,29.777243;118.376887,29.777877;118.375449,29.778294;118.375214,29.778788;118.374517,29.780937;118.373859,29.781618;118.373154,29.782026;118.371685,29.78252;118.371001,29.782631;118.370754,29.782247;118.370503,29.781582;118.368733,29.778964;118.367594,29.778272;118.365889,29.777479;118.364106,29.776863;118.362621,29.776875;118.362146,29.776733;118.361661,29.776708;118.360925,29.777276;118.360596,29.77774;118.360418,29.778615;118.360495,29.781284;118.360343,29.781987;118.359908,29.782658;118.359272,29.783366;118.358675,29.783933;118.358274,29.784147;118.355378,29.781696;118.353186,29.779012;118.352468,29.77797;118.351623,29.777078;118.350859,29.775896;118.350559,29.775206;118.350344,29.774154;118.349882,29.772788;118.350319,29.769778;118.350081,29.767539;118.348452,29.766172;118.345462,29.764069;118.339949,29.760703;118.337373,29.760526;118.335271,29.760561;118.333827,29.760699;118.332863,29.761744;118.332719,29.763811;118.332168,29.765602;118.329463,29.767888;118.327835,29.768488;118.326252,29.768509;118.32493,29.768367;118.323761,29.768728;118.322538,29.769893;118.321323,29.771238;118.320222,29.772176;118.317792,29.772159;118.31595,29.772309;118.31524,29.77301;118.315209,29.774092;118.314973,29.775186;118.313421,29.77648;118.31093,29.77687;118.308829,29.777013;118.306994,29.777452;118.305199,29.779262;118.304572,29.780476;118.30387,29.781519;118.303083,29.781706;118.30183,29.7815;118.300569,29.780942;118.299783,29.780224;118.298415,29.778975;118.296345,29.777865;118.294809,29.776741;118.292774,29.776898;118.289332,29.781511;118.289289,29.792253;118.307913,29.792236;118.307314,29.804892;118.30511,29.810097;118.304224,29.81219;118.298946,29.81394;118.296982,29.815011;118.295694,29.816947;118.295265,29.81933;118.294407,29.820745;118.292948,29.820821;118.291832,29.820522;118.291145,29.819479;118.290974,29.818437;118.289944,29.817841;118.288485,29.818438;118.287111,29.81799;118.284667,29.821301;118.283594,29.826439;118.281819,29.830712;118.274868,29.828776;118.264739,29.828776;118.259977,29.833614;118.258476,29.833634;118.257506,29.834658;118.251773,29.833611;118.246366,29.832421;118.241131,29.829144;118.234522,29.825124;118.232232,29.824106;118.225255,29.828071;118.223471,29.840812;118.223064,29.845637;118.222164,29.851389;118.222268,29.855518;118.222468,29.863081;118.221021,29.868386;118.21701,29.875809;118.215833,29.881339;118.213329,29.886206;118.211615,29.891059;118.208003,29.893888;118.203023,29.894681;118.195939,29.895518;118.190095,29.893345;118.184536,29.89209;118.179524,29.891505;118.175861,29.892271;118.171749,29.895799;118.168434,29.899998;118.165144,29.905111;118.16369,29.910185;118.163006,29.914329;118.161327,29.920787;118.159631,29.926326;118.158679,29.930245;118.155882,29.93443;118.152531,29.937024;118.147638,29.941253;118.144529,29.94338;118.140917,29.946435;118.133701,29.952774;118.130417,29.958343;118.129274,29.965244;118.12729,29.970329;118.123329,29.969951;118.119618,29.969105;118.114641,29.970347;118.112318,29.972455;118.109291,29.978016;118.107062,29.983564;118.105623,29.989781;118.106318,29.996192;118.106769,30.00375;118.10811,30.009563;118.108531,30.008968;118.109178,30.008311;118.109344,30.007333;118.10973,30.006088;118.109891,30.004986;118.110756,30.004017;118.111053,30.003873;118.112385,30.003625;118.113201,30.00331;118.114468,30.003174;118.115483,30.002792;118.116507,30.002962;118.117267,30.002918;118.117872,30.003308;118.118565,30.003336;118.119177,30.003096;118.119862,30.002453;118.120169,30.002384;118.121016,30.002476;118.122524,30.002432;118.122942,30.00224;118.125372,30.003608;118.130056,30.004951;118.130406,30.004829;118.130725,30.004595;118.131369,30.003751;118.131859,30.002876;118.132806,30.001695;118.133864,30.000178;118.134351,29.999068;118.135004,29.99823;118.135898,29.997738;118.138036,29.996524;118.140224,29.995642;118.141031,29.995458;118.14367,29.995342;118.145444,29.996028;118.146692,29.996087;118.147286,29.996541;118.148034,29.99772;118.147321,30.000252;118.146702,30.002997;118.146024,30.004546;118.144455,30.006296;118.144155,30.007088;118.14386,30.008472;118.143684,30.010273;118.14376,30.010465;118.143982,30.01057;118.146413,30.010438;118.147252,30.010708;118.148171,30.011555;118.148999,30.012628;118.149549,30.013543;118.15062,30.014795;118.152609,30.016852;118.153595,30.018543;118.154049,30.019588;118.155525,30.021843;118.155832,30.022889;118.15589,30.023637;118.155506,30.025118;118.155804,30.026209;118.15607,30.026564;118.157298,30.026449;118.16401,30.023756;118.165153,30.022759;118.165591,30.023385;118.166759,30.023608;118.168138,30.024235;118.16902,30.024534;118.171262,30.023592;118.172616,30.023259;118.173035,30.022653;118.172747,30.021853;118.172708,30.021416;118.172962,30.020657;118.173194,30.019397;118.172963,30.018564;118.172491,30.018129;118.171922,30.017836;118.171723,30.017581;118.171436,30.016128;118.171013,30.01564;118.170034,30.015374;118.169504,30.014757;118.169303,30.014352;118.169224,30.013882;118.169363,30.013259;118.169302,30.011921;118.169019,30.010671;118.168717,30.008115;118.16875,30.006702;118.169116,30.006462;118.169848,30.006112;118.170779,30.005952;118.171985,30.00611;118.173783,30.006584;118.175184,30.006761;118.176297,30.00614;118.177681,30.006049;118.178167,30.006124;118.178269,30.006414;118.178188,30.007027;118.178396,30.007134;118.179363,30.005881;118.179729,30.005599;118.181811,30.005191;118.183284,30.005132;118.184957,30.005274;118.185585,30.005177;118.186683,30.004106;118.189236,30.002929;118.189675,30.002974;118.190524,30.004083;118.19131,30.004325;118.191918,30.004398;118.192566,30.004199;118.193217,30.003683;118.194508,30.002251;118.195118,30.001944;118.195314,30.001942;118.195438,30.002048;118.19535,30.002783;118.195458,30.00412;118.19614,30.005295;118.196039,30.007053;118.196612,30.00955;118.199273,30.01221;118.200239,30.014654;118.199012,30.016389;118.198634,30.017283;118.19862,30.018022;118.20013,30.019588;118.201248,30.020235;118.202941,30.02092;118.203565,30.021652;118.204121,30.022889;118.204224,30.023316;118.204011,30.023917;118.203516,30.024592;118.203481,30.024823;118.203656,30.025121;118.203977,30.025246;118.204739,30.025259;118.206321,30.025639;118.207892,30.025894;118.208361,30.02613;118.209315,30.026121;118.210017,30.025788;118.212974,30.026421;118.214876,30.027257;118.215846,30.028232;118.216674,30.029616;118.21722,30.031209;118.217244,30.032187;118.216595,30.034457;118.215804,30.035249;118.21363,30.038335;118.213349,30.039155;118.213199,30.039956;118.213263,30.041496;118.213326,30.041955;118.213747,30.042682;118.213556,30.042984;118.212714,30.043713;118.21163,30.044954;118.210524,30.047686;118.208644,30.05048;118.20865,30.050919;118.209029,30.052071;118.208962,30.05265;118.20769,30.055093;118.207553,30.055951;118.208048,30.057958;118.209349,30.058095;118.212027,30.058023;118.2122,30.058086;118.212181,30.058493;118.211723,30.059269;118.211173,30.062478;118.211209,30.063399;118.211841,30.064827;118.211903,30.065918;118.211763,30.066519;118.211815,30.066776;118.212939,30.067236;118.213088,30.067384;118.213875,30.067419;118.214501,30.067323;118.215266,30.066603;118.215387,30.066214;118.216971,30.064941;118.218113,30.064205;118.218629,30.064113;118.21922,30.06415;118.219839,30.064529;118.220314,30.065209;118.220937,30.065867;118.22241,30.0668;118.223569,30.067109;118.224333,30.067187;118.225831,30.067043;118.22685,30.067889;118.227517,30.068075;118.228913,30.068284;118.230573,30.068955;118.230921,30.068911;118.231692,30.068623;118.232729,30.067619;118.234721,30.066907;118.235559,30.067056;118.236338,30.067327;118.237351,30.068006;118.237774,30.068081;118.239481,30.067882;118.240306,30.067904;118.240657,30.068101;118.241113,30.069505;118.241821,30.070586;118.243625,30.072308;118.244603,30.073076;118.244764,30.073307;118.245202,30.074305;118.246277,30.075708;118.246442,30.076256;118.2466,30.077414;118.248113,30.078525;118.248784,30.079136;118.249379,30.080064;118.249908,30.080663;118.250969,30.080969;118.251617,30.081017;118.255869,30.080748;118.256732,30.080984;118.257761,30.081621;118.258244,30.081409;118.260901,30.079791;118.262156,30.079645;118.265883,30.079664;118.266261,30.079188;118.267505,30.078828;118.268517,30.077803;118.268913,30.077494;118.269613,30.07714;118.272534,30.076427;118.272994,30.075808;118.273086,30.075122;118.273232,30.075053;118.273981,30.075396;118.274447,30.075475;118.275503,30.075452;118.279061,30.076099;118.279828,30.075939;118.281116,30.075204;118.281744,30.07441;118.283293,30.073808;118.284139,30.073578;118.284891,30.073557;118.286048,30.073673;118.287119,30.074043;118.287659,30.074324;118.288917,30.074511;118.289843,30.074294;118.291263,30.073754;118.292327,30.073063;118.295207,30.071766;118.295942,30.071677;118.297163,30.071861;118.297563,30.071774;118.298626,30.071074"


      const boundsList = huizhouPoints.split(";\n");

      const polygons = [];

      

      boundsList.forEach((boundary, index) => {

        const bounds = [];

        boundary.split(";").forEach(item => {

          const lonlats = item.split(",");

          if (lonlats.length === 2) {

            bounds.push({

              longitude: Number(lonlats[0]),

              latitude: Number(lonlats[1])

            });

          }

        });

        

        if (bounds.length > 0) {

            polygons.push({

              points: bounds,

              strokeWidth: 3,

              strokeColor: '#5583FF',

              fillColor: 'rgba(85, 131, 255, 0.3)',

              fillOpacity: 0.3,

              zIndex: 1

            });

          }

      });

      

      that.setData({

        polygons: polygons

      });

      // 调整地图视野以显示整个区域

      setTimeout(() => {

        that.includePolygonArea();

      }, 300);

    },

18455111359 扫描二维码