Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.79 KB | None | 0 0
  1. <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCZdYinebnv3Lf0KYxxVBFQpIwKIUAtGCg&callback=initMap"
  2. type="text/javascript"></script>
  3.  
  4. <script type="text/javascript">
  5. var GALL_PETERS_RANGE_X = 256;
  6. var GALL_PETERS_RANGE_Y = 256;
  7.  
  8. function degreesToRadians(deg)
  9. {
  10. return deg * (Math.PI / 180);
  11. }
  12.  
  13. function radiansToDegrees(rad)
  14. {
  15. return rad / (Math.PI / 180);
  16. }
  17.  
  18. function GallPetersProjection()
  19. {
  20. this.worldOrigin_ = new google.maps.Point(GALL_PETERS_RANGE_X * 400 / 800,
  21. GALL_PETERS_RANGE_Y / 2);
  22.  
  23. this.worldCoordinatePerLonDegree_ = GALL_PETERS_RANGE_X / 360;
  24. this.worldCoordinateLatRange = GALL_PETERS_RANGE_Y / 2;
  25. };
  26.  
  27. GallPetersProjection.prototype.fromLatLngToPoint = function(latLng)
  28. {
  29.  
  30. var origin = this.worldOrigin_;
  31. var x = origin.x + this.worldCoordinatePerLonDegree_ * latLng.lng();
  32. var latRadians = degreesToRadians(latLng.lat());
  33. var y = origin.y - this.worldCoordinateLatRange * Math.sin(latRadians);
  34.  
  35. return new google.maps.Point(x, y);
  36. };
  37.  
  38. GallPetersProjection.prototype.fromPointToLatLng = function(point, noWrap) {
  39.  
  40. var y = point.y;
  41. var x = point.x;
  42.  
  43. if (y < 0) {
  44. y = 0;
  45. }
  46. if (y >= GALL_PETERS_RANGE_Y) {
  47. y = GALL_PETERS_RANGE_Y;
  48. }
  49.  
  50. var origin = this.worldOrigin_;
  51. var lng = (x - origin.x) / this.worldCoordinatePerLonDegree_;
  52. var latRadians = Math.asin((origin.y - y) / this.worldCoordinateLatRange);
  53. var lat = radiansToDegrees(latRadians);
  54. return new google.maps.LatLng(lat, lng, noWrap);
  55. };
  56.  
  57. function initialize() {
  58.  
  59. var gallPetersMap;
  60.  
  61. var gallPetersMapType = new google.maps.ImageMapType({
  62. getTileUrl: function(coord, zoom)
  63. {
  64. var numTiles = 1 << zoom;
  65.  
  66. if (coord.y < 0 || coord.y >= numTiles) {
  67. return null;
  68. }
  69. if (coord.x < 0 || coord.x >= numTiles) {
  70. return null;
  71. }
  72.  
  73. var x = ((coord.x % numTiles) + numTiles) % numTiles;
  74. var y = ((coord.y % numTiles) + numTiles) % numTiles;
  75. var baseURL = '/map/';
  76.  
  77. baseURL += '' + x + 'x' + coord.y + '-' +(6-zoom)+ '.jpg';
  78. return baseURL;
  79. },
  80. tileSize: new google.maps.Size(256, 256),
  81. isPng: true,
  82. minZoom: 2,
  83. maxZoom: 4,
  84. name: 'Świat gry'
  85. });
  86.  
  87. gallPetersMapType.projection = new GallPetersProjection();
  88.  
  89. document.getElementById('irpmap').style.background = "#324a54";
  90. var mapOptions = {
  91. zoom: 3,
  92. center: new google.maps.LatLng(-35.3536147483593, 100.15234375),
  93. streetViewControl: false,
  94. mapTypeControlOptions: {
  95. mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'gallPetersMap']
  96. }
  97. };
  98. gallPetersMap = new google.maps.Map(document.getElementById('irpmap'),
  99. mapOptions);
  100.  
  101. gallPetersMap.mapTypes.set('gallPetersMap', gallPetersMapType);
  102. gallPetersMap.setMapTypeId('gallPetersMap');
  103. var map = gallPetersMap;
  104. var load = new XMLHttpRequest();
  105.  
  106. load.open("GET", "/index.php?app=panel&module=ajax&section=map&md5check={$this->member->form_hash}", false);
  107. load.send(null);
  108.  
  109.  
  110. var data = JSON.parse(load.responseText);
  111.  
  112.  
  113.  
  114. for(var id = 0, len = data.items.length, item; id != len && (item = data.items[id]); ++id) {
  115. var item = data.items[id];
  116. var point = new google.maps.LatLng(parseFloat((((item.pos.y*90)/4100)+2.5)), parseFloat((item.pos.x*90)/1500));
  117. function buildInfoWindow(marker,map,point){
  118. var contentString = '<div id="contentxD" style="overflow: auto; min-width:160px; min-height: 35px;">' +
  119. '<div id="siteNotice">' +
  120. '</div>' +
  121. '<h3 id="firstHeading" class="firstHeading">' + item.name + '</h3>' +
  122. '<div id="bodyContent">' +
  123. '<p>' + item.text + '</p>' +
  124. '</div>' +
  125. '</div>';
  126.  
  127. var infowindow = new google.maps.InfoWindow({
  128. content: contentString
  129. });
  130. google.maps.event.addListener(marker, 'click', function() {
  131. infowindow.open(map,marker);
  132. console.log(marker);
  133. });
  134. }
  135.  
  136. var marker = new google.maps.Marker({
  137. position: point,
  138. map: gallPetersMap,
  139. title: item.name,
  140. icon: 'http://net4game.com/public/hrp/map/icons/Icon_'+item.icon+'.gif',
  141. zIndex: 1000
  142. });
  143. buildInfoWindow(marker,map,point);
  144. }
  145.  
  146. }
  147.  
  148. google.maps.event.addDomListener(window, 'load', initialize);
  149. </script>
  150.  
  151.  
  152.  
  153. <div class="ipsBox">
  154. <div class="ipsVerticalTabbed ipsLayout ipsLayout_withleft ipsLayout_smallleft clearfix">
  155. <div class="ipsVerticalTabbed_tabs ipsLayout_left">
  156. <ul class="clear">
  157. <li><a href="index.php?app=panel&module=online"><i class="fas fa-gamepad"></i> Gracze online</a></li>
  158. <li><a href="index.php?app=panel&module=market&sort=1"><i class="fas fa-shopping-basket"></i> Aukcje</a></li>
  159. <li><a href="index.php?app=panel&module=leader"><i class="fas fa-building"></i> Grupy</a></li>
  160. <li><a href="index.php?app=panel&module=characters&section=create"><i class="fas fa-plus"></i> Stwórz postać</a></li>
  161. <li><a href="index.php?app=panel&module=apelacje"><i class="fas fa-bookmark"></i> Apelacje</a></li>
  162. <li><a href="index.php?app=panel&module=tickets"><i class="fas fa-code"></i> Zgłoszenia</a></li>
  163. <li><a href="index.php?app=panel&module=ekipa"><i class="fas fa-users"></i> Ekipa</a></li>
  164. <li><a href="index.php?app=panel&module=services"><i class="fas fa-credit-card"></i> Premium</a></li>
  165. <li><a href="index.php?app=panel&module=hosting"><i class="fas fa-image"></i> Hosting Obrazków</a></li>
  166. <li class="active"><a href="index.php?app=panel&module=map"><i class="fas fa-map-marker-alt"></i> Mapa świata</a></li>
  167. </ul>
  168. </div>
  169. <div class="ipsVerticalTabbed_content ipsLayout_content ipsBox_container" id="modcp_content" style="min-height: 360px;">
  170. <div class="ipsPad">
  171.  
  172.  
  173.  
  174. <div id="irpmap" style="height: 500px; width:100%;"></div>
  175. </div>
  176. </div>
  177. </div>
  178. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement