/** * Creates markup to insert a single map. * * @access private */ function create_tag($map, $overrides = array()) { $map = apply_filters('agm_google_maps-shortcode-create_tag', $map, $overrides); if (!$map['id']) { return ''; } $map = array_merge($map, $overrides); $elid = 'map-' . md5(microtime() . rand()); $content = apply_filters('agm_google_maps-shortcode-tag_content', '', $map); $rpl = '<div class="agm_google_maps" id="' . $elid . '">' . $content . '</div>'; $rpl .= '<script type="text/javascript">_agmMaps.push({selector: "#' . $elid . '", data: ' . json_encode($map) . '});</script>'; AgmDependencies::ensure_presence(); return $rpl; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $height = (int) $instance['height']; $height = $height ? $height : 200; // Apply default $width = (int) $instance['width']; $width = $width ? $width : 200; // Apply default $query = $instance['query']; $query_custom = $instance['query_custom']; $network = $instance['network']; $map_id = $instance['map_id']; $show_as_one = $instance['show_as_one']; $show_map = $instance['show_map']; $show_markers = $instance['show_markers']; $show_images = $instance['show_images']; $show_posts = $instance['show_posts']; $zoom = (int) $instance['zoom']; $maps = $this->get_maps($query, $query_custom, $map_id, $show_as_one, $network); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } if (is_array($maps)) { foreach ($maps as $map) { $selector = 'agm_widget_map_' . md5(microtime() . rand()); $map['show_posts'] = (int) $show_posts; $map['height'] = $height; $map['width'] = $width; $map['show_map'] = $show_map; $map['show_markers'] = $show_markers; $map['show_images'] = $show_images; if ($zoom) { $map['zoom'] = $zoom; } AgmDependencies::ensure_presence(); echo '<div class="agm-google_map-widget" id="' . $selector . '"></div>'; echo '<script type="text/javascript">_agmMaps[_agmMaps.length] = {selector: "#' . $selector . '", data: ' . json_encode($map) . '};</script>'; } } echo $after_widget; }