|
1 |
| ---- |
2 |
| ---- |
3 | 1 | function initialize() {
|
4 |
| - $.getJSON( |
5 |
| - 'https://githubschool.github.io/open-enrollment-classes-introduction-to-github/createMap.topojson', |
6 |
| - function (data) { |
7 |
| - var mapSize = new google.maps.Size(256, 256), // original size, fallback for space invador images |
8 |
| - scaledSize = new google.maps.Size(20, 20), // size on map, fallback for space invador images |
9 |
| - anchor = new google.maps.Point(0, 32), // start point |
10 |
| - map = new google.maps.Map(document.getElementById('map'), { |
11 |
| - zoom: 2, |
12 |
| - minZoom: 2, |
13 |
| - center: new google.maps.LatLng(10, 15), |
14 |
| - mapTypeId: 'terrain', |
15 |
| - //disableDefaultUI: true, |
16 |
| - mapTypeControl: false, |
17 |
| - panControl: false, |
18 |
| - //scaleControl: false, |
19 |
| - scrollwheel: false, |
20 |
| - streetViewControl: false, |
21 |
| - //zoomControl: false, |
22 |
| - //draggable: false, |
23 |
| - styles: [ |
24 |
| - { |
25 |
| - featureType: 'administrative', |
26 |
| - elementType: 'geometry', |
27 |
| - stylers: [{visibility: 'off'}] |
28 |
| - }, |
29 |
| - { |
30 |
| - featureType: 'administrative.country', |
31 |
| - stylers: [{visibility: 'off'}] |
32 |
| - }, |
33 |
| - { |
34 |
| - featureType: 'water', |
35 |
| - elementType: 'labels', |
36 |
| - stylers: [{visibility: 'off'}] |
37 |
| - }, |
38 |
| - { |
39 |
| - featureType: 'administrative', |
40 |
| - elementType: 'labels', |
41 |
| - stylers: [{visibility: 'off'}] |
42 |
| - } |
43 |
| - ] |
44 |
| - }), |
45 |
| - markers = data.features.map(function (coords) { |
46 |
| - var coordinates = coords.geometry.coordinates, |
47 |
| - username = coords.properties.username; |
| 2 | + if ($("#map").length) { |
| 3 | + $.getJSON( |
| 4 | + 'https://githubschool.github.io/open-enrollment-classes-introduction-to-github/createMap.topojson', |
| 5 | + function (data) { |
| 6 | + var mapSize = new google.maps.Size(256, 256), // original size, fallback for space invador images |
| 7 | + scaledSize = new google.maps.Size(20, 20), // size on map, fallback for space invador images |
| 8 | + anchor = new google.maps.Point(0, 32), // start point |
| 9 | + map = new google.maps.Map(document.getElementById('map'), { |
| 10 | + zoom: 2, |
| 11 | + minZoom: 2, |
| 12 | + center: new google.maps.LatLng(10, 15), |
| 13 | + mapTypeId: 'terrain', |
| 14 | + //disableDefaultUI: true, |
| 15 | + mapTypeControl: false, |
| 16 | + panControl: false, |
| 17 | + //scaleControl: false, |
| 18 | + scrollwheel: false, |
| 19 | + streetViewControl: false, |
| 20 | + //zoomControl: false, |
| 21 | + //draggable: false, |
| 22 | + styles: [ |
| 23 | + { |
| 24 | + featureType: 'administrative', |
| 25 | + elementType: 'geometry', |
| 26 | + stylers: [{visibility: 'off'}] |
| 27 | + }, |
| 28 | + { |
| 29 | + featureType: 'administrative.country', |
| 30 | + stylers: [{visibility: 'off'}] |
| 31 | + }, |
| 32 | + { |
| 33 | + featureType: 'water', |
| 34 | + elementType: 'labels', |
| 35 | + stylers: [{visibility: 'off'}] |
| 36 | + }, |
| 37 | + { |
| 38 | + featureType: 'administrative', |
| 39 | + elementType: 'labels', |
| 40 | + stylers: [{visibility: 'off'}] |
| 41 | + } |
| 42 | + ] |
| 43 | + }), |
| 44 | + markers = data.features.map(function (coords) { |
| 45 | + var coordinates = coords.geometry.coordinates, |
| 46 | + username = coords.properties.username; |
48 | 47 |
|
49 |
| - return new google.maps.Marker({ |
50 |
| - position: new google.maps.LatLng( |
51 |
| - coordinates[1], |
52 |
| - coordinates[0] |
53 |
| - ), |
54 |
| - map: map, |
55 |
| - title: username, |
56 |
| - icon: { |
57 |
| - url: 'https://github.com/' + username + '.png?size=20', |
58 |
| - size: mapSize, |
59 |
| - scaledSize: scaledSize, |
60 |
| - anchor: anchor |
61 |
| - } |
62 |
| - }); |
63 |
| - }); |
| 48 | + return new google.maps.Marker({ |
| 49 | + position: new google.maps.LatLng( |
| 50 | + coordinates[1], |
| 51 | + coordinates[0] |
| 52 | + ), |
| 53 | + map: map, |
| 54 | + title: username, |
| 55 | + icon: { |
| 56 | + url: 'https://github.com/' + username + '.png?size=20', |
| 57 | + size: mapSize, |
| 58 | + scaledSize: scaledSize, |
| 59 | + anchor: anchor |
| 60 | + } |
| 61 | + }); |
| 62 | + }); |
64 | 63 |
|
65 |
| - new MarkerClusterer(map, markers, { |
66 |
| - imagePath: '{{site.baseurl}}/images/cluster/m', |
67 |
| - averageCenter: true, |
68 |
| - minimumClusterSize: 42 |
69 |
| - }); |
70 |
| - } |
71 |
| - ); |
| 64 | + new MarkerClusterer(map, markers, { |
| 65 | + imagePath: '{{site.baseurl}}/images/cluster/m', |
| 66 | + averageCenter: true, |
| 67 | + minimumClusterSize: 42 |
| 68 | + }); |
| 69 | + } |
| 70 | + ); |
| 71 | + } |
72 | 72 | }
|
0 commit comments