function styled_google_map_field_formatter_settings_form in Styled Google Map 7
Same name and namespace in other branches
- 7.2 styled_google_map.module \styled_google_map_field_formatter_settings_form()
Implements hook_field_formatter_settings_form().
File
- ./
styled_google_map.module, line 156 - Contains all hooks and functions for the Styled Google Map module.
Code
function styled_google_map_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
// Include CTools dependent to hide/show our form fields.
ctools_include('dependent');
$element = array();
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
// Set all available setting fields for the Styled Google Map.
if ($display['type'] == 'styled_google_map_map_formatter') {
$element['width'] = array(
'#type' => 'textfield',
'#title' => t('Width size'),
'#default_value' => $settings['width'],
'#description' => t('Map width written in pixels or percentage'),
'#required' => TRUE,
);
$element['height'] = array(
'#type' => 'textfield',
'#title' => t('Height size'),
'#default_value' => $settings['height'],
'#description' => t('Map height written in pixels or percentage'),
'#required' => TRUE,
);
$element['style'] = array(
'#type' => 'fieldset',
'#title' => t('Map style'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$element['style']['maptype'] = array(
'#type' => 'select',
'#options' => array(
'ROADMAP' => t('ROADMAP'),
'SATELLITE' => t('SATELLITE'),
'HYBRID' => t('HYBRID'),
'TERRAIN' => t('TERRAIN'),
),
'#title' => t('Map type'),
'#default_value' => $settings['style']['maptype'],
'#required' => TRUE,
);
$element['style']['style'] = array(
'#type' => 'textarea',
'#title' => t('JSON Style'),
'#default_value' => $settings['style']['style'],
'#description' => t('Check out !url for custom styles. Also check out this !project to style and edit Google Map JSON styles.', array(
'!url' => l(t('Snazzy maps'), 'http://snazzymaps.com/', array(
'attributes' => array(
'target' => '_blank',
),
)),
'!project' => l(t('Github page'), 'http://instrument.github.io/styled-maps-wizard/', array(
'attributes' => array(
'target' => '_blank',
),
)),
)),
);
$element['style']['pin'] = array(
'#type' => 'textfield',
'#title' => t('URL to the marker'),
'#default_value' => $settings['style']['pin'],
'#description' => t('URL to the marker image. You can use a !wrapper for the url. Ex. !example', array(
'!wrapper' => l(t('Stream wrapper'), 'https://drupal.org/project/system_stream_wrapper', array(
'attributes' => array(
'target' => '_blank',
),
)),
'!example' => STYLED_GOOGLE_MAP_DEFAULT_PIN,
)),
);
$element['map_center'] = array(
'#type' => 'fieldset',
'#title' => t('Centering map'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Retrieve all field names from the current entity bundle.
$fields = field_info_instances($form['#entity_type'], $form['#bundle']);
$center_options = array(
'' => t('Center automatically'),
);
foreach ($fields as $key => $map_field) {
if ($map_field['widget']['type'] == 'geofield_latlon' && $key != $field['field_name']) {
$center_options[$key] = $map_field['label'];
}
}
$element['map_center']['center_coordinates'] = array(
'#type' => 'select',
'#options' => $center_options,
'#default_value' => $settings['map_center']['center_coordinates'],
'#description' => t('To have map centered on other point than location you need to have another GeoField in your content type structure'),
);
$element['popup'] = array(
'#type' => 'fieldset',
'#title' => t('Marker popup'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$element['popup']['choice'] = array(
'#type' => 'select',
'#options' => array(
0 => t('None'),
1 => t('Field'),
2 => t('View mode'),
),
'#default_value' => $settings['popup']['choice'],
'#id' => 'edit-popup-choice-field',
);
// Retrieve view mode settings from the current entity bundle.
$view_mode_settings = field_view_mode_settings($instance['entity_type'], $form['#bundle']);
$view_modes = array();
// Loop the and put all available view modes in an array.
foreach ($view_mode_settings as $bundle_view_mode => $value) {
if ($value['custom_settings'] && $bundle_view_mode != $view_mode) {
$view_modes[$bundle_view_mode] = $bundle_view_mode;
}
}
$element['popup']['view_mode'] = array(
'#type' => 'select',
'#options' => $view_modes,
'#default_value' => $settings['popup']['view_mode'],
'#states' => array(
'visible' => array(
':input[id="edit-popup-choice-field"]' => array(
'value' => 2,
),
),
),
);
// Retrieve all field names from the current entity bundle.
$fields = array_keys(field_info_instances($form['#entity_type'], $form['#bundle']));
$element['popup']['text'] = array(
'#type' => 'select',
'#options' => array_combine($fields, $fields),
'#default_value' => $settings['popup']['text'],
'#states' => array(
'visible' => array(
':input[id="edit-popup-choice-field"]' => array(
'value' => 1,
),
),
),
);
$element['popup']['label'] = array(
'#type' => 'checkbox',
'#title' => t('Show field label'),
'#default_value' => $settings['popup']['label'],
'#states' => array(
'visible' => array(
':input[id="edit-popup-choice-field"]' => array(
'value' => 1,
),
),
),
);
$element['popup']['shadow_style'] = array(
'#type' => 'select',
'#title' => t('Shadow style'),
'#options' => array(
0,
1,
2,
),
'#description' => t('1: shadow behind, 2: shadow below, 0: no shadow'),
'#default_value' => $settings['popup']['shadow_style'],
);
$element['popup']['padding'] = array(
'#type' => 'textfield',
'#title' => t('Padding'),
'#field_suffix' => 'px',
'#default_value' => $settings['popup']['padding'],
);
$element['popup']['border_radius'] = array(
'#type' => 'textfield',
'#title' => t('Border radius'),
'#field_suffix' => 'px',
'#default_value' => $settings['popup']['border_radius'],
);
$element['popup']['border_width'] = array(
'#type' => 'textfield',
'#title' => t('Border width'),
'#field_suffix' => 'px',
'#default_value' => $settings['popup']['border_width'],
);
$element['popup']['border_color'] = array(
'#type' => 'textfield',
'#title' => t('Border color'),
'#field_suffix' => '#hex',
'#default_value' => $settings['popup']['border_color'],
);
$element['popup']['background_color'] = array(
'#type' => 'textfield',
'#title' => t('Background color'),
'#field_suffix' => '#hex',
'#default_value' => $settings['popup']['background_color'],
);
$element['popup']['min_width'] = array(
'#type' => 'textfield',
'#title' => t('Min width'),
'#field_suffix' => 'px (or auto)',
'#default_value' => $settings['popup']['min_width'],
);
$element['popup']['max_width'] = array(
'#type' => 'textfield',
'#title' => t('Max width'),
'#field_suffix' => 'px (or auto)',
'#default_value' => $settings['popup']['max_width'],
);
$element['popup']['min_height'] = array(
'#type' => 'textfield',
'#title' => t('Min height'),
'#field_suffix' => 'px (or auto)',
'#default_value' => $settings['popup']['min_height'],
);
$element['popup']['max_height'] = array(
'#type' => 'textfield',
'#title' => t('Max height'),
'#field_suffix' => 'px (or auto)',
'#default_value' => $settings['popup']['max_height'],
);
$element['popup']['arrow_style'] = array(
'#type' => 'select',
'#title' => t('Arrow style'),
'#options' => array(
0,
1,
2,
),
'#description' => t('1: left side visible, 2: right side visible, 0: both sides visible'),
'#default_value' => $settings['popup']['arrow_style'],
);
$element['popup']['arrow_size'] = array(
'#type' => 'textfield',
'#title' => t('Arrow size'),
'#field_suffix' => 'px',
'#default_value' => $settings['popup']['arrow_size'],
);
$element['popup']['arrow_position'] = array(
'#type' => 'textfield',
'#title' => t('Arrow position'),
'#field_suffix' => 'px',
'#default_value' => $settings['popup']['arrow_position'],
);
$element['popup']['disable_auto_pan'] = array(
'#type' => 'select',
'#title' => t('Auto pan'),
'#options' => array(
true => t('Yes'),
false => t('No'),
),
'#description' => t('Automatically center the pin on click'),
'#default_value' => $settings['popup']['disable_auto_pan'],
);
$element['popup']['hide_close_button'] = array(
'#type' => 'select',
'#title' => t('Hide close button'),
'#options' => array(
true => t('Yes'),
false => t('No'),
),
'#description' => t('Hide the popup close button'),
'#default_value' => $settings['popup']['hide_close_button'],
);
$element['popup']['disable_animation'] = array(
'#type' => 'select',
'#title' => t('Disable animation'),
'#options' => array(
true => t('Yes'),
false => t('No'),
),
'#description' => t('Disables the popup animation'),
'#default_value' => $settings['popup']['disable_animation'],
);
$element['popup']['classes']['content_container'] = array(
'#type' => 'textfield',
'#title' => t('Wrapper class'),
'#default_value' => $settings['popup']['classes']['content_container'],
);
$element['popup']['classes']['background'] = array(
'#type' => 'textfield',
'#title' => t('Background class'),
'#default_value' => $settings['popup']['classes']['background'],
);
$element['popup']['classes']['arrow'] = array(
'#type' => 'textfield',
'#title' => t('Arrow class'),
'#default_value' => $settings['popup']['classes']['arrow'],
);
$element['popup']['classes']['arrow_outer'] = array(
'#type' => 'textfield',
'#title' => t('Arrow outer class'),
'#default_value' => $settings['popup']['classes']['arrow_outer'],
);
$element['popup']['classes']['arrow_inner'] = array(
'#type' => 'textfield',
'#title' => t('Arrow inner class'),
'#default_value' => $settings['popup']['classes']['arrow_inner'],
);
$element['zoom'] = array(
'#type' => 'fieldset',
'#title' => t('Zoom'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$element['zoom']['default'] = array(
'#type' => 'select',
'#options' => range(1, 23),
'#title' => t('Default zoom level'),
'#default_value' => $settings['zoom']['default'],
'#description' => t('Should be between the Min and Max zoom level.'),
'#required' => TRUE,
);
$element['zoom']['max'] = array(
'#type' => 'select',
'#options' => range(1, 23),
'#title' => t('Max zoom level'),
'#default_value' => $settings['zoom']['max'],
'#description' => t('Should be greater then the Min zoom level.'),
'#required' => TRUE,
);
$element['zoom']['min'] = array(
'#type' => 'select',
'#options' => range(1, 23),
'#title' => t('Min zoom level'),
'#default_value' => $settings['zoom']['min'],
'#description' => t('Should be smaller then the Max zoom level.'),
'#required' => TRUE,
);
$element['maptypecontrol'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Map Type control'),
'#default_value' => $settings['maptypecontrol'],
);
$element['scalecontrol'] = array(
'#type' => 'checkbox',
'#title' => t('Enable scale control'),
'#default_value' => $settings['scalecontrol'],
);
$element['rotatecontrol'] = array(
'#type' => 'checkbox',
'#title' => t('Enable rotate control'),
'#default_value' => $settings['rotatecontrol'],
);
$element['draggable'] = array(
'#type' => 'checkbox',
'#title' => t('Enable dragging'),
'#default_value' => $settings['draggable'],
);
$element['mobile_draggable'] = array(
'#type' => 'checkbox',
'#title' => t('Enable mobile dragging'),
'#description' => t('Sometimes when the map covers big part of touch device screen draggable feature can cause inability to scroll the page'),
'#default_value' => $settings['mobile_draggable'],
);
$element['streetviewcontrol'] = array(
'#type' => 'checkbox',
'#title' => t('Enable street view control'),
'#default_value' => $settings['streetviewcontrol'],
);
$element['zoomcontrol'] = array(
'#type' => 'checkbox',
'#title' => t('Enable zoom control'),
'#default_value' => $settings['zoomcontrol'],
);
$element['scrollwheel'] = array(
'#type' => 'checkbox',
'#title' => t('Enable scrollwheel'),
'#default_value' => $settings['scrollwheel'],
);
}
return $element;
}