Baidu Map-Search by address latitude and longitude

Source: Internet
Author: User

<HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head>    <title>Query latitude and longitude based on address</title>    <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">    <Scripttype= "Text/javascript"src= "http://api.map.baidu.com/api?v=1.3"></Script></Head><Bodystyle= "background: #CBE1FF">    <Divstyle= "Width:730px;margin:auto;">address to query:<inputID= "Text_"type= "text"value= "Ningbo Tianyi Square"style= "margin-right:100px;"/>query results (latitude and longitude):<inputID= "Result_"type= "text" />        <inputtype= "button"value= "Query"onclick= "Searchbystationname ();"/>        <DivID= "Container"style= "Position:absolute;                 margin-top:30px;                 width:730px;                 height:590px;                 top:50;                border:1px solid Gray; Overflow:hidden; ">        </Div>    </Div></Body><Scripttype= "Text/javascript">    varMap= NewBmap.map ("Container"); Map.centerandzoom ("Ningbo",  A);    Map.enablescrollwheelzoom (); //Enable wheel Zoom out, disabled by defaultMap.enablecontinuouszoom (); //Enable map inertia drag, disabled by defaultMap.addcontrol (NewBmap.navigationcontrol ()); //Add a default zoom translation controlMap.addcontrol (NewBmap.overviewmapcontrol ()); //add default thumbnail map controlMap.addcontrol (NewBmap.overviewmapcontrol ({isOpen:true, anchor:bmap_anchor_bottom_right})); //Lower right corner, open    varLocalsearch= Newbmap.localsearch (map); Localsearch.enableautoviewport (); //allow automatic resizing of forms    functionSearchbystationname () {map.clearoverlays ();//clear the original label    varkeyword=document.getElementById ("Text_"). Value; Localsearch.setsearchcompletecallback (function(SearchResult) {varPOI=Searchresult.getpoi (0); document.getElementById ("Result_"). Value=POI.POINT.LNG+ "," +Poi.point.lat; Map.centerandzoom (Poi.point, -); varMarker= NewBmap.marker (NewBmap.point (POI.POINT.LNG, Poi.point.lat)); //Create a callout that corresponds to the latitude and longitude of the place to be queriedMap.addoverlay (marker); varcontent=document.getElementById ("Text_"). Value+ "<br/><br/> Longitude:" +POI.POINT.LNG+ "<br/> Latitude:" +Poi.point.lat; varInfowindow= NewBmap.infowindow ("<p style= ' font-size:14px; ' >" +content+ "</p>"); Marker.addeventlistener ("Click", function () {  This. Openinfowindow (Infowindow);}); //marker.setanimation (bmap_animation_bounce);//Bounce Animation    }); Localsearch.search (keyword);} </Script></HTML>

Baidu Map-Search by address latitude and longitude

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.