JS call Baidu Map of the method
The code is as follows:
JS Call Baidu Map Search
Quote Baidu JS Api
<script type= "Text/javascript" src= "http://api.map.baidu.com/api?v=2.0&ak=xxxxxxxxxxxx" ></script >
To create an address resolver:
var localsearch = null;
Query parameters
var options = {/
/intelligent Search
onsearchcomplete:function (results) {
//query result status code
if ( Localsearch.getstatus () = = bmap_status_success) {
var s = convertmapsearch (results);//To process
the results Model.locationaddress (s); Assigns the resulting data to an array of knockout objects (which can be replaced by other array objects)}}
;
Localsearch = new Bmap.localsearch ("City", options);
Combining the TextInput binding method of knockout and the subscribe attribute of object, the real-time query function of input box is realized.
Binding
<input id= "txtaddress" type= "text" placeholder= "Please enter dining address" data-bind= "textinput:addressinput"/>
/ The/subscribe property executes the address query
sf.addressInput.subscribe (function (val) {
var addr = $.trim (val)
when the input changes. if (addr = = "") {return
;
}
Localsearch.search (addr);
});
The above is a small part of the cloud habitat community to share the JS call Baidu Map and call Baidu Map search function, about more about Baidu map related content, please continue to pay attention to this site, there is no new content updates.