Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (55 sloc) 3.28 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Get Search Boundary</title>
<style>html,body{height:100%;}body{padding:0;margin:0;}h1{padding:0;margin:0;font-size:50%;}</style>
</head>
<body>
<!-- MAP[START] -->
<h1>Get Search Boundary</h1>
<input type="text" id="searchBox" value="New York City"><button id="search">Search</button>
<div id="myMap" style='width:60%;height:70%;float:left;'></div>
<!-- MAP[END] -->
<script src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[ *** YOUR MY KEY *** ]' async defer></script>
<script src="../js/BmapQuery.js"></script>
<script>
//****************************************************************************************
// BingMaps&BmapQuery
//****************************************************************************************
//Init
function GetMap(){
//------------------------------------------------------------------------
//1. Instance
//------------------------------------------------------------------------
const map = new Bmap("#myMap");
//------------------------------------------------------------------------
//2. Display Map
//------------------------------------------------------------------------
map.startMap(47.6149, -122.1941, "load", 9); //The place is Bellevue.
//----------------------------------------------------
//3.Get Search Boundary
// map.getSearchBoundary("area", "type");
//----------------------------------------------------
// [ "type" ]
// *CountryRegion: Country or region.
// *AdminDivision1: First administrative level within the country/region level, such as a state or a province.
// *AdminDivision2: Second administrative level within the country/region level, such as a county.
// *PopulatedPlace: A concentrated area of human settlement, such as a city, town or village.
// *Neighborhood: A section of a populated place that is typically well-known, but often with indistinct boundaries.
// *Postcode1: The smallest post code category, such as a zip code.
// *Postcode2: The next largest post code category after Postcode1 that is created by aggregating Postcode1 areas.
// *Postcode3: The next largest post code category after Postcode2 that is created by aggregating Postcode2 areas.
// *Postcode4: The next largest post code category after Postcode3 that is created by aggregating Postcode3 areas.
// Note: Not all entity types are available in all areas.
//---------------------------------------------------
document.getElementById("search").onclick=function(){
//text value.
const searchBox = document.getElementById("searchBox").value;
//BingMaps Serch
map.getSearchBoundary(searchBox, 'PopulatedPlace');
}
}
</script>
</body>
</html>