Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>OpenLayers Google (v3) Layer Example - demo with styled maps, traffic, fusion tables</title>
  4. <script src="http://maps.google.com/maps/api/js?V=3.3&sensor=false"></script>
  5. <script src="http://openlayers.org/dev/OpenLayers.js"></script>
  6. <script>
  7. var map;
  8. var MY_MAPTYPE_ID = 'usroadatlas';
  9.  
  10. var roadAtlasStyles = [{
  11. featureType: "road.highway",
  12. elementType: "geometry",
  13. stylers: [{
  14. hue: "#ff0022"
  15. }, {
  16. saturation: 60
  17. }, {
  18. lightness: -20
  19. }]
  20. }, {
  21. featureType: "road.arterial",
  22. elementType: "all",
  23. stylers: [{
  24. hue: "#2200ff"
  25. }, {
  26. lightness: -40
  27. }, {
  28. visibility: "simplified"
  29. }, {
  30. saturation: 30
  31. }]
  32. }, {
  33. featureType: "road.local",
  34. elementType: "all",
  35. stylers: [{
  36. hue: "#f6ff00"
  37. }, {
  38. saturation: 50
  39. }, {
  40. gamma: 0.7
  41. }, {
  42. visibility: "simplified"
  43. }]
  44. }, {
  45. featureType: "water",
  46. elementType: "geometry",
  47. stylers: [{
  48. saturation: 40
  49. }, {
  50. lightness: 40
  51. }]
  52. }, {
  53. featureType: "road.highway",
  54. elementType: "labels",
  55. stylers: [{
  56. visibility: "on"
  57. }, {
  58. saturation: 98
  59. }]
  60. }, {
  61. featureType: "administrative.locality",
  62. elementType: "labels",
  63. stylers: [{
  64. hue: "#0022ff"
  65. }, {
  66. saturation: 50
  67. }, {
  68. lightness: -10
  69. }, {
  70. gamma: 0.9
  71. }]
  72. }, {
  73. featureType: "transit.line",
  74. elementType: "geometry",
  75. stylers: [{
  76. hue: "#ff0000"
  77. }, {
  78. visibility: "on"
  79. }, {
  80. lightness: -70
  81. }]
  82. }];
  83.  
  84. var usRoadMapType = new google.maps.StyledMapType(roadAtlasStyles);
  85.  
  86. var roadatlas = new OpenLayers.Layer.Google("Google US Road Atlas",
  87.  
  88. { type: 'usroadatlas'},
  89. { isBaseLayer: false}
  90.  
  91.  
  92. );
  93.  
  94. roadatlas.id = 'a';
  95.  
  96.  
  97.  
  98. var gmap = new OpenLayers.Layer.Google("Google Roads",
  99. { isBaseLayer: false});
  100.  
  101. var kml1 = new OpenLayers.Layer.Vector("KML", {
  102. strategies: [new OpenLayers.Strategy.Fixed()],
  103. protocol: new OpenLayers.Protocol.HTTP({
  104. url: "kmls/AirCallMobileCoverage.kml",
  105. format: new OpenLayers.Format.KML({
  106. extractStyles: true,
  107. extractAttributes: true,
  108. maxDepth: 2
  109. })
  110. })
  111. },
  112. { isBaseLayer: false}
  113. );
  114.  
  115.  
  116. function init() {
  117.  
  118. map = new OpenLayers.Map('map');
  119. map.addControl(new OpenLayers.Control.LayerSwitcher())
  120. map.addLayers([gmap, kml1, roadatlas]);
  121.  
  122.  
  123. map.setCenter(new OpenLayers.LonLat(-87.650052, 41.850033).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), 10);
  124.  
  125. map.getLayer('a').mapObject.mapTypeControlOptions = {
  126. mapTypeIds: [google.maps.MapTypeId.ROADMAP, MY_MAPTYPE_ID]
  127. };
  128. map.getLayer('a').mapObject.mapTypes.set(MY_MAPTYPE_ID, usRoadMapType);
  129.  
  130. }
  131. </script>
  132. </head>
  133. <body onload="init()">
  134. <div id="map"></div>
  135. </body>
  136. </html>
  137.  
  138. Z_INDEX_BASE: {
  139. BaseLayer: 100,
  140. Overlay: 325,
  141. Feature: 725,
  142. Popup: 750,
  143. Control: 1000
  144. },
  145.  
  146. function fixZIndex()
  147. {
  148. vectorLayer.setZIndex ( olMap.Z_INDEX_BASE[ "Feature" ] );
  149. markerLayer.setZIndex ( olMap.Z_INDEX_BASE[ "Feature" ] + 1 );
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement