-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocation.js
43 lines (37 loc) · 1.1 KB
/
location.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Search result of locations
*/
var locations;
function searchLocation(){
const placeSearch = new AMap.PlaceSearch({
city: $('#l_city').val(),
pageSize: 50, //单页显示结果条数
pageIndex: 1, //页码
});
placeSearch.search($('#l_keyword').val(),function(status,result){
if(status!="complete"){
$.toast({class:"error",message:"搜索失败:"+status});
return;
}
locations=result.poiList.pois;
$('#l_result').html('');
result.poiList.pois.forEach((poi,index) => {
const template=`
<button class="ui primary tertiary button" onclick="addLocation(${index})">${poi.id} ${poi.name} ${poi.address}</button> <br/>
`
$('#l_result').append(template);
});
});
}
function addLocation(index){
const data=locations[index];
addRoute2({
start_station: data.name,
end_station: data.name,
via: "步行",
color: "888888",
passes: [],
polyline: [data.location]
});
$('#add_location').modal('hide');
}