当前位置:网站首页>[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 !
边栏推荐
- Modnet matting model reproduction
- LeetCode-54
- Regulations for network security events of vocational group in 2022 Guizhou Vocational College skill competition
- 11-gorm-v2-03-basic query
- 5.Oracle-表空间
- [wustctf2020] plain_ WP
- 求组合数 AcWing 889. 满足条件的01序列
- Sword finger offer II 058: schedule
- 4. Oracle redo log file management
- 20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
猜你喜欢
SQL三种连接:内连接、外连接、交叉连接
‘mongoexport‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
7.Oracle-表结构
背包问题 AcWing 9. 分组背包问题
Series of how MySQL works (VIII) 14 figures explain the atomicity of MySQL transactions and the principle of undo logging
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
Leetcode array operation
中国剩余定理 AcWing 204. 表达整数的奇怪方式
容斥原理 AcWing 890. 能被整除的数
随机推荐
【LeetCode】Easy | 20. Valid parentheses
There are three kinds of SQL connections: internal connection, external connection and cross connection
Leetcode divide and conquer / dichotomy
What is socket? Basic introduction to socket
MySQL advanced part 2: MySQL architecture
P2575 master fight
Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
[wustctf2020] plain_ WP
confidential! Netease employee data analysis internal training course, white whoring! (attach a data package worth 399 yuan)
Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
What's wrong with this paragraph that doesn't work? (unresolved)
LeetCode 1200. Minimum absolute difference
Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
Game theory acwing 894 Split Nim game
Leetcode-6108: decrypt messages
ADG5412FBRUZ-RL7应用 双电源模拟开关和多路复用器IC
MQClientException: No route info of this topic: type_ topic
Relevant information of National Natural Science Foundation of China
中国剩余定理 AcWing 204. 表达整数的奇怪方式