How Web development uses the high-D map API (ii) to combine input hints and poi search plugins

Source: Internet
Author: User

Say two words:

    • In addition to the sections I wrote myself, the other parts are available on the Gold open platform (click outside the link).
    • The content I have compiled is based on practical projects and hopefully more targeted and streamlined.

Preparatory work:

    • First, register the developer account to become the open platform developer
    • After logging in, go to "Create new app" on the "app management" page
    • Add key,"service platform for your app" select "web (JSAPI) "

After getting the key, introduce the Gold API and UI component library and related CSS files on the page

    • <link rel= "stylesheet" href= "Http://cache.amap.com/lbs/static/main1119.css"/>
    • <script src= "Http://cache.amap.com/lbs/static/es5.min.js" ></script>
    • <script src= "Http://webapi.amap.com/maps?v=1.4.3&key=3853mark's key doesn't tell you 138eacc13d55806d&plugin= Amap.placesearch,amap.advancedinfowindow "></script>
    • <script src= "//webapi.amap.com/ui/1.0/main.js?v=1.0.11" ></script>

Displays the HTML and JS used by the underlying map

<body>
<div id= "Container" ></div>
</body>
<script type= "Text/javascript" >
var map = new Amap.map (' container ', {
Resizeenable:true,
Zoom:11,
Center: [116.397428, 39.90923]//default Map center by latitude
});
</script>

Introduction of the German Map toolkit js file

    • <script type= "Text/javascript" src= "Https://cache.amap.com/lbs/static/addToolbar.js" ></script>

Write the HTML tags required for input prompts

    • is to include an ID unique input box in <body> for the binding of the cue box
<div>
<input id= "Tipinput" class= "Form-control input-style" placeholder= "Please enter the keyword" value= "/>
</div>

Enter the JS used by the cue and POI search plugin

Amap.plugin ([' Amap.autocomplete ', ' Amap.placesearch '],function ()} {
var autooptions = {
City: "Beijing",//cities, default national
Input: "keyword"//ID of input using Lenovo (that is, the unique ID above)
};
autocomplete= new Amap.autocomplete (autooptions);
var placesearch = new Amap.placesearch ({
City: ' Beijing ',
Map:map
})
AMap.event.addListener (AutoComplete, "select", Function (e) {
TODO implements its own functionality for the selected POI
Placesearch.setcity (E.poi.adcode);
Placesearch.search (E.poi.name)
});
});

...

Tips

    • You may find that the browser defaults to your search history, which is displayed below the search box, which affects the input prompts.
    • Therefore, you need to set the property autocomplete= "off" in input

How Web development uses the high-D map API (ii) to combine input hints and poi search plugins

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.