当前位置:网站首页>[Gaode map POI stepping pit] amap Placesearch cannot be used
[Gaode map POI stepping pit] amap Placesearch cannot be used
2022-07-05 06:27:00 【Heerey525】
situation
Recently, we need to use the search function of Gaode map
step
apply key
On the open platform of Gaode map Register an account and apply Key, obtain key And security keys
Find case
Find the function in the document Input prompt and POI Search for
Get into demo
Choose the function I need Query after prompt , Found that it met my expectations .
Run locally demo
Directly replace the previous step demo Copy , Run locally .
It should also be noted that you need to bring the security key with you for later use .

<script type="text/javascript">
window._AMapSecurityConfig = {
securityJsCode:' Your security key ',
}
</script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key= You applied for key"></script>
Search without prompt
Directly copied code , add key And security keys , Search can't prompt the address .
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title> Query after prompt </title>
<link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
</head>
<body>
<div id="container"></div>
<div id="myPageTop">
<table>
<tr>
<td>
<label> Please enter keywords :</label>
</td>
</tr>
<tr>
<td>
<input id="tipinput"/>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
window._AMapSecurityConfig = {
securityJsCode:' Your security key ',
}
</script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key= You applied for key"></script>
<script type="text/javascript">
// Map loading
var map = new AMap.Map("container", {
resizeEnable: true
});
// Input prompt
var autoOptions = {
input: "tipinput"
};
AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], function(){
var auto = new AMap.AutoComplete(autoOptions);
var placeSearch = new AMap.PlaceSearch({
map: map
}); // Construct location query class
auto.on("select", select);// Register to listen , When a record is selected, it will trigger
function select(e) {
placeSearch.setCity(e.poi.adcode);
placeSearch.search(e.poi.name); // Keyword query
}
});
</script>
</body>
</html>
Baidu search is fruitless
Baidu search a circle
It is said that plug-ins will be used from AMap.plugin Changed to: AMap.service, It doesn't work
It is said that plug-ins will be used from AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], function(){}) Changed to: Synchronization mode <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key= You applied for key&plugin=AMap.PlaceSearch,AMap.AutoComplete"></script>, It doesn't work
There are other articles that don't work
You have to look for it from official documents

?, This sentence was directly ignored by me at the beginning , Is it a version problem , Look back at the https://webapi.amap.com/maps?v=1.4.15, Turned out to be 1.4.15 ???, Then I put the code AutoComplete Change to Autocomplete, wow , success !!!
reflection
In the future, take the official demo Just take the whole , Don't paste from other blog posts !
边栏推荐
- ollvm编译出现的问题纪录
- Basic explanation of typescript
- RecyclerView的应用
- 5.Oracle-表空间
- 阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
- MySQL advanced part 2: MySQL architecture
- Sum of three terms (construction)
- Game theory acwing 892 Steps Nim game
- 1.13 - RISC/CISC
- Suppose a bank's ATM machine, which allows users to deposit and withdraw money. Now there is 200 yuan in an account, and both user a and user B have the right to deposit and withdraw money from this a
猜你喜欢

NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar

Operator priority, one catch, no doubt

Redis-01.初识Redis

Chinese remainder theorem acwing 204 Strange way of expressing integers

Stack acwing 3302 Expression evaluation

Game theory acwing 893 Set Nim game

博弈论 AcWing 894. 拆分-Nim游戏

Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software

Design specification for mobile folding screen

5.Oracle-錶空間
随机推荐
Nested method, calculation attribute is not applicable, use methods
LeetCode 0107. Sequence traversal of binary tree II - another method
Leetcode recursion
Quickly use Amazon memorydb and build your own redis memory database
4. Object mapping Mapster
One question per day 1020 Number of enclaves
Redis-01.初识Redis
2.Oracle-数据文件的添加及管理
1.15 - input and output system
FFmpeg build下载(包含old version)
5. Oracle TABLESPACE
C job interview - casting and comparing - C job interview - casting and comparing
3. Oracle control file management
How to generate an image from text on fly at runtime
Leetcode backtracking method
Interval problem acwing 906 Interval grouping
Leetcode-1200: minimum absolute difference
Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
2022-5-the fourth week daily
Chinese remainder theorem acwing 204 Strange way of expressing integers