/**
     * Render an GEO microformat for the specified latitude and longitude
     *
     * @param float $latitude
     * @param float $longitude
     */
    public static function render($arguments = array())
    {
        // Arguments
        $defaults = array('echo' => true);
        $arguments = wp_parse_args($arguments, $defaults);
        // Options
        $options = Pronamic_Google_Maps_Maps::getOptions();
        $pgm = Pronamic_Google_Maps_Maps::getMetaData();
        $activeTypes = $options['active'];
        global $post;
        $active = isset($activeTypes[$post->post_type]) && $activeTypes[$post->post_type];
        // Active
        if ($active && $pgm->active) {
            $content = sprintf('
				<div class="geo">
					<abbr class="latitude" title="%.6f">%s</abbr>
					<abbr class="longitude" title="%.6f">%s</abbr>
				</div>', $pgm->latitude, Pronamic_Google_Maps_LatLng::convertToDegMinSec($pgm->latitude, Pronamic_Google_Maps_LatLng::DIRECTION_LATITUDE), $pgm->longitude, Pronamic_Google_Maps_LatLng::convertToDegMinSec($pgm->longitude, Pronamic_Google_Maps_LatLng::DIRECTION_LONGITUDE));
            if ($arguments['echo']) {
                echo $content;
            } else {
                return $content;
            }
        }
    }
Пример #2
0
 /**
  * Render an Google Maps for the current global post
  *
  * @param mixed $arguments
  */
 public static function render($arguments = array())
 {
     $defaults = array('width' => self::$defaultWidth, 'height' => self::$defaultHeight, 'static' => false, 'label' => null, 'color' => null, 'echo' => true, 'marker_options' => array(), 'map_options' => array());
     $arguments = wp_parse_args($arguments, $defaults);
     $options = Pronamic_Google_Maps_Maps::getOptions();
     $pgm = Pronamic_Google_Maps_Maps::getMetaData();
     $activeTypes = $options['active'];
     global $post;
     $active = isset($activeTypes[$post->post_type]) && $activeTypes[$post->post_type];
     if ($active && $pgm->active) {
         $info = new Pronamic_Google_Maps_Info();
         $info->title = $pgm->title;
         $info->description = $pgm->description;
         $info->latitude = $pgm->latitude;
         $info->longitude = $pgm->longitude;
         $info->width = $arguments['width'];
         $info->height = $arguments['height'];
         $info->static = filter_var($arguments['static'], FILTER_VALIDATE_BOOLEAN);
         $info->label = $arguments['label'];
         $info->color = $arguments['color'];
         // Marker options
         $marker_options = $arguments['marker_options'];
         $marker_options = apply_filters('pronamic_google_maps_marker_options', $marker_options);
         foreach ($marker_options as $key => $value) {
             $value = apply_filters('pronamic_google_maps_marker_options_' . $key, $value);
             $info->markerOptions->{$key} = $value;
         }
         // Map options
         $info->mapOptions->mapTypeId = $pgm->mapType;
         $info->mapOptions->zoom = $pgm->zoom;
         foreach ($arguments['map_options'] as $key => $value) {
             $value = apply_filters('pronamic_google_maps_map_options_' . $key, $value);
             $info->mapOptions->{$key} = $value;
         }
         $html = self::getMapHtml($info);
         if ($info->isDynamic()) {
             Pronamic_Google_Maps_Site::requireSiteScript();
         }
         if ($arguments['echo']) {
             echo $html;
         } else {
             return $html;
         }
     }
 }
Пример #3
0
 /**
  * Add the meta box
  */
 public static function addMetaBox()
 {
     $options = Pronamic_Google_Maps_Maps::getOptions();
     if (isset($options['active'])) {
         $types = $options['active'];
         if (is_array($types)) {
             foreach ($types as $name => $active) {
                 Pronamic_Google_Maps_MetaBox::register($name);
             }
         }
     }
 }