<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>由区划编码检索地理范围</title>
<link rel="stylesheet" href="https://map.botaisoft.com/js/doc/lib/fmap.css">
<script src="https://map.botaisoft.com/js/doc/lib/fmap.js"></script>
<style>
body, html,#map {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
</style>
</head>
<body>
<div id="map"></div>
<script>
var token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJGQU5HaTIyR0VOeUhsTTJCZ211bEhpRGhtR2pFYmFLYyIsInVzZXIiOiJndWVzdCJ9.CJ9JuWCxrx4U40K%2FHoBcgqP%2Bgn%2BWqXE9io6eCxi6g9g%3D"
var layer = FMap.tileLayer('http://map.botaisoft.com/apis/v1/rastertiles/mix_map/{z}/{x}/{y}.png?token=' + token);
var map = new FMap.Map('map', {
center: new FMap.LatLng(38.92705, 121.6580833),
zoom: 13,
maxZoom: 17,
minZoom: 3,
layers: [layer]
});
var inputValArray = [210200];
if (inputValArray[0] != "") {
var url = "http://map.botaisoft.com/apis/";
var districtSearcher = new FMap.DistrictSearch(
new FMap.DistrictSearchOptions(url, function (result) {
var _geoJson = result.geoJson.geometry.coordinates, levelsDeep;
if (_geoJson[0][0][0][0] instanceof Array) {
levelsDeep = 3;
} else if (_geoJson[0][0][0] instanceof Array) {
levelsDeep = 2;
} else if (_geoJson[0][0] instanceof Array) {
levelsDeep = 1;
}
var latlngs = FMap.GeoJSON.coordsToLatLngs(_geoJson, levelsDeep);
var polyline = FMap.polyline(latlngs, {
color: "#1969e1",
dashArray: '5, 5',
weight: '2'
}).addTo(map);
map.fitBounds(polyline.getBounds());
}, token
));
districtSearcher.searchBoundaryByRegion(parseInt(inputValArray[0]));
}
</script>
</body>
</html>