( ! empty( $marker_text ) ) ? $marker_text : $marker_address, 'infowindow' => $show_infowindow, ) ), ); if ( empty( $markers ) ) { $markers = array(); } else { $markers = json_decode( urldecode( $markers ), TRUE ); if ( ! is_array( $markers ) ) { $markers = array(); } } foreach ( $markers as $index => $marker ) { /** * Filtering the included markers * * @param $marker ['marker_address'] string Address * @param $marker ['marker_text'] string Marker Text * @param $marker ['marker_img'] string Marker Image * @param $marker ['marker_size'] string Marker Size */ if ( ! empty( $marker['marker_address'] ) ) { $script_options['markers'][] = array( 'html' => ( ! empty( $marker['marker_text'] ) ) ? $marker['marker_text'] : $marker['marker_address'], 'address' => $marker['marker_address'], 'marker_img' => ( ! empty( $marker['marker_img'] ) ) ? wp_get_attachment_image_src( intval( $marker['marker_img'] ), 'thumbnail' ) : NULL, 'marker_size' => ( ! empty( $marker['marker_size'] ) ) ? array( $marker['marker_size'], $marker['marker_size'], ) : NULL, ); } } if ( ! empty( $zoom ) ) { $script_options['zoom'] = intval( $zoom ); } if ( ! empty( $type ) AND $provider == 'google' ) { $type = strtoupper( $type ); if ( in_array( $type, array( 'ROADMAP', 'SATELLITE', 'HYBRID', 'TERRAIN' ) ) ) { $script_options['maptype'] = $type; } } if ( ! empty( $map_bg_color ) ) { $script_options['mapBgColor'] = $map_bg_color; } if ( $custom_marker_img != '' ) { if ( is_numeric( $custom_marker_img ) ) { $custom_marker_img = wp_get_attachment_image_url( intval( $custom_marker_img ), 'thumbnail' ); } $custom_marker_size = intval( $custom_marker_size ); $script_options['icon'] = array( 'url' => $custom_marker_img, 'size' => array( $custom_marker_size, $custom_marker_size ), ); } if ( empty( $height ) ) { $height = 400; } $script_options['height'] = $height; if ( $provider == 'osm' ) { if ( ! empty( $layer_style ) ) { $script_options['style'] = $layer_style; } else { $script_options['style'] = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; // default value for empty case } } if ( $hide_controls ) { $script_options['hideControls'] = TRUE; } if ( $disable_zoom ) { $script_options['disableZoom'] = TRUE; } if ( $disable_dragging ) { $script_options['disableDragging'] = TRUE; } $script_options = apply_filters( 'us_maps_js_options', $script_options, get_the_ID(), $us_maps_index ); // Enqueue relevant scripts if ( $provider == 'osm' ) { if ( us_get_option( 'ajax_load_js', 0 ) == 0 ) { wp_enqueue_script( 'us-lmap' ); } } elseif ( $provider == 'google' ) { wp_enqueue_script( 'us-google-maps' ); if ( us_get_option( 'ajax_load_js', 0 ) == 0 ) { wp_enqueue_script( 'us-gmap' ); } } $inline_css = us_prepare_inline_css( array( 'background' => $map_bg_color, 'height' => $height . 'px', ) ); // Output the element $output = '
'; $output .= '
'; if ( $provider == 'google' AND $map_style_json != '' ) { $output .= '
'; } $output .= '
'; // If we are in front end editor mode, apply JS to maps if ( function_exists( 'vc_is_page_editable' ) AND vc_is_page_editable() ) { if ( $provider == 'osm' ) { $output .= ''; } else { $output .= ''; } } echo $output;