收费管理系统

gmap.html 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title></title>
  7. <script type="text/javascript" src="../internal.js"></script>
  8. <style type="text/css">
  9. .content{
  10. width: 600px;
  11. height: 412px;
  12. margin: 20px;
  13. }
  14. .content table{width: 100%}
  15. .content table td{vertical-align: middle;}
  16. #address{width:405px;height:28px;background: #FFF;border:1px solid #ccc; line-height: 28px;border-radius: 5px;margin-left: 10px;}
  17. #container {margin-top: 10px;}
  18. #doSearch {
  19. display: block;
  20. text-align: center;
  21. line-height: 30px;
  22. text-decoration: none;
  23. height: 30px;
  24. width: 78px;
  25. border: 0;
  26. background-color: #3498db;
  27. border-radius: 5px;
  28. color: #fff;
  29. }
  30. </style>
  31. <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
  32. </head>
  33. <body>
  34. <div class="content">
  35. <table>
  36. <tr>
  37. <td><label for="address"><var id="lang_input_address"></var></label></td>
  38. <td><input id="address" type="text" /></td>
  39. <td><a id="doSearch" href="javascript:void(0)" class="button"><var id="lang_input_search"></var></a></td>
  40. </tr>
  41. </table>
  42. <div id="container" style="width: 100%; height: 362px;margin-top: 20px;"></div>
  43. </div>
  44. <script type="text/javascript">
  45. domUtils.on(window,"load",function(){
  46. var map = new google.maps.Map(document.getElementById('container'), {
  47. zoom: 3,
  48. streetViewControl: false,
  49. scaleControl: true,
  50. mapTypeId: google.maps.MapTypeId.ROADMAP
  51. });
  52. var imgcss;
  53. var marker = new google.maps.Marker({
  54. map: map,
  55. draggable: true
  56. });
  57. function doSearch(){
  58. var address = document.getElementById('address').value;
  59. var geocoder = new google.maps.Geocoder();
  60. geocoder.geocode( { 'address': address}, function (results, status) {
  61. if (status == google.maps.GeocoderStatus.OK) {
  62. var bounds = results[0].geometry.viewport;
  63. map.fitBounds(bounds);
  64. marker.setPosition(results[0].geometry.location);
  65. marker.setTitle(address);
  66. } else alert(lang.searchError);
  67. });
  68. }
  69. $G('address').onkeydown = function (evt){
  70. evt = evt || event;
  71. if (evt.keyCode == 13) {
  72. doSearch();
  73. }
  74. };
  75. $G("doSearch").onclick = doSearch;
  76. dialog.onok = function (){
  77. var center = map.getCenter();
  78. var point = marker.getPosition();
  79. var url = "https://maps.googleapis.com/maps/api/staticmap?center=" + center.lat() + ',' + center.lng() + "&zoom=" + map.zoom + "&size=520x340&maptype=" + map.getMapTypeId() + "&markers=" + point.lat() + ',' + point.lng() + "&sensor=false";
  80. editor.execCommand('inserthtml', '<img width="520" height="340" src="' + url + '"' + (imgcss ? ' style="' + imgcss + '"' :'') + '/>');
  81. };
  82. function getPars(str,par){
  83. var reg = new RegExp(par+"=((\\d+|[.,])*)","g");
  84. return reg.exec(str)[1];
  85. }
  86. var img = editor.selection.getRange().getClosedNode();
  87. if(img && img.src.indexOf("https://maps.googleapis.com/maps/api/staticmap")!=-1){
  88. var url = img.getAttribute("src");
  89. var centers = getPars(url,"center").split(",");
  90. point = new google.maps.LatLng(Number(centers[0]),Number(centers[1]));
  91. map.setCenter(point);
  92. map.setZoom(Number(getPars(url,"zoom")));
  93. centers = getPars(url,"markers").split(",");
  94. marker.setPosition(new google.maps.LatLng(Number(centers[0]),Number(centers[1])));
  95. imgcss = img.style.cssText;
  96. }else{
  97. setTimeout(function(){
  98. doSearch();
  99. },30)
  100. }
  101. });
  102. </script>
  103. </body>
  104. </html>