JS section
//Baidu MapBmapfun:function () { varMap =NewBmap.map ("Map"); varPoint =NewBmap.point (116.319764, 40.070091), REPORTP=NewBmap.point (116.311481, 40.072409), n= 1, polyline, RECENTP =false, DataPoints=[REPORTP,//coordinates 1 NewBmap.point (116.313098, 40.072603),//coordinates 2 NewBmap.point (116.315074, 40.069511),//coordinates 3 NewBmap.point (116.317949, 40.06998),//coordinates 4 and so on NewBmap.point (116.325854, 40.073017),//coordinates 4 and so on NewBmap.point (116.311481, 40.072409) ]; Map.centerandzoom (Point,16); Map.addcontrol (NewBmap.navigationcontrol ()); Map.addcontrol (NewBmap.scalecontrol ()); Map.addcontrol (NewBmap.overviewmapcontrol ()); //var marker = new Bmap.marker (point); Create a callout //Map.addoverlay (marker); Add a callout to a mapsetinterval (DrawPolyline,1000) functionDrawPolyline () {if(!!polyline) {Map.removeoverlay (polyline)}if(RECENTP) {Map.removeoverlay (RECENTP)} n= n%datapoints.length console.info (n)if(N > 1) { varPoints = [] for(vari = 0;i < n; i + +) {Points.push (datapoints[i])} polyline=NewBmap.polyline (points, {strokecolor: "#f00", Strokeweight:2, strokeopacity:0.5}); Map.addoverlay (polyline); RECENTP=addpoint ({point:points[n-1], Title:' Where you are now ', DateTime:' January 12, 2014: ' +n+ ' 5 ', before:' 30 seconds ago '}) N++ } Else{n= 2 } } //var polyline = new Bmap.polyline ([ //reportp,//coordinates 1 //New Bmap.point (116.313098, 40.072603),//coordinate 2 //New Bmap.point (116.315074, 40.069511),//coordinate 3 //New Bmap.point (116.317949, 40.06998),//coordinate 4 and so on //New Bmap.point (116.325854, 40.073017),//coordinate 4 and so on //recentp,//coordinates 4 and so on //], {strokecolor: "#f00", Strokeweight:2, strokeopacity:0.5}); //Map.addoverlay (polyline); ////Map.addeventlistener (' click ', Function (e) { ////Console.info (E.point) // // })Addpoint ({POINT:REPORTP, title:' Location of the alarm ', DateTime:' January 12, 2014 14:15 ', before:' 10 minutes ago ', Animation:true }) //Addpoint ({ //POINT:RECENTP, //title: ' Where is now ', //dateTime: ' January 12, 2014 14:45 ', //before: ' 30 seconds ago ' // }) functionAddpoint (data) {varPoint =Data.point//Resolve Address varGC =NewBmap.geocoder (); varMarker =NewBmap.marker (point);//Create a calloutMap.addoverlay (marker);//add a callout to a map if(!!data.animation) {marker.setanimation (bmap_animation_bounce)}//Resolve AddressGc.getlocation (Point,function(RS) {varAddcomp =rs.addresscomponents; varAddress = []; //municipalities do not show provinces, because provinces and municipalities are the same if(Addcomp.province! =addcomp.city) {addcomp.province? Address.push (addcomp.province): ""; } addcomp.city? Address.push (addcomp.city): ""; Addcomp.district? Address.push (addcomp.district): ""; Addcomp.street? Address.push (Addcomp.street): ""; Addcomp.streetnumber? Address.push (Addcomp.streetnumber): ""; Address= Address.join (","); vartitle = "Coordinates:" + point.lng + "," +Point.lat; varContent = []; Content.push ("<p style= ' margin:0; ' > "+ title +" </p> "); Content.push ("<p style= ' margin:0; ' > Location: "+ address +" </p> "); //Content.push ("<p style= ' margin:0; > Start time: "+ start_time +" </p> "); //Content.push ("<p style= ' margin:0; > Last time: "+ end_time +" </p> ");Content.push ("<p style= ' margin:0; > Time: "+ data.datetime + ' (' + Data.before + ') ' +" </p> "); Content= Content.join (""); //Add callout Information varopts = {width:250, enablemessage:false, title: ' <p class= ' map-info ' > ' + data.title + ' </p> '}; varInfo_window =NewBmap.infowindow (content, opts); Marker.infowindow=Info_window; Marker.openinfowindow (Info_window) Marker.addeventlistener ("Click",function() { This. Openinfowindow (Info_window); }); }); returnmarker; } }
CSS Section
{height: 580px;} { color: red; Margin-top: -5px; margin-bottom: 7px; font-weight: bold; font-size: 1.2em;}
Use Baidu Map to do geo-tracking