Add option to select Google Map type

This commit is contained in:
Brian Miyaji
2014-05-16 21:53:06 +10:00
parent 4ec64cd5ee
commit 38a4a321ba
3 changed files with 16 additions and 1 deletions

View File

@@ -10,7 +10,8 @@
var mapOptions = {
scrollwheel: false,
zoom: 12,
center: ll
center: ll,
mapTypeId: google.maps.MapTypeId[vars.map_type]
};
var map = new google.maps.Map($self[0], mapOptions)
var marker = new google.maps.Marker({

View File

@@ -54,6 +54,19 @@ class SP_Settings_General extends SP_Settings_Page {
'options' => $presets,
),
array(
'title' => __( 'Google Maps', 'sportspress' ),
'id' => 'sportspress_map_type',
'default' => 'ROADMAP',
'type' => 'select',
'options' => array(
'ROADMAP' => __( 'Default', 'sportspress' ),
'SATELLITE' => __( 'Satellite', 'sportspress' ),
'HYBRID' => __( 'Hybrid', 'sportspress' ),
'TERRAIN' => __( 'Terrain', 'sportspress' ),
),
),
array( 'type' => 'sectionend', 'id' => 'general_options' ),
array( 'title' => __( 'Styles and Scripts', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'script_styling_options' ),

View File

@@ -50,6 +50,7 @@ class SP_Frontend_Scripts {
if ( is_singular( 'sp_event' ) || is_tax( 'sp_venue' ) ):
wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true );
wp_enqueue_script( 'sp-maps', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/sp-maps.js', array( 'jquery', 'google-maps' ), time(), true );
wp_localize_script( 'sp-maps', 'vars', array( 'map_type' => strtoupper( get_option( 'sportspress_map_type', 'ROADMAP' ) ) ) );
endif;
// Localize scripts.