set_map_atts(); // Prints the iframe if ( isset( $_GET['sm_map_iframe'] ) ) { add_action( 'template_redirect', array( &$this, 'add_iframe_locations' ), 2 ); add_action( 'template_redirect', array( &$this, 'generate_iframe' ) ); } } /** * This loads all the attributes for the map itself * * 'map_width' * 'map_height' * 'default_lat' * 'default_lng' * 'zoom_level' * 'default_radius' * 'map_type' * 'special_text' * 'default_state' * 'default_country' * 'default_language' * 'default_domain' * 'map_stylesheet' * 'units' * 'autoload' * 'lock_default_location' * 'results_limit' * 'address_format' * 'powered_by' * 'enable_permalinks' * 'permalink_slug' * 'display_search' * 'map_pages' * 'adsense_for_maps' * 'adsense_pub_id' * 'adsense_channel_id' * 'adsense_max_ads' * * @since 2.4 */ function set_map_atts( $atts=array() ) { global $simple_map; $locations = ! empty ( $_GET['location_ids'] ) ? explode( ',', $_GET['location_ids'] ) : array(); // Do atts for iframes if ( isset( $_GET['sm_map_iframe'] ) ) { // Set atts from GET vars if ( ! empty( $_GET['map_width'] ) ) $atts['map_width'] = $_GET['map_width']; if ( ! empty( $_GET['map_height'] ) ) $atts['map_height'] = $_GET['map_height']; if ( ! empty( $_GET['pan_control'] ) ) $atts['panControl'] = $_GET['pan_control']; if ( ! empty( $_GET['zoom_control'] ) ) $atts['zoomControl'] = $_GET['zoom_control']; if ( ! empty( $_GET['scale_control'] ) ) $atts['scaleControl'] = $_GET['scale_control']; if ( ! empty( $_GET['street_view_control'] ) ) $atts['streetViewControl'] = $_GET['street_view_control']; if ( ! empty( $_GET['map_type_control'] ) ) $atts['mapTypeControl'] = $_GET['map_type_control']; if ( ! empty( $_GET['map_type'] ) ) $atts['mapType'] = $_GET['map_type']; if ( empty( $_GET['default_lat'] ) ) $atts['default_lat'] = get_post_meta( $locations[0], 'location_lat', true ); if ( empty( $_GET['default_lng'] ) ) $atts['default_lng'] = get_post_meta( $locations[0], 'location_lng', true ); if ( empty( $_GET['zoom_level'] ) ) $atts['zoom_level'] = 15; } // Default Options $defaults = $simple_map->get_options(); // Overwrite defaults with any vars passed in $merged_atts = wp_parse_args( $atts, $defaults ); // Kick back to property $this->map_atts = $merged_atts; } /** * Adds a location to the map * * @since 2.4 */ function add_location( $location ) { // $location can be a post object or a post ID. If its an object, grab the id if ( is_object( $location ) ) $location = $location->ID; // Build array of important post data if ( $location_data = get_metadata( 'post', $location ) ) { $location_array = array( 'id' => $location, 'lat' => ! empty( $location_data['location_lat'][0] ) ? $location_data['location_lat'][0] : false, 'lng' => ! empty( $location_data['location_lng'][0] ) ? $location_data['location_lng'][0] : false ); if ( $location_array['lat'] && $location_array['lng'] ) $this->locations[$location] = $location_array; } } /** * A wrapper for add_location for use when loading an iframe * * @since 2.4 */ function add_iframe_locations() { // Add locations from GET string in iframe embed $locations = ! empty ( $_GET['location_ids'] ) ? explode( ',', $_GET['location_ids'] ) : array(); foreach( $locations as $location ) { $this->add_location( $location ); } } /** * Returns the map code * * @since 2.4 */ function get_map() { } /** * Returns the link for the iframe embed * * @since 2.4 */ function get_iframe_embed() { $atts = $this->map_atts; $locations = array_keys( $this->locations ); $iframe = ''; return $iframe; } /** * Generates the actual iframe * * @since 1.0 */ function generate_iframe() { if ( ! empty( $_GET['sm_map_iframe'] ) ) { global $simple_map; $this->set_map_atts(); $atts = $this->map_atts; wp_enqueue_script('jquery'); ?>