<!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 = ["大连市"];
if (inputValArray[0] != "") {
var url = "http://map.botaisoft.com/apis/";
var districtSearcher = new FMap.DistrictSearch(
new FMap.DistrictSearchOptions(url, function (result) {
var location = [result.getInfoList()[0][1], result.getInfoList()[0][0]];
var marker = new FMap.Marker(location).addTo(map)
map.setView(location)
}, token
));
districtSearcher.searchCenterByRegion(inputValArray[0]);
}
</script>
</body>
</html>