Baidu Map API--Location Location

Source: Internet
Author: User

jquery Environment <script src= "http://api.map.baidu.com/api?v=1.5&ak=1b0ace7dde0245f796844a06fb112734" >< /script><form action= "" id= "Comform" name= "Comform" method= "POST" onsubmit= "return Checkform ();" ><input type= "hidden" name= "usertype" value= "2"/><fieldset><legend>&nbsp; Add Branch/Store & Nbsp;</legend><tableclass= "Depttable" style= "width:90%; margin:0 auto; " > <tr> &LT;TDclass= "Label" ><label> owned Enterprise <b><sup>*</sup></b></label></td> <td> <input type= "text" id= "Comname" name= "Comname" style= "width:260px;" value= "<?php Echo$comname?> "Disabled></td> </tr> <tr> &LT;TDclass= "Label" ><label> Branch/Store name <b><sup>*</sup></b></label></td> <td> <input type= "text" id= "Shopname" name= "Comname" style= "width:260px;" ></td> </tr> <tr> &LT;TDclass= "Label" ><label> contacts <b><sup>*</sup></b></label></td> <td>< Input type= "text" id= "Realname" name= "Realname" style= "width:160px;" ></td> </tr> <tr> &LT;TDclass= "label" ><label> phone number <b><sup>*</sup></b></label></td> <td>< Input type= "text" id= "mobile" name= "mobile" style= "width:160px;" ></td> </tr> <tr> &LT;TDclass= "Label" ><label> contact qq</label></td> <td><input type= "text" id= "QQ" Name= "QQ" style= " width:160px; " ></td> </tr> <tr> &LT;TDclass= "Label" ><label>e-Mail</label></td> <td><input type= "text" id= "email" name= "email" style= "width:160px;" ></td> </tr> <tr> &LT;TDclass= "Label" ><label> Group </label></td> <td><select name= "classid" id = ' classid ' style= ' width : 164px; " ><option value= "0" > select group </option><?phpEcho $option _html;? ></select></td> </tr> <tr> &LT;TDclass= "Label" ><label> business address </label></td> <td> <select id= "s_province" Name= "S_pro Vinceclass= "area" > </select>&nbsp;&nbsp; <select id= "s_city" name= "s_city"class= "area" > </select>&nbsp;&nbsp; <select id= "S_county" name= "S_county"class= "area" > </select> <script type= "Text/javascript" >_init_area ();</script> <input type= "text" name= "address" id = ' address ' style= "width:260px;" ><input type = ' button ' name = ' search ' id = ' locate-btn ' value = ' position ' > <br/> enter address, click ' Auto Position ' button to map On the location. <br/>(If you can't locate after entering an address, click on the map to select a location)<divclass= "Control-group" > <div id= "Map" style= "width:600px;height:300px;" ></div> </div>
<!--where the map is displayed, feel free---</td> </tr> <tr> &LT;TDclass= "Label" ><label> other </label></td> <td> open: <input type= "Radio" id= "Issh" name= "Issh" Value= "1" checked> is <input type= "Radio" id= "Issh" name= "issh" value= "0" > No </td> </tr> <tr> <tdclass= "Label" ><label></label></td> <td><input type= "button" id = ' btn ' value= "OK Add" style= " width:80px;height:30px; " ></td> </tr></table> <input type= "hidden" value= "116.403694" name= "WVYVMQLQ" id= "LBSJD" > <input type= "hidden" value= "39.916042" name= "Wvyvmrrq" id= "lbswd" ></fieldset></form><!-- Page function Description--><div style= "Margin:20px;line-height:200%;color:green;" > <p> page Name: Edit Store </p> <p>controllers file:csuser.php</p> <p>views folder:user</p> <p> page File:addcomshop.php</p> <p> operation Rights: Enterprise Administrator, store manager (associated Health Division) </p> <p> corresponding data sheet:jk_comshop< /p> <p> Function Point description: 1, grouping from the data table Jk_sysclass lists the group of the enterprise stores. 2. After submitting the data, three data sheets need to be updated: Jk_sysclass infonum (plus 1), Jk_comshop;jk_comuser shopnum plus 1</p></div><!--End---& Lt;script>varlocated =true; //positioning coordinates varDestpoint =NewBmap.point ($ (' #lbsjd '). Val (), $ (' #lbswd ').Val ()); Two hidden domains were written to store the initial location of the location $ (function(){ /** Start processing Baidu map **/ varMap =NewBmap.map ("Map"); Map. Centerandzoom (NewBmap.point (DESTPOINT.LNG, Destpoint.lat), 12);//Initialize MapMap.Enablescrollwheelzoom (); Map. AddControl (NewBMap.Navigationcontrol ()); varMarker =NewBMap.Marker (Destpoint); Map. Addoverlay (marker);//Add a calloutMap. AddEventListener ("click",function(e) {if(Confirm ("Confirm to select this location?") ") ) {Destpoint= e.Point ; $(' #lbsjd '). Val (destpoint.LNG); $(' #lbswd '). Val (destpoint.lat); Map.clearoverlays (); varMarker1 =NewBmap.marker (Destpoint);//Create a calloutMap.Addoverlay (Marker1); } }); varmyvalue; varLocal; functionSetplace () {map. Clearoverlays ();//clear all overlays on the mapLocal =NewBmap.localsearch (map, {//Smart Searchrenderoptions:{Map:Map}}); Located=true; Local. Setmarkerssetcallback (Callback); Local.search (myvalue); } functionAddEventListener (marker) {marker. AddEventListener ("click",function(data) {Destpoint= Data.target.getPosition (0); }); } function Callback(posi) {$ ("#locate-btn"). Removeattr ("Disabled")); for(vari=0;i<posi.length;i++){ if(i==0) {Destpoint= Posi[0].Point ; } Posi[i]. Marker.addeventlistener ("click",function(data) {Destpoint= Data.target.getPosition (0); }); } } $("#s_province"). Change (function(){ $("#locate-btn"). attr ("Disabled", "disabled"); Local=NewBmap.localsearch (map, {//Smart Searchrenderoptions:{Map:Map}}); Located=true; Local. Setmarkerssetcallback (Callback); Local. Search ($ ("#s_province"). Find (' option:selected ').text ()); return false; }); $("#s_city"). Change (function(){ $("#locate-btn"). attr ("Disabled", "disabled"); Local=NewBmap.localsearch (map, {//Smart Searchrenderoptions:{Map:Map}}); Located=true; Local. Setmarkerssetcallback (Callback); Local. Search ($ ("#s_city"). Find (' option:selected ').text ()); return false; });
The drop-down box is changed to reposition $ with a changed value ("#s_county"). Change (function(){ $("#locate-btn"). attr ("Disabled", "disabled"); Local=NewBmap.localsearch (map, {//Smart Searchrenderoptions:{Map:Map}}); Located=true; Local. Setmarkerssetcallback (Callback); Local. Search ($ ("#s_county"). Find (' option:selected ').text ()); return false; });
When clicked, fetch the value of the Address text box to find $ ("#locate-btn"). Click (function(){ if($ ("#address"). val () = = "") {alert ("Please address!" "); return ; } $("#locate-btn"). attr ("Disabled", "disabled"); Local=NewBmap.localsearch (map, {//Smart Searchrenderoptions:{Map:Map}}); Located=true; Local. Setmarkerssetcallback (Callback); Local. Search ($ ("#address").Val ());//Search geolocation for locationreturn false; }); }) </script>

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.