-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustommap.js
More file actions
executable file
·184 lines (153 loc) · 5.25 KB
/
custommap.js
File metadata and controls
executable file
·184 lines (153 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
var map;
var lala;
function initialize() {
var mapOptions;
var featureOpts;
var styledMapOptions; // sets name to appear in box switch
var customMapID; // sets id to register with mapTypeIDs array.
var customMapType; // a map Class to apply to our map: takes in features(like colors) and options(like names)
var defaultMapID = "default"; // id to register to the mapTypeIDs array. will set to default
var defaultMapType;
// set up our default map options
mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeControl: true,
mapTypeId: customMapID,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DEFAULT,
position: google.maps.ControlPosition.RIGHT_TOP,
// set to default
mapTypeIds: [defaultMapID]
},
overviewMapControlOptions: {
opened: true
},
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.RIGHT_CENTER
},
zoomControl: true,
zoomControlOptions: {
position: google.maps.ControlPosition.RIGHT_CENTER
},
streetViewControl: true,
streetViewControlOptions: {
position: google.maps.ControlPosition.RIGHT_CENTER
},
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.BOTTOM_RIGHT
}
};
// create our map
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
defaultMapType = new google.maps.StyledMapType([], {name:'Base'});
map.mapTypes.set(defaultMapID, defaultMapType);
// set up our custom feature options
featureOpts = [
{
stylers: [
{ hue: '#890000' },
{ visibility: 'simplified' },
{ gamma: 0.5 },
{ weight: 0.5 }
]
},
{
elementType: 'labels',
stylers: [
{ visibility: 'off' }
]
},
{
featureType: 'water',
stylers: [
{ color: '#890000' }
]
}
];
customMapID = "customMapID";
// set up our default styled map options
styledMapOptions = {
name: 'Redworld'
};
// create a map type using our features and map options
customMapType = new google.maps.StyledMapType(featureOpts, styledMapOptions);
// set our map to use our new map type
map.mapTypeControlOptions.mapTypeIds.push(customMapID);
map.mapTypes.set(customMapID, customMapType);
// Recursive Print html of map features
function mapFeature(inFeatures){
var htmlString = "\n";
var i =0;
for (var index in inFeatures){
i++;
var features = inFeatures[index];
if (typeof features === 'string'){
htmlString += '<h3 class="headline">' + features + '</h3>';
htmlString+= '<div class="content">';
//htmlString += addSliderHml(features);
htmlString += addSliderHml(features);
htmlString += '</div>';
}
else{
// get title
htmlString += '<h3 class="headline">' + index + '</h3>';
htmlString += '<div class="content">\n';
htmlString += addSliderHml(index);
htmlString += '<div class="accordian">\n' + mapFeature(features) + '</div>';
htmlString+= '</div>\n';
}
}
htmlString +="";
return htmlString;
}
function addSliderHml(feature){
var htmlString = "\n";
// <div feature="road" styler="saturation" class="slider"></div>
//<span>Saturation: </span> <span id="road-saturation-label" class="feature-label">0</span>
htmlString += '<div class="settings">\n';
htmlString += '<h4>' + feature + '</h4> \n';
htmlString += '<div class="feature-tabs"><ul>\n';
htmlString += '<li><a href="#feature-label">Label</a></li>\n';
htmlString += '<li><a href="#feature-outline">outline</a></li>\n';
htmlString += '<li><a href="#feature-fill">fill</a></li>\n';
htmlString += '</ul>\n';
htmlString += '<div id="feature-label">dadadad</div><div id="feature-outline">ouou</div><div id="feature-fill">fififdad</div></div>\n';
htmlString += '<span>Saturation</span> <span id="' + feature + '-saturation-label" class="feature-label">0</span>\n';
htmlString += '<div feature="' + feature + '" styler="saturation" class="slider"></div>\n';
htmlString += '<span>Saturation</span> <span id="' + feature + '-saturation-label" class="feature-label">0</span>\n';
htmlString += '<div feature="' + feature + '" styler="saturation" class="slider"></div>\n';
htmlString += '<span>Saturation</span> <span id="' + feature + '-saturation-label" class="feature-label">0</span>\n';
htmlString += '<div feature="' + feature + '" styler="saturation" class="slider"></div>\n';
htmlString += '</div>\n';
return htmlString;
}
// bind the 'contentChanged event to the accordian action
$('.controls').bind('contentChanged', function() {
$( ".accordian" ).accordion({
collapsible: true,
'heightStyle':'content',
active: false,
activate: toggleSettings
});
$( ".slider" ).slider();
$( ".feature-tabs" ).tabs({
collapsible: true
});
});
$('#accordian').html('<div class="accordian">'+ mapFeature(mapFeatures) + '</div>');
$('.controls').trigger('contentChanged')
}
google.maps.event.addDomListener(window, 'load', initialize);
function toggleSettings(event, ui){
// opening
if(ui.newPanel.length !== 0){
ui.newPanel.fadeIn(300);
ui.newPanel.parent('.accordian').parents('.content').children('.settings').fadeOut();
}else{
ui.oldPanel.fadeOut(300);
ui.oldPanel.parent().parent('.content').children('.settings').fadeIn(300);
}
}