選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

map.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. window.marker = null;
  2. function initialize() {
  3. var map;
  4. var latitude = $('#map').attr('data-latitude');
  5. var longitude = $('#map').attr('data-longitude');
  6. var mapMarker = $('#map').attr('data-marker');
  7. var mapMarkerName = $('#map').attr('data-marker-name');
  8. var nottingham = new google.maps.LatLng(latitude, longitude);
  9. var style = [{
  10. "featureType": "all",
  11. "elementType": "labels.text.fill",
  12. "stylers": [{
  13. "saturation": 36
  14. },
  15. {
  16. "color": "#000000"
  17. },
  18. {
  19. "lightness": 40
  20. }
  21. ]
  22. },
  23. {
  24. "featureType": "all",
  25. "elementType": "labels.text.stroke",
  26. "stylers": [{
  27. "visibility": "on"
  28. },
  29. {
  30. "color": "#000000"
  31. },
  32. {
  33. "lightness": 16
  34. }
  35. ]
  36. },
  37. {
  38. "featureType": "all",
  39. "elementType": "labels.icon",
  40. "stylers": [{
  41. "visibility": "off"
  42. }]
  43. },
  44. {
  45. "featureType": "administrative",
  46. "elementType": "geometry.fill",
  47. "stylers": [{
  48. "color": "#000000"
  49. },
  50. {
  51. "lightness": 20
  52. }
  53. ]
  54. },
  55. {
  56. "featureType": "administrative",
  57. "elementType": "geometry.stroke",
  58. "stylers": [{
  59. "color": "#000000"
  60. },
  61. {
  62. "lightness": 17
  63. },
  64. {
  65. "weight": 1.2
  66. }
  67. ]
  68. },
  69. {
  70. "featureType": "landscape",
  71. "elementType": "geometry",
  72. "stylers": [{
  73. "color": "#000000"
  74. },
  75. {
  76. "lightness": 20
  77. }
  78. ]
  79. },
  80. {
  81. "featureType": "poi",
  82. "elementType": "geometry",
  83. "stylers": [{
  84. "color": "#000000"
  85. },
  86. {
  87. "lightness": 21
  88. }
  89. ]
  90. },
  91. {
  92. "featureType": "road.highway",
  93. "elementType": "geometry.fill",
  94. "stylers": [{
  95. "color": "#000000"
  96. },
  97. {
  98. "lightness": 17
  99. }
  100. ]
  101. },
  102. {
  103. "featureType": "road.highway",
  104. "elementType": "geometry.stroke",
  105. "stylers": [{
  106. "color": "#000000"
  107. },
  108. {
  109. "lightness": 29
  110. },
  111. {
  112. "weight": 0.2
  113. }
  114. ]
  115. },
  116. {
  117. "featureType": "road.arterial",
  118. "elementType": "geometry",
  119. "stylers": [{
  120. "color": "#000000"
  121. },
  122. {
  123. "lightness": 18
  124. }
  125. ]
  126. },
  127. {
  128. "featureType": "road.local",
  129. "elementType": "geometry",
  130. "stylers": [{
  131. "color": "#000000"
  132. },
  133. {
  134. "lightness": 16
  135. }
  136. ]
  137. },
  138. {
  139. "featureType": "transit",
  140. "elementType": "geometry",
  141. "stylers": [{
  142. "color": "#000000"
  143. },
  144. {
  145. "lightness": 19
  146. }
  147. ]
  148. },
  149. {
  150. "featureType": "water",
  151. "elementType": "geometry",
  152. "stylers": [{
  153. "color": "#000000"
  154. },
  155. {
  156. "lightness": 17
  157. }
  158. ]
  159. }
  160. ];
  161. var mapOptions = {
  162. center: nottingham,
  163. mapTypeId: google.maps.MapTypeId.ROADMAP,
  164. backgroundColor: "#000",
  165. zoom: 15,
  166. panControl: false,
  167. zoomControl: true,
  168. mapTypeControl: false,
  169. scaleControl: false,
  170. streetViewControl: false,
  171. overviewMapControl: false,
  172. zoomControlOptions: {
  173. style: google.maps.ZoomControlStyle.LARGE
  174. }
  175. }
  176. map = new google.maps.Map(document.getElementById('map'), mapOptions);
  177. var mapType = new google.maps.StyledMapType(style, {
  178. name: "Grayscale"
  179. });
  180. map.mapTypes.set('grey', mapType);
  181. map.setMapTypeId('grey');
  182. var marker_image = mapMarker;
  183. var pinIcon = new google.maps.MarkerImage(marker_image, null, null, null, new google.maps.Size(46, 40));
  184. marker = new google.maps.Marker({
  185. position: nottingham,
  186. map: map,
  187. icon: pinIcon,
  188. title: mapMarkerName
  189. });
  190. }
  191. var map = document.getElementById('map');
  192. if (map != null) {
  193. google.maps.event.addDomListener(window, 'load', initialize);
  194. }