<!DOCTYPE HTML><HTML><Head> <Metaname= "Viewport"content= "initial-scale=1.0, User-scalable=no" /> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <title>12.1</title> <Scripttype= "Text/javascript"> varIscreatr= false; functionInitialize () {varMap= NewBmap.map ("Container", {minzoom: A, Maxzoom: - }); Map.centerandzoom ("Chengdu", -); Map.enablescrollwheelzoom (true); Map.addeventlistener ("Click", function(e) {if(Iscreatr== true) return; //---------------------------------------------Coverings---------------------------------------------Iscreatr= true; var Point= NewBmap.point (E.POINT.LNG, E.point.lat); //Create a callout object and add it to the map varMarker= NewBmap.marker (point); varlable= NewBmap.label ("I can pull it.", {offset:NewBmap.size ( -, -Ten) }); Marker.setlabel (lable); Map.addoverlay (marker); Marker.enabledragging (); //can be dragged and pulledMarker.addeventlistener ("Dragend", function(e) {document.getElementById ("R-result"). InnerHTML=E.POINT.LNG+ "," +E.point.lat;//Print drag end coordinates }); }); } functionLoadscript () {varScript=Document.createelement ("Script"); SCRIPT.SRC= "http://api.map.baidu.com/api?v=1.4&callback=initialize"; Document.body.appendChild (script); } window.onload=Loadscript; </Script></Head><Body> <Divstyle= "float:left; width:100px;">1</Div> <DivID= "Container"style= "width:800px; height:500px"> </Div> <DivID= "R-result"style= "float:left; width:100px;">Print coordinates</Div> <DivID= "Result"> </Div></Body></HTML>
Baidu Map API Advanced Tutorial-click Create and drag callout 4.html