Home Web Front-end JS Tutorial Image rotation, mouse wheel zoom, mirroring, image switching js code_javascript skills

Image rotation, mouse wheel zoom, mirroring, image switching js code_javascript skills

May 16, 2016 pm 03:19 PM
js Picture rotation mirror

本文实例为大家展示了图片旋转、鼠标滚轮缩放、镜像、切换图片多重效果,提供了详细的代码,分享给大家供大家参考,具体内容如下

具体代码:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

<!DOCTYPE html>

<html lang="zh-cn">

 <head>

  <title>图片旋转,鼠标滚轮缩放,镜像,切换图片</title>

  <meta charset="utf-8" />

  <!--<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>-->

  <script type="text/javascript" src="js/abc.js"></script>

 </head>

 

 <body>

 

  <h1 style="text-align: center;color: blue;">效果预览</h1>

  <script>

   //容器对象

   var ImageTrans = function(container, options) {

    this._initialize(container, options);

    this._initMode();

    if (this._support) {

     this._initContainer();

     this._init();

    } else { //模式不支持

     this.onError("not support");

    }

   };

   ImageTrans.prototype = {

    //初始化程序

    _initialize: function(container, options) {

     var container = this._container = $$(container);

  this._clientWidth = container.clientWidth; //变换区域宽度

  this._clientHeight = container.clientHeight; //变换区域高度

  this._img = new Image(); //图片对象

  this._style = {}; //备份样式

  this._x = this._y = 1; //水平/垂直变换参数

  this._radian = 0; //旋转变换参数

  this._support = false; //是否支持变换

  this._init = this._load = this._show = this._dispose = $$.emptyFunction;

     var opt = this._setOptions(options);

     this._zoom = opt.zoom;

     this.onPreLoad = opt.onPreLoad;

     this.onLoad = opt.onLoad;

     this.onError = opt.onError;

     this._LOAD = $$F.bind(function() {

  this.onLoad();

  this._load();

  this.reset();

  this._img.style.visibility = "visible";

  }, this);

  $$CE.fireEvent(this, "init");

    },

    //设置默认属性

    _setOptions: function(options) {

     this.options = { //默认值

      mode: "css3|filter|canvas",

      zoom: .1, //缩放比率

      onPreLoad: function() {}, //图片加载前执行

      onLoad: function() {}, //图片加载后执行

      onError: function(err) {} //出错时执行

     };

     return $$.extend(this.options, options || {});

 },

 //模式设置

 _initMode: function() {

  var modes = ImageTrans.modes;

  this._support = $$A.some(this.options.mode.toLowerCase().split("|"), function(mode) {

  mode = modes[mode];

  if (mode && mode.support) {

  mode.init && (this._init = mode.init); //初始化执行程序

  mode.load && (this._load = mode.load); //加载图片执行程序

  mode.show && (this._show = mode.show); //变换显示程序

  mode.dispose && (this._dispose = mode.dispose); //销毁程序

  //扩展变换方法

  $$A.forEach(ImageTrans.transforms, function(transform, name) {

  this[name] = function() {

   transform.apply(this, [].slice.call(arguments));

   this._show();

  }

  }, this);

  return true;

  }

  }, this);

 },

 //初始化容器对象

 _initContainer: function() {

  var container = this._container,

  style = container.style,

  position = $$D.getStyle(container, "position");

  this._style = {

  "position": style.position,

  "overflow": style.overflow

  }; //备份样式

  if (position != "relative" && position != "absolute") {

  style.position = "relative";

  }

  style.overflow = "hidden";

  $$CE.fireEvent(this, "initContainer");

 },

 //加载图片

 load: function(src) {

  if (this._support) {

  var img = this._img,

  oThis = this;

  img.onload || (img.onload = this._LOAD);

  img.onerror || (img.onerror = function() {

  oThis.onError("err image");

  });

  img.style.visibility = "hidden";

  this.onPreLoad();

  img.src = src;

  }

 },

 //重置

 reset: function() {

  if (this._support) {

  this._x = this._y = 1;

  this._radian = 0;

  this._show();

  }

 },

 //销毁程序

 dispose: function() {

  if (this._support) {

  this._dispose();

  $$CE.fireEvent(this, "dispose");

  $$D.setStyle(this._container, this._style); //恢复样式

  this._container = this._img = this._img.onload = this._img.onerror = this._LOAD = null;

  }

 }

 };

 //变换模式

 ImageTrans.modes = function() {

 var css3Transform; //ccs3变换样式

 //初始化图片对象函数

 function initImg(img, container) {

  $$D.setStyle(img, {

  position: "absolute",

  border: 0,

  padding: 0,

  margin: 0,

  width: "auto",

  height: "auto", //重置样式

  visibility: "hidden" //加载前隐藏

  });

  container.appendChild(img);

 }

 //获取变换参数函数

 function getMatrix(radian, x, y) {

  var Cos = Math.cos(radian),

  Sin = Math.sin(radian);

  return {

  M11: Cos * x,

  M12: -Sin * y,

  M21: Sin * x,

  M22: Cos * y

  };

 }

 return {

  css3: { //css3设置

  support: function() {

  var style = document.createElement("div").style;

  return $$A.some(

  ["transform", "MozTransform", "webkitTransform", "OTransform"],

  function(css) {

   if (css in style) {

   css3Transform = css;

   return true;

   }

  });

  }(),

  init: function() {

  initImg(this._img, this._container);

  },

  load: function() {

  var img = this._img;

  $$D.setStyle(img, { //居中

  top: (this._clientHeight - img.height) / 2 + "px",

  left: (this._clientWidth - img.width) / 2 + "px",

  visibility: "visible"

  });

  },

  show: function() {

  var matrix = getMatrix(this._radian, this._y, this._x);

  //设置变形样式

  this._img.style[css3Transform] = "matrix(" + matrix.M11.toFixed(16) + "," + matrix.M21.toFixed(16) + "," + matrix.M12.toFixed(16) + "," + matrix.M22.toFixed(16) + ", 0, 0)";

  },

  dispose: function() {

  this._container.removeChild(this._img);

  }

  },

  filter: { //滤镜设置

  support: function() {

  return "filters" in document.createElement("div");

  }(),

  init: function() {

  initImg(this._img, this._container);

  //设置滤镜

  this._img.style.filter = "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand')";

  },

  load: function() {

  this._img.onload = null; //防止ie重复加载gif的bug

  this._img.style.visibility = "visible";

  },

  show: function() {

  var img = this._img;

  //设置滤镜

  $$.extend(

  img.filters.item("DXImageTransform.Microsoft.Matrix"),

  getMatrix(this._radian, this._y, this._x)

  );

  //保持居中

  img.style.top = (this._clientHeight - img.offsetHeight) / 2 + "px";

  img.style.left = (this._clientWidth - img.offsetWidth) / 2 + "px";

  },

  dispose: function() {

  this._container.removeChild(this._img);

  }

  },

  canvas: { //canvas设置

  support: function() {

  return "getContext" in document.createElement('canvas');

  }(),

  init: function() {

  var canvas = this._canvas = document.createElement('canvas'),

  context = this._context = canvas.getContext('2d');

  //样式设置

  $$D.setStyle(canvas, {

  position: "absolute",

  left: 0,

  top: 0

  });

  canvas.width = this._clientWidth;

  canvas.height = this._clientHeight;

  this._container.appendChild(canvas);

  },

  show: function() {

  var img = this._img,

  context = this._context,

  clientWidth = this._clientWidth,

  clientHeight = this._clientHeight;

  //canvas变换

  context.save();

  context.clearRect(0, 0, clientWidth, clientHeight); //清空内容

  context.translate(clientWidth / 2, clientHeight / 2); //中心坐标

  context.rotate(this._radian); //旋转

  context.scale(this._y, this._x); //缩放

  context.drawImage(img, -img.width / 2, -img.height / 2); //居中画图

  context.restore();

  },

  dispose: function() {

  this._container.removeChild(this._canvas);

  this._canvas = this._context = null;

  }

  }

 };

 }();

 //变换方法

 ImageTrans.transforms = {

 //垂直翻转

 vertical: function() {

  this._radian = Math.PI - this._radian;

  this._y *= -1;

 },

 //水平翻转

 horizontal: function() {

  this._radian = Math.PI - this._radian;

  this._x *= -1;

 },

 //根据弧度旋转

 rotate: function(radian) {

  this._radian = radian;

 },

 //向左转90度

 left: function() {

  this._radian -= Math.PI / 2;

 },

 //向右转90度

 right: function() {

  this._radian += Math.PI / 2;

 },

 //根据角度旋转

 rotatebydegress: function(degress) {

  this._radian = degress * Math.PI / 180;

 },

 //缩放

 scale: function() {

  function getZoom(scale, zoom) {

  return scale > 0 && scale > -zoom &#63; zoom :

  scale < 0 && scale < zoom &#63; -zoom : 0;

  }

  return function(zoom) {

  if (zoom) {

  var hZoom = getZoom(this._y, zoom),

  vZoom = getZoom(this._x, zoom);

  if (hZoom && vZoom) {

  this._y += hZoom;

  this._x += vZoom;

  }

  }

  }

 }(),

 //放大

 zoomin: function() {

  this.scale(Math.abs(this._zoom));

 },

 //缩小

 zoomout: function() {

  this.scale(-Math.abs(this._zoom));

 }

 };

 //拖动旋转

 ImageTrans.prototype._initialize = (function() {

 var init = ImageTrans.prototype._initialize,

  methods = {

  "init": function() {

  this._mrX = this._mrY = this._mrRadian = 0;

  this._mrSTART = $$F.bind(start, this);

  this._mrMOVE = $$F.bind(move, this);

  this._mrSTOP = $$F.bind(stop, this);

  },

  "initContainer": function() {

  $$E.addEvent(this._container, "mousedown", this._mrSTART);

  },

  "dispose": function() {

  $$E.removeEvent(this._container, "mousedown", this._mrSTART);

  this._mrSTOP();

  this._mrSTART = this._mrMOVE = this._mrSTOP = null;

  }

  };

 //开始函数

 function start(e) {

  var rect = $$D.clientRect(this._container);

  this._mrX = rect.left + this._clientWidth / 2;

  this._mrY = rect.top + this._clientHeight / 2;

  this._mrRadian = Math.atan2(e.clientY - this._mrY, e.clientX - this._mrX) - this._radian;

  $$E.addEvent(document, "mousemove", this._mrMOVE);

  $$E.addEvent(document, "mouseup", this._mrSTOP);

  if ($$B.ie) {

  var container = this._container;

  $$E.addEvent(container, "losecapture", this._mrSTOP);

  container.setCapture();

  } else {

  $$E.addEvent(window, "blur", this._mrSTOP);

  e.preventDefault();

  }

 };

 //拖动函数

 function move(e) {

  this.rotate(Math.atan2(e.clientY - this._mrY, e.clientX - this._mrX) - this._mrRadian);

  window.getSelection &#63; window.getSelection().removeAllRanges() : document.selection.empty();

 };

 //停止函数

 function stop() {

  $$E.removeEvent(document, "mousemove", this._mrMOVE);

  $$E.removeEvent(document, "mouseup", this._mrSTOP);

  if ($$B.ie) {

  var container = this._container;

  $$E.removeEvent(container, "losecapture", this._mrSTOP);

  container.releaseCapture();

  } else {

  $$E.removeEvent(window, "blur", this._mrSTOP);

  };

 };

 return function() {

  var options = arguments[1];

  if (!options || options.mouseRotate !== false) {

  //扩展钩子

  $$A.forEach(methods, function(method, name) {

  $$CE.addEvent(this, name, method);

  }, this);

  }

  init.apply(this, arguments);

 }

 })();

 //滚轮缩放

 ImageTrans.prototype._initialize = (function() {

 var init = ImageTrans.prototype._initialize,

  mousewheel = $$B.firefox &#63; "DOMMouseScroll" : "mousewheel",

  methods = {

  "init": function() {

  this._mzZoom = $$F.bind(zoom, this);

  },

  "initContainer": function() {

  $$E.addEvent(this._container, mousewheel, this._mzZoom);

  },

  "dispose": function() {

  $$E.removeEvent(this._container, mousewheel, this._mzZoom);

  this._mzZoom = null;

  }

  };

 //缩放函数

 function zoom(e) {

  this.scale((

  e.wheelDelta &#63; e.wheelDelta / (-120) : (e.detail || 0) / 3

  ) * Math.abs(this._zoom));

  e.preventDefault();

 };

 return function() {

  var options = arguments[1];

  if (!options || options.mouseZoom !== false) {

  //扩展钩子

  $$A.forEach(methods, function(method, name) {

  $$CE.addEvent(this, name, method);

      }, this);

     }

     init.apply(this, arguments);

    }

   })();

  </script>

  <style>

   #idContainer {

    border: 1px solid red;

    width: 1000px;

    height: 500px;

    background: black center no-repeat;

    margin: 0 auto;

   }

 

   input {

    margin: 10px;

    padding: 10px;

    border: 1px solid red;

    background: yellow;

    color: green;

    font-size: 16px;

   }

 

   #idSrc {

    width: auto;

   }

  </style>

 

  <div id="idContainer"></div>

  <input id="idLeft" value="向左旋转" type="button" />

  <input id="idRight" value="向右旋转" type="button" />

  <input id="idVertical" value="垂直翻转" type="button" />

  <input id="idHorizontal" value="水平翻转" type="button" />

  <input id="idReset" value="重置" type="button" />

  <input id="idCanvas" value="使用Canvas" type="button" />

  <input id="idSrc" value="img/07.jpg" type="text" />

  <input id="idLoad" value="换图" type="button" />

  <script>

   (function() {

    var container = $$("idContainer"),

  src = "img/7.jpg",

  options = {

  onPreLoad: function() {

  container.style.backgroundImage = "url('http://images.cnblogs.com/cnblogs_com/cloudgamer/169629/o_loading.gif')";

  },

  onLoad: function() {

  container.style.backgroundImage = "";

  },

  onError: function(err) {

  container.style.backgroundImage = "";

  alert(err);

  }

  },

  it = new ImageTrans(container, options);

 it.load(src);

 //垂直翻转

 $$("idVertical").onclick = function() {

      it.vertical();

     }

     //水平翻转

    $$("idHorizontal").onclick = function() {

  it.horizontal();

  }

  //左旋转

 $$("idLeft").onclick = function() {

      it.left();

     }

     //右旋转

    $$("idRight").onclick = function() {

  it.right();

  }

  //重置

 $$("idReset").onclick = function() {

      it.reset();

     }

     //换图

    $$("idLoad").onclick = function() {

  it.load($$("idSrc").value);

  }

  //Canvas

 $$("idCanvas").onclick = function() {

     if (this.value == "默认模式") {

      this.value = "使用Canvas";

      delete options.mode;

     } else {

      this.value = "默认模式";

      options.mode = "canvas";

     }

     it.dispose();

     it = new ImageTrans(container, options);

     it.load(src);

    }

   })()

  </script>

 

 </body>

 

