Custom Map Styles

Apply custom styles to a Map Field.

Instructions

  1. Install our free Custom Javascript for Gravity Forms plugin.
    Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
    
    1. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.

Code

Filename: gpaa-custom-map-styles.js

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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/**
 * Gravity Perks // GP Address Autocomplete // Custom Map Styles
 *
 * Apply custom styles to a Map Field.
 *
 * https://gravitywiz.com/documentation/gravity-forms-address-autocomplete
 *
 * Instructions:
 *     1. Install our free Custom Javascript for Gravity Forms plugin.
 *        Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
 *     2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
 */

window.gform.addFilter('gpaa_map_options', function(opts, formId, fieldId) {
	/**
	 * Array of google.map.MapTypeStyle objects
	 * @reference https://developers.google.com/maps/documentation/javascript/reference/map#MapTypeStyle
	 *
	 * You can customize this as you would like for custom map styles. For some pre-made styles, check out: https://snazzymaps.com/
	 * For instance, the default styles in this snippet come from this Snazzy Map style: https://snazzymaps.com/style/93/lost-in-the-desert
	 */
	opts.styles = [
    	{
    	    elementType: 'labels',
    	    stylers: [
    	        {
    	            'visibility': 'off'
    	        },
    	        {
    	            'color': '#f49f53'
    	        }
    	    ]
    	},
    	{
    	    featureType: 'landscape',
    	    stylers: [
    	        {
    	            'color': '#f9ddc5'
    	        },
    	        {
    	            'lightness': -7
    	        }
    	    ]
    	},
    	{
    	    featureType: 'road',
    	    stylers: [
    	        {
    	            'color': '#813033'
    	        },
    	        {
    	            'lightness': 43
    	        }
    	    ]
    	},
    	{
    	    featureType: 'poi.business',
    	    stylers: [
    	        {
    	            'color': '#645c20'
    	        },
    	        {
    	            'lightness': 38
    	        }
    	    ]
    	},
    	{
    	    featureType: 'water',
    	    stylers: [
    	        {
    	            'color': '#1994bf'
    	        },
    	        {
    	            'saturation': -69
    	        },
    	        {
    	            'gamma': 0.99
    	        },
    	        {
    	            'lightness': 43
    	        }
    	    ]
    	},
    	{
    	    featureType: 'road.local',
    	    elementType: 'geometry.fill',
    	    stylers: [
    	        {
    	            'color': '#f19f53'
    	        },
    	        {
    	            'weight': 1.3
    	        },
    	        {
    	            'visibility': 'on'
    	        },
    	        {
    	            'lightness': 16
    	        }
    	    ]
    	},
    	{
    	    featureType: 'poi.park',
    	    stylers: [
    	        {
    	            'color': '#645c20'
    	        },
    	        {
    	            'lightness': 39
    	        }
    	    ]
    	},
    	{
    	    featureType: 'poi.school',
    	    stylers: [
    	        {
    	            'color': '#a95521'
    	        },
    	        {
    	            'lightness': 35
    	        }
    	    ]
    	},
    	{
    	    featureType: 'poi.medical',
    	    elementType: 'geometry.fill',
    	    stylers: [
    	        {
    	            'color': '#813033'
    	        },
    	        {
    	            'lightness': 38
    	        },
    	        {
    	            'visibility': 'off'
    	        }
    	    ]
    	},
    	{
    	    featureType: 'poi.sports_complex',
    	    stylers: [
    	        {
    	            'color': '#9e5916'
    	        },
    	        {
    	            'lightness': 32
    	        }
    	    ]
    	},
    	{
    	    featureType: 'poi.government',
    	    stylers: [
    	        {
    	            'color': '#9e5916'
    	        },
    	        {
    	            'lightness': 46
    	        }
    	    ]
    	},
    	{
    	    featureType: 'transit.station',
    	    stylers: [
    	        {
    	            'visibility': 'off'
    	        }
    	    ]
    	},
    	{
    	    featureType: 'transit.line',
    	    stylers: [
    	        {
    	            'color': '#813033'
    	        },
    	        {
    	            'lightness': 22
    	        }
    	    ]
    	},
    	{
    	    featureType: 'transit',
    	    stylers: [
    	        {
    	            'lightness': 38
    	        }
    	    ]
    	},
    	{
    	    featureType: 'road.local',
    	    elementType: 'geometry.stroke',
    	    stylers: [
    	        {
    	            'color': '#f19f53'
    	        },
    	        {
    	            'lightness': -10
    	        }
    	    ]
    	},
	];

	return opts;
});

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.