index.html 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Ionic App</title>
  6. <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  7. <meta name="format-detection" content="telephone=no">
  8. <meta name="msapplication-tap-highlight" content="no">
  9. <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
  10. <link rel="manifest" href="manifest.json">
  11. <meta name="theme-color" content="#4e8ef7">
  12. <!-- add to homescreen for ios -->
  13. <meta name="apple-mobile-web-app-capable" content="yes">
  14. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  15. <!-- cordova.js required for cordova apps (remove if not needed) -->
  16. <script src="cordova.js"></script>
  17. <!-- un-comment this code to enable service worker
  18. <script>
  19. if ('serviceWorker' in navigator) {
  20. navigator.serviceWorker.register('service-worker.js')
  21. .then(() => console.log('service worker installed'))
  22. .catch(err => console.error('Error', err));
  23. }
  24. </script>-->
  25. <link href="build/main.css" rel="stylesheet">
  26. </head>
  27. <body>
  28. <!-- Ionic's root component and where the app will load -->
  29. <ion-app></ion-app>
  30. <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=lYGuG0ZagxCX2ra23MgMT5iTyqdrGLh2"></script>
  31. <script>
  32. //2011-7-25
  33. (function(){ //闭包
  34. function load_script(xyUrl, callback){
  35. var head = document.getElementsByTagName('head')[0];
  36. var script = document.createElement('script');
  37. script.type = 'text/javascript';
  38. script.src = xyUrl;
  39. //借鉴了jQuery的script跨域方法
  40. script.onload = script.onreadystatechange = function(){
  41. if((!this.readyState || this.readyState === "loaded" || this.readyState === "complete")){
  42. callback && callback();
  43. // Handle memory leak in IE
  44. script.onload = script.onreadystatechange = null;
  45. if ( head && script.parentNode ) {
  46. head.removeChild( script );
  47. }
  48. }
  49. };
  50. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  51. head.insertBefore( script, head.firstChild );
  52. }
  53. function translate(point,type,callback){
  54. var callbackName = 'cbk_' + Math.round(Math.random() * 10000); //随机函数名
  55. var xyUrl = "http://api.map.baidu.com/ag/coord/convert?from="+ type + "&to=4&x=" + point.lng + "&y=" + point.lat + "&callback=BMap.Convertor." + callbackName;
  56. //动态创建script标签
  57. load_script(xyUrl);
  58. BMap.Convertor[callbackName] = function(xyResult){
  59. delete BMap.Convertor[callbackName]; //调用完需要删除改函数
  60. var point = new BMap.Point(xyResult.x, xyResult.y);
  61. callback && callback(point);
  62. }
  63. }
  64. window.BMap = window.BMap || {};
  65. BMap.Convertor = {};
  66. BMap.Convertor.translate = translate;
  67. })();
  68. </script>
  69. <!-- The polyfills js is generated during the build process -->
  70. <script src="build/polyfills.js"></script>
  71. <!-- The vendor js is generated during the build process
  72. It contains all of the dependencies in node_modules -->
  73. <script src="build/vendor.js"></script>
  74. <!-- The main bundle js is generated during the build process -->
  75. <script src="build/main.js"></script>
  76. </body>
  77. </html>