Mam taki problem, zrobiłem kod z google map i chce aby po za mape nie dalo sie wyjechac. Obecnie mam tak ze przesuwając moge jechac i jechac bez konca na bialym tle.
ss: http://iv.pl/images/16197759761087648399.png
Kod:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml"><head>
  5. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  6. <meta http-equiv="content-type" content="text/html/xml; charset=utf-8"/>
  7. <meta name="author" content="Richard Milton, Centre for Advanced Spatial Analysis (CASA), University College London (UCL)">
  8. <meta name="description" content="Page automatically created by GMapImageCutter created by CASA">
  9. <meta name="keywords" content="Google, Maps, Image, Images, Tile, Cutter, GMapImageCutter, GMapCreator">
  10. <title>xxxxxx</title>
  11.  
  12. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  13.  
  14. <script type="text/javascript">
  15. //<![CDATA[
  16. var centreLat=0.0;
  17. var centreLon=0.0;
  18. var initialZoom=2;
  19. var imageWraps=false; //SET THIS TO false TO PREVENT THE IMAGE WRAPPING AROUND
  20.  
  21. var map; //the GMap3 itself
  22. var gmicMapType;
  23.  
  24. function GMICMapType() {
  25. this.Cache = Array();
  26. this.opacity = 1.0;
  27. }
  28. GMICMapType.prototype.tileSize = new google.maps.Size(256, 256);
  29. GMICMapType.prototype.maxZoom = 19;
  30. GMICMapType.prototype.getTile = function(coord, zoom, ownerDocument) {
  31. var c = Math.pow(2, zoom);
  32. var c = Math.pow(2, zoom);
  33. var tilex=coord.x,tiley=coord.y;
  34. if (imageWraps) {
  35. if (tilex<0) tilex=c+tilex%c;
  36. if (tilex>=c) tilex=tilex%c;
  37. if (tiley<0) tiley=c+tiley%c;
  38. if (tiley>=c) tiley=tiley%c;
  39. }
  40. else {
  41. if ((tilex<0)||(tilex>=c)||(tiley<0)||(tiley>=c))
  42. {
  43. var blank = ownerDocument.createElement('DIV');
  44. blank.style.width = this.tileSize.width + 'px';
  45. blank.style.height = this.tileSize.height + 'px';
  46. return blank;
  47. }
  48. }
  49. var img = ownerDocument.createElement('IMG');
  50. var d = tilex;
  51. var e = tiley;
  52. var f = "t";
  53. for (var g = 0; g < zoom; g++) {
  54. c /= 2;
  55. if (e < c) {
  56. if (d < c) { f += "q" }
  57. else { f += "r"; d -= c }
  58. }
  59. else {
  60. if (d < c) { f += "t"; e -= c }
  61. else { f += "s"; d -= c; e -= c }
  62. }
  63. }
  64. img.id = "t_" + f;
  65. img.style.width = this.tileSize.width + 'px';
  66. img.style.height = this.tileSize.height + 'px';
  67. img.src = "Pride Role Play-tiles/"+f+".jpg";
  68. this.Cache.push(img);
  69. return img;
  70. }
  71. GMICMapType.prototype.realeaseTile = function(tile) {
  72. var idx = this.Cache.indexOf(tile);
  73. if(idx!=-1) this.Cache.splice(idx, 1);
  74. tile=null;
  75. }
  76. GMICMapType.prototype.name = "xxxxxx";
  77. GMICMapType.prototype.alt = "xxxxxx";
  78. GMICMapType.prototype.setOpacity = function(newOpacity) {
  79. this.opacity = newOpacity;
  80. for (var i = 0; i < this.Cache.length; i++) {
  81. this.Cache[i].style.opacity = newOpacity; //mozilla
  82. this.Cache[i].style.filter = "alpha(opacity=" + newOpacity * 100 + ")"; //ie
  83. }
  84. }
  85.  
  86. function getWindowHeight() {
  87. if (window.self&&self.innerHeight) {
  88. return self.innerHeight;
  89. }
  90. if (document.documentElement&&document.documentElement.clientHeight) {
  91. return document.documentElement.clientHeight;
  92. }
  93. return 0;
  94. }
  95.  
  96. function resizeMapDiv() {
  97. //Resize the height of the div containing the map.
  98.  
  99. //Do not call any map methods here as the resize is called before the map is created.
  100. var d=document.getElementById("map");
  101.  
  102. var offsetTop=0;
  103. for (var elem=d; elem!=null; elem=elem.offsetParent) {
  104. offsetTop+=elem.offsetTop;
  105.  
  106. }
  107. var height=getWindowHeight()-offsetTop-16;
  108.  
  109. if (height>=0) {
  110. d.style.height=height+"px";
  111. }
  112. }
  113.  
  114. function load() {
  115. resizeMapDiv();
  116. var latlng = new google.maps.LatLng(centreLat, centreLon);
  117. var myOptions = {
  118. zoom: initialZoom,
  119. minZoom: 2,
  120. maxZoom: 5,
  121. center: latlng,
  122. panControl: true,
  123. zoomControl: true,
  124. mapTypeControl: true,
  125. scaleControl: false,
  126. streetViewControl: false,
  127. overviewMapControl: true,
  128. mapTypeControlOptions: { mapTypeIds: ["ImageCutter"] },
  129. mapTypeId: "ImageCutter"
  130. }
  131. map = new google.maps.Map(document.getElementById("map"), myOptions);
  132. gmicMapType = new GMICMapType();
  133. map.mapTypes.set("ImageCutter",gmicMapType);
  134.  
  135.  
  136. /////////////////////////////////////////////////////////////////////////////////////
  137. //Add any markers here e.g.
  138. // var marker = new google.maps.Marker({
  139. // map:map,
  140. // position: new google.maps.LatLng(x,y),
  141. // title: "My Marker"
  142. // });
  143. /////////////////////////////////////////////////////////////////////////////////////
  144.  
  145. }
  146.  
  147.  
  148. //]]>
  149. </script>
  150.  
  151. </head>
  152.  
  153. <body onresize="resizeMapDiv()" onload="load()">
  154.  
  155. <div id="map"></div>
  156.  
  157. </body>

</html>