JS call Baidu Map and call Baidu Map search function _javascript Skills

Source: Internet
Author: User

JS call Baidu Map of the method

The code is as follows:

<! DOCTYPE html>  

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.