質問編集履歴

2

URl削除

2016/12/17 01:46

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -188,7 +188,7 @@
188
188
 
189
189
  var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
190
190
 
191
- var icon = new google.maps.MarkerImage('http://watashinokaisya.com/wp-content/themes/coen/images/map_coen.png');
191
+ var icon = new google.maps.MarkerImage('');
192
192
 
193
193
  // create marker
194
194
 

1

コードを追記致しました。

2016/12/17 01:46

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -8,6 +8,334 @@
8
8
 
9
9
 
10
10
 
11
+ ```ここに言語を入力
12
+
13
+ /google map
14
+
15
+
16
+
17
+ (function($) {
18
+
19
+
20
+
21
+ /*
22
+
23
+ * render_map
24
+
25
+ *
26
+
27
+ * This function will render a Google Map onto the selected jQuery element
28
+
29
+ *
30
+
31
+ * @type function
32
+
33
+ * @date 8/11/2013
34
+
35
+ * @since 4.3.0
36
+
37
+ *
38
+
39
+ * @param $el (jQuery element)
40
+
41
+ * @return n/a
42
+
43
+ */
44
+
45
+
46
+
47
+ function render_map( $el ) {
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+ // var
56
+
57
+ var $markers = $el.find('.marker');
58
+
59
+
60
+
61
+ // vars
62
+
63
+ var args = {
64
+
65
+ zoom : 16,
66
+
67
+ center : new google.maps.LatLng(0, 0),
68
+
69
+ mapTypeId : google.maps.MapTypeId.ROADMAP,
70
+
71
+ draggable: true, //追記ドラッグ禁止
72
+
73
+ scrollwheel: false //スクロール禁止
74
+
75
+ };
76
+
77
+
78
+
79
+ // create map
80
+
81
+ var map = new google.maps.Map( $el[0], args);
82
+
83
+
84
+
85
+ // add a markers reference
86
+
87
+ map.markers = [];
88
+
89
+
90
+
91
+ // add markers
92
+
93
+ $markers.each(function(){
94
+
95
+
96
+
97
+ add_marker( $(this), map );
98
+
99
+
100
+
101
+ });
102
+
103
+
104
+
105
+ // center map
106
+
107
+ center_map( map );
108
+
109
+
110
+
111
+ }
112
+
113
+
114
+
115
+ /*
116
+
117
+ * add_marker
118
+
119
+ *
120
+
121
+ * This function will add a marker to the selected Google Map
122
+
123
+ *
124
+
125
+ * @type function
126
+
127
+ * @date 8/11/2013
128
+
129
+ * @since 4.3.0
130
+
131
+ *
132
+
133
+ * @param $marker (jQuery element)
134
+
135
+ * @param map (Google Map object)
136
+
137
+ * @return n/a
138
+
139
+ */
140
+
141
+
142
+
143
+ function add_marker( $marker, map ) {
144
+
145
+
146
+
147
+ // color
148
+
149
+ var styleOptions = [{
150
+
151
+ 'stylers': [{
152
+
153
+ 'gamma': 1.2//ガンマ
154
+
155
+ }, {
156
+
157
+ 'saturation': -100//彩度
158
+
159
+ }, {
160
+
161
+ 'lightness': -20//明度
162
+
163
+ }]
164
+
165
+ }]
166
+
167
+
168
+
169
+ var styledMapOptions = {
170
+
171
+ name: 'mono'
172
+
173
+ }
174
+
175
+ var monoType = new google.maps.StyledMapType(styleOptions, styledMapOptions);
176
+
177
+ map.mapTypes.set('mono', monoType);
178
+
179
+ map.setMapTypeId('mono');
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+ // var
188
+
189
+ var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
190
+
191
+ var icon = new google.maps.MarkerImage('http://watashinokaisya.com/wp-content/themes/coen/images/map_coen.png');
192
+
193
+ // create marker
194
+
195
+ var marker = new google.maps.Marker({
196
+
197
+ position : latlng,
198
+
199
+ map : map,
200
+
201
+ icon : icon
202
+
203
+ });
204
+
205
+
206
+
207
+ // add to array
208
+
209
+ map.markers.push( marker );
210
+
211
+
212
+
213
+ // if marker contains HTML, add it to an infoWindow
214
+
215
+ if( $marker.html() )
216
+
217
+ {
218
+
219
+ // create info window
220
+
221
+ var infowindow = new google.maps.InfoWindow({
222
+
223
+ content : $marker.html()
224
+
225
+ });
226
+
227
+
228
+
229
+ // show info window when marker is clicked
230
+
231
+ google.maps.event.addListener(marker, 'click', function() {
232
+
233
+
234
+
235
+ infowindow.open( map, marker );
236
+
237
+
238
+
239
+ });
240
+
241
+ }
242
+
243
+
244
+
245
+ }
246
+
247
+
248
+
249
+ /*
250
+
251
+ * center_map
252
+
253
+ *
254
+
255
+ * This function will center the map, showing all markers attached to this map
256
+
257
+ *
258
+
259
+ * @type function
260
+
261
+ * @date 8/11/2013
262
+
263
+ * @since 4.3.0
264
+
265
+ *
266
+
267
+ * @param map (Google Map object)
268
+
269
+ * @return n/a
270
+
271
+ */
272
+
273
+
274
+
275
+ function center_map( map ) {
276
+
277
+
278
+
279
+ // vars
280
+
281
+ var bounds = new google.maps.LatLngBounds();
282
+
283
+
284
+
285
+ // loop through all markers and create bounds
286
+
287
+ $.each( map.markers, function( i, marker ){
288
+
289
+
290
+
291
+ var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
292
+
293
+
294
+
295
+ bounds.extend( latlng );
296
+
297
+
298
+
299
+ });
300
+
301
+
302
+
303
+ // only 1 marker?
304
+
305
+ if( map.markers.length == 1 )
306
+
307
+ {
308
+
309
+ // set center of map
310
+
311
+ map.setCenter( bounds.getCenter() );
312
+
313
+ map.setZoom( 16 );
314
+
315
+ }
316
+
317
+ else
318
+
319
+ {
320
+
321
+ // fit to bounds
322
+
323
+ map.fitBounds( bounds );
324
+
325
+ }
326
+
327
+
328
+
329
+ }
330
+
331
+ ```
332
+
333
+
334
+
335
+
336
+
337
+
338
+
11
339
  http://qiita.com/JumpeiSato/items/21cfc4e07288313cf3ab
12
340
 
13
341