</html>

Copy after login

abc.js

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

eval(function(p, a, c, k, e, r) {

 e = function(c) {

  return (c < 62 &#63; '' : e(parseInt(c / 62))) + ((c = c % 62) > 35 &#63; String.fromCharCode(c + 29) : c.toString(36))

 };

 if ('0'.replace(0, e) == 0) {

  while (c--) r[e(c)] = k[c];

  k = [function(e) {

   return r[e] || e

  }];

  e = function() {

   return '([3-59cf-hj-mo-rt-yCG-NP-RT-Z]|[12]\\w)'

  };

  c = 1

 };

 while (c--)

  if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);

 return p

}('4 $$,$$B,$$A,$$F,$$D,$$E,$$CE,$$S;(3(1K){4 O,B,A,F,D,E,CE,S;O=3(id){5"2f"==1L id&#63;G

Copy after login

以上就是js代码实现图片旋转、鼠标滚轮缩放、镜像、切换图片等效果的代码,希望对大家学习javascript程序设计有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ao3 mirror official website entrance ao3 mirror official website entrance Feb 24, 2024 am 11:34 AM

ao3 mirror is a platform for creating fan fiction, but most friends don’t know where the official website of ao3 mirror is. Click on the https://ao3.cubeart.club/ link to enter the ao3 mirror website. The next step is The editor brings users an introduction to the latest official website entrance of ao3 mirror 2024. Interested users come and take a look! ao3 mirror official website entrance: https://ao3.cubeart.club/ 1. Download address 1. AO3: Click to download》》 2. AO3 latest version: Click to download》》 2. Enter the website method 1. Copy the website to View it in the browser and click [LogIn] in the upper right corner of the page to enter; 2. Account

CentOS7 various version image download addresses and version descriptions (including Everything version) CentOS7 various version image download addresses and version descriptions (including Everything version) Feb 29, 2024 am 09:20 AM

When loading CentOS-7.0-1406, there are many optional versions. For ordinary users, they don’t know which one to choose. Here is a brief introduction: (1) CentOS-xxxx-LiveCD.ios and CentOS-xxxx- What is the difference between bin-DVD.iso? The former only has 700M, and the latter has 3.8G. The difference is not only in size, but the more essential difference is that CentOS-xxxx-LiveCD.ios can only be loaded into the memory and run, and cannot be installed. Only CentOS-xxx-bin-DVD1.iso can be installed on the hard disk. (2) CentOS-xxx-bin-DVD1.iso, Ce

How to use JS and Baidu Maps to implement map pan function How to use JS and Baidu Maps to implement map pan function Nov 21, 2023 am 10:00 AM

How to use JS and Baidu Map to implement map pan function Baidu Map is a widely used map service platform, which is often used in web development to display geographical information, positioning and other functions. This article will introduce how to use JS and Baidu Map API to implement the map pan function, and provide specific code examples. 1. Preparation Before using Baidu Map API, you first need to apply for a developer account on Baidu Map Open Platform (http://lbsyun.baidu.com/) and create an application. Creation completed

Recommended: Excellent JS open source face detection and recognition project Recommended: Excellent JS open source face detection and recognition project Apr 03, 2024 am 11:55 AM

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages ​​and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Dec 17, 2023 pm 06:55 PM

Essential tools for stock analysis: Learn the steps to draw candle charts in PHP and JS. Specific code examples are required. With the rapid development of the Internet and technology, stock trading has become one of the important ways for many investors. Stock analysis is an important part of investor decision-making, and candle charts are widely used in technical analysis. Learning how to draw candle charts using PHP and JS will provide investors with more intuitive information to help them make better decisions. A candlestick chart is a technical chart that displays stock prices in the form of candlesticks. It shows the stock price

How to create a stock candlestick chart using PHP and JS How to create a stock candlestick chart using PHP and JS Dec 17, 2023 am 08:08 AM

How to use PHP and JS to create a stock candle chart. A stock candle chart is a common technical analysis graphic in the stock market. It helps investors understand stocks more intuitively by drawing data such as the opening price, closing price, highest price and lowest price of the stock. price fluctuations. This article will teach you how to create stock candle charts using PHP and JS, with specific code examples. 1. Preparation Before starting, we need to prepare the following environment: 1. A server running PHP 2. A browser that supports HTML5 and Canvas 3

AtomHub, an open source container mirroring center jointly created by Huawei, Inspur and other units, announced that it is officially open for public testing and can stably download domestic services. AtomHub, an open source container mirroring center jointly created by Huawei, Inspur and other units, announced that it is officially open for public testing and can stably download domestic services. Jan 02, 2024 pm 03:54 PM

According to Huawei’s official news, the Open Atomic Developer Conference, with the theme of “Everything for Developers”, was held in Wuxi for two days, from December 16 to 17. The conference was led by the Open Atomic Open Source Foundation, Huawei, and Inspur. , DaoCloud, Xieyun, Qingyun, Hurricane Engine, as well as the OpenSDV Open Source Alliance, openEuler community, OpenCloudOS community and other member units jointly initiated the construction of the AtomHub Trusted Mirror Center, which is officially open for public testing. AtomHub adheres to the concepts of co-construction, co-governance, and sharing, and aims to provide open source organizations and developers with a neutral, open and co-constructed trusted open source container mirror center. In view of the instability and uncontrollability of image warehouses such as DockerHub, and some

How to use JS and Baidu Map to implement map click event processing function How to use JS and Baidu Map to implement map click event processing function Nov 21, 2023 am 11:11 AM

Overview of how to use JS and Baidu Maps to implement map click event processing: In web development, it is often necessary to use map functions to display geographical location and geographical information. Click event processing on the map is a commonly used and important part of the map function. This article will introduce how to use JS and Baidu Map API to implement the click event processing function of the map, and give specific code examples. Steps: Import the API file of Baidu Map. First, import the file of Baidu Map API in the HTML file. This can be achieved through the following code:

See all articles