Google_Maps_Builder_Engine

Class Google_Maps_Builder_Engine.

Defined (1)

The class is defined in the following location(s).

/includes/class-gmb-engine.php  
  1. class Google_Maps_Builder_Engine extends Google_Maps_Builder_Core_Engine { 
  2.  
  3.  
  4. /** 
  5. * Google_Maps_Builder_Engine constructor. 
  6. */ 
  7. public function __construct() { 
  8.  
  9. parent::__construct(); 
  10.  
  11.  
  12.  
  13. /** 
  14. * Google Maps Builder Shortcode 
  15. * Google Maps output relies on the shortcode to display 
  16. * @param $atts 
  17. * @return string 
  18. */ 
  19. public function google_maps_shortcode( $atts ) { 
  20.  
  21. $atts = shortcode_atts( 
  22. array( 
  23. 'title' => '',  
  24. 'id' => '',  
  25. 'reference' => '',  
  26. ), $atts, 'google_maps' 
  27. ); 
  28.  
  29. //gather data for this shortcode 
  30. $post = get_post( $atts['id'] ); 
  31. $all_meta = get_post_custom( $atts['id'] ); 
  32.  
  33. $visual_info = maybe_unserialize( $all_meta['gmb_width_height'][0] ); 
  34. $lat_lng = maybe_unserialize( $all_meta['gmb_lat_lng'][0] ); 
  35.  
  36. //Put markers into an array for JS usage 
  37. $map_marker_array = array(); 
  38. $markers_repeatable = isset( $all_meta['gmb_markers_group'][0] ) ? maybe_unserialize( $all_meta['gmb_markers_group'][0] ) : ''; 
  39.  
  40. if ( is_array( $markers_repeatable ) ) { 
  41. foreach ( $markers_repeatable as $marker ) { 
  42. array_push( $map_marker_array, $marker ); 
  43.  
  44. //Send data for AJAX usage 
  45. //Add params to AJAX for Shortcode Usage 
  46. //@see: http://benjaminrojas.net/using-wp_localize_script-dynamically/ 
  47. $localized_data = apply_filters( 'gmb_localized_data', array( 
  48. $post->ID => array( 
  49. 'id' => $atts['id'],  
  50. 'map_params' => array( 
  51. 'title' => $post->post_title,  
  52. 'width' => $visual_info['width'],  
  53. 'height' => $visual_info['height'],  
  54. 'latitude' => $lat_lng['latitude'],  
  55. 'longitude' => $lat_lng['longitude'],  
  56. 'zoom' => ! empty( $all_meta['gmb_zoom'][0] ) ? $all_meta['gmb_zoom'][0] : '15',  
  57. 'default_marker' => apply_filters( 'gmb_default_marker', GMB_PLUGIN_URL . 'assets/img/spotlight-poi.png' ),  
  58. ),  
  59. 'map_controls' => array( 
  60. 'zoom_control' => ! empty( $all_meta['gmb_zoom_control'][0] ) ? strtoupper( $all_meta['gmb_zoom_control'][0] ) : 'STANDARD',  
  61. 'pan_control' => ! empty( $all_meta['gmb_pan'][0] ) ? $all_meta['gmb_pan'][0] : 'none',  
  62. 'map_type_control' => ! empty( $all_meta['gmb_map_type_control'][0] ) ? $all_meta['gmb_map_type_control'][0] : 'none',  
  63. 'draggable' => ! empty( $all_meta['gmb_draggable'][0] ) ? $all_meta['gmb_draggable'][0] : 'none',  
  64. 'double_click_zoom' => ! empty( $all_meta['gmb_double_click'][0] ) ? $all_meta['gmb_double_click'][0] : 'none',  
  65. 'wheel_zoom' => ! empty( $all_meta['gmb_wheel_zoom'][0] ) ? $all_meta['gmb_wheel_zoom'][0] : 'none',  
  66. 'street_view' => ! empty( $all_meta['gmb_street_view'][0] ) ? $all_meta['gmb_street_view'][0] : 'none',  
  67. ),  
  68. 'map_theme' => array( 
  69. 'map_type' => ! empty( $all_meta['gmb_type'][0] ) ? $all_meta['gmb_type'][0] : 'RoadMap',  
  70. 'map_theme_json' => ! empty( $all_meta['gmb_theme_json'][0] ) ? $all_meta['gmb_theme_json'][0] : 'none',  
  71.  
  72. ),  
  73. 'map_markers' => $map_marker_array,  
  74. 'plugin_url' => GMB_PLUGIN_URL,  
  75. 'places_api' => array( 
  76. 'show_places' => ! empty( $all_meta['gmb_show_places'][0] ) ? $all_meta['gmb_show_places'][0] : 'no',  
  77. 'search_radius' => ! empty( $all_meta['gmb_search_radius'][0] ) ? $all_meta['gmb_search_radius'][0] : '3000',  
  78. 'search_places' => ! empty( $all_meta['gmb_places_search_multicheckbox'][0] ) ? maybe_unserialize( $all_meta['gmb_places_search_multicheckbox'][0] ) : '',  
  79. ),  
  80. 'map_markers_icon' => ! empty( $all_meta['gmb_map_marker'] ) ? $all_meta['gmb_map_marker'][0] : 'none',  
  81. ) ); 
  82.  
  83. $this->array_push_localized_script( $localized_data ); 
  84.  
  85. ob_start(); 
  86.  
  87. include $this->get_google_maps_template( 'public.php' ); 
  88.  
  89. return apply_filters( 'gmb_shortcode_output', ob_get_clean() ); 
  90.  
  91.  
  92.