From 98ea090b9fa66bc9295c97e0aaed1a62448a61ce Mon Sep 17 00:00:00 2001 From: rumperuu Date: Tue, 11 Apr 2017 07:22:35 +0000 Subject: [PATCH] Almost done --- 404.php | 24 +- comments.php | 79 +- footer.php | 10 + front-page.php | 116 --- functions.php | 285 +++++-- header.php | 16 + index.php | 16 +- js/markerclusterer.js | 1315 +++++++++++++++++++++++++++++ page-experience-by-companies.php | 66 +- page-experience-by-locations.php | 1 + page-experience.php | 92 +- page-home.php | 59 ++ page.php | 2 +- style.css | 458 +++++++--- taxonomy-company.php | 144 +--- template-parts/content-page.php | 13 +- template-parts/content-single.php | 113 +-- template-parts/content.php | 20 +- updateCompanies.php | 1 + 19 files changed, 2056 insertions(+), 774 deletions(-) delete mode 100644 front-page.php create mode 100644 js/markerclusterer.js create mode 100644 page-experience-by-locations.php create mode 100644 page-home.php create mode 100644 updateCompanies.php diff --git a/404.php b/404.php index 59907be..c275bb4 100644 --- a/404.php +++ b/404.php @@ -9,19 +9,17 @@ get_header(); ?> -
-
- -
- - -
-

- - -
+
+
+
+
+
+
+

404

+

That's ‘computer’ for Oops! Something went wrong!

+
+
+
diff --git a/comments.php b/comments.php index 9b1bc57..ec71e27 100644 --- a/comments.php +++ b/comments.php @@ -21,59 +21,40 @@ if ( post_password_required() ) { ?>
+
+
+

Comments

+ + - -

+
    + 'ol', + 'short_ping' => true, + 'avatar_size' => 42, + ) ); + ?> +
+ + + +

No comments yet.

+ -

- - - -
    +

    + +
+
'ol', - 'short_ping' => true, - 'avatar_size' => 42, + comment_form( array( + 'title_reply_before' => '

', + 'title_reply_after' => '

', ) ); ?> - - - - - - - -

- - - '

', - 'title_reply_after' => '

', - ) ); - ?> - +
+
diff --git a/footer.php b/footer.php index 1e0a78b..cf085b4 100644 --- a/footer.php +++ b/footer.php @@ -41,6 +41,16 @@ */ ?>
+ + diff --git a/front-page.php b/front-page.php deleted file mode 100644 index d469074..0000000 --- a/front-page.php +++ /dev/null @@ -1,116 +0,0 @@ - - class="no-js"> - - - - - - - - - - > -
-
-
-
-
- A picture of Ben Goldsworthy -
-
- -
- -
-
-

Personal

- -
-
- -
-
-

Portfolios

- -
-
- -
-
-

Experience

- -
-
- -
- -
- -
-
- - diff --git a/functions.php b/functions.php index a9263d3..8b15a44 100644 --- a/functions.php +++ b/functions.php @@ -1,6 +1,6 @@ 240, @@ -89,23 +87,23 @@ if ( ! function_exists( 'twentysixteen_setup' ) ) : // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( - 'primary' => __( 'Primary Menu', 'twentysixteen' ), - 'social' => __( 'Social Links Menu', 'twentysixteen' ), + 'primary' => __( 'Primary Menu', 'omphaloskepsis' ), + 'social' => __( 'Social Links Menu', 'omphaloskepsis' ), ) ); - function bengoldsworthy_infinite_scroll_init() { + function omphaloskepsis_infinite_scroll_init() { add_theme_support( 'infinite-scroll', array( 'container' => 'main', - 'render' => 'bengoldsworthy_infinite_scroll_render', + 'render' => 'omphaloskepsis_infinite_scroll_render', 'footer' => 'colophon', ) ); } -add_action( 'init', 'bengoldsworthy_infinite_scroll_init' ); +add_action( 'init', 'omphaloskepsis_infinite_scroll_init' ); /** * Custom render function for Infinite Scroll. */ -function bengoldsworthy_infinite_scroll_render() { +function omphaloskepsis_infinite_scroll_render() { while ( have_posts() ) { the_post(); if ( is_search() ) { @@ -149,13 +147,13 @@ function bengoldsworthy_infinite_scroll_render() { * This theme styles the visual editor to resemble the theme style, * specifically font, colors, icons, and column width. */ - add_editor_style( array( 'css/editor-style.css', twentysixteen_fonts_url() ) ); + add_editor_style( array( 'css/editor-style.css', omphaloskepsis_fonts_url() ) ); // Indicate widget sidebars can use selective refresh in the Customizer. add_theme_support( 'customize-selective-refresh-widgets' ); } -endif; // twentysixteen_setup -add_action( 'after_setup_theme', 'twentysixteen_setup' ); +endif; // omphaloskepsis_setup +add_action( 'after_setup_theme', 'omphaloskepsis_setup' ); /** * Sets the content width in pixels, based on the theme's design and stylesheet. @@ -164,25 +162,25 @@ add_action( 'after_setup_theme', 'twentysixteen_setup' ); * * @global int $content_width * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 */ -function twentysixteen_content_width() { - $GLOBALS['content_width'] = apply_filters( 'twentysixteen_content_width', 840 ); +function omphaloskepsis_content_width() { + $GLOBALS['content_width'] = apply_filters( 'omphaloskepsis_content_width', 840 ); } -add_action( 'after_setup_theme', 'twentysixteen_content_width', 0 ); +add_action( 'after_setup_theme', 'omphaloskepsis_content_width', 0 ); /** * Registers a widget area. * * @link https://developer.wordpress.org/reference/functions/register_sidebar/ * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 */ -function twentysixteen_widgets_init() { +function omphaloskepsis_widgets_init() { register_sidebar( array( - 'name' => __( 'Sidebar', 'twentysixteen' ), + 'name' => __( 'Sidebar', 'omphaloskepsis' ), 'id' => 'sidebar-1', - 'description' => __( 'Add widgets here to appear in your sidebar.', 'twentysixteen' ), + 'description' => __( 'Add widgets here to appear in your sidebar.', 'omphaloskepsis' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', @@ -190,9 +188,9 @@ function twentysixteen_widgets_init() { ) ); register_sidebar( array( - 'name' => __( 'Content Bottom 1', 'twentysixteen' ), + 'name' => __( 'Content Bottom 1', 'omphaloskepsis' ), 'id' => 'sidebar-2', - 'description' => __( 'Appears at the bottom of the content on posts and pages.', 'twentysixteen' ), + 'description' => __( 'Appears at the bottom of the content on posts and pages.', 'omphaloskepsis' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', @@ -200,44 +198,44 @@ function twentysixteen_widgets_init() { ) ); register_sidebar( array( - 'name' => __( 'Content Bottom 2', 'twentysixteen' ), + 'name' => __( 'Content Bottom 2', 'omphaloskepsis' ), 'id' => 'sidebar-3', - 'description' => __( 'Appears at the bottom of the content on posts and pages.', 'twentysixteen' ), + 'description' => __( 'Appears at the bottom of the content on posts and pages.', 'omphaloskepsis' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } -add_action( 'widgets_init', 'twentysixteen_widgets_init' ); +add_action( 'widgets_init', 'omphaloskepsis_widgets_init' ); -if ( ! function_exists( 'twentysixteen_fonts_url' ) ) : +if ( ! function_exists( 'omphaloskepsis_fonts_url' ) ) : /** - * Register Google fonts for Twenty Sixteen. + * Register Google fonts for Omphaloskepsis. * - * Create your own twentysixteen_fonts_url() function to override in a child theme. + * Create your own omphaloskepsis_fonts_url() function to override in a child theme. * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 * * @return string Google fonts URL for the theme. */ - function twentysixteen_fonts_url() { + function omphaloskepsis_fonts_url() { $fonts_url = ''; $fonts = array(); $subsets = 'latin,latin-ext'; /* translators: If there are characters in your language that are not supported by Merriweather, translate this to 'off'. Do not translate into your own language. */ - if ( 'off' !== _x( 'on', 'Merriweather font: on or off', 'twentysixteen' ) ) { + if ( 'off' !== _x( 'on', 'Merriweather font: on or off', 'omphaloskepsis' ) ) { $fonts[] = 'Merriweather:400,700,900,400italic,700italic,900italic'; } /* translators: If there are characters in your language that are not supported by Montserrat, translate this to 'off'. Do not translate into your own language. */ - if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'twentysixteen' ) ) { + if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'omphaloskepsis' ) ) { $fonts[] = 'Montserrat:400,700'; } /* translators: If there are characters in your language that are not supported by Inconsolata, translate this to 'off'. Do not translate into your own language. */ - if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'twentysixteen' ) ) { + if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'omphaloskepsis' ) ) { $fonts[] = 'Inconsolata:400'; } @@ -257,80 +255,80 @@ endif; * * Adds a `js` class to the root `` element when JavaScript is detected. * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 */ -function twentysixteen_javascript_detection() { +function omphaloskepsis_javascript_detection() { echo "\n"; } -add_action( 'wp_head', 'twentysixteen_javascript_detection', 0 ); +add_action( 'wp_head', 'omphaloskepsis_javascript_detection', 0 ); /** * Enqueues scripts and styles. * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 */ -function twentysixteen_scripts() { +function omphaloskepsis_scripts() { // Load the normalisation stylesheet. - wp_enqueue_style( 'twentysixteen-reset', get_template_directory_uri() . '/css/reset.css', array( ), null ); + wp_enqueue_style( 'omphaloskepsis-reset', get_template_directory_uri() . '/css/reset.css', array( ), null ); - wp_style_add_data( 'twentysixteen-ie', 'conditional', 'lt IE 10' ); + wp_style_add_data( 'omphaloskepsis-ie', 'conditional', 'lt IE 10' ); // Add custom fonts, used in the main stylesheet. - wp_enqueue_style( 'twentysixteen-fonts', twentysixteen_fonts_url(), array(), null ); + wp_enqueue_style( 'omphaloskepsis-fonts', omphaloskepsis_fonts_url(), array(), null ); // Add Genericons, used in the main stylesheet. wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.4.1' ); // Theme stylesheet. - wp_enqueue_style( 'twentysixteen-style', get_stylesheet_uri() ); + wp_enqueue_style( 'omphaloskepsis-style', get_stylesheet_uri() ); wp_enqueue_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'); wp_enqueue_style( 'montserrat', "https://fonts.googleapis.com/css?family=Montserrat" ); // Load the Internet Explorer specific stylesheet. - wp_enqueue_style( 'twentysixteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentysixteen-style' ), '20160412' ); - wp_style_add_data( 'twentysixteen-ie', 'conditional', 'lt IE 10' ); + wp_enqueue_style( 'omphaloskepsis-ie', get_template_directory_uri() . '/css/ie.css', array( 'omphaloskepsis-style' ), '20160412' ); + wp_style_add_data( 'omphaloskepsis-ie', 'conditional', 'lt IE 10' ); // Load the Internet Explorer 8 specific stylesheet. - wp_enqueue_style( 'twentysixteen-ie8', get_template_directory_uri() . '/css/ie8.css', array( 'twentysixteen-style' ), '20160412' ); - wp_style_add_data( 'twentysixteen-ie8', 'conditional', 'lt IE 9' ); + wp_enqueue_style( 'omphaloskepsis-ie8', get_template_directory_uri() . '/css/ie8.css', array( 'omphaloskepsis-style' ), '20160412' ); + wp_style_add_data( 'omphaloskepsis-ie8', 'conditional', 'lt IE 9' ); // Load the Internet Explorer 7 specific stylesheet. - wp_enqueue_style( 'twentysixteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentysixteen-style' ), '20160412' ); - wp_style_add_data( 'twentysixteen-ie7', 'conditional', 'lt IE 8' ); + wp_enqueue_style( 'omphaloskepsis-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'omphaloskepsis-style' ), '20160412' ); + wp_style_add_data( 'omphaloskepsis-ie7', 'conditional', 'lt IE 8' ); // Load the html5 shiv. - wp_enqueue_script( 'twentysixteen-html5', get_template_directory_uri() . '/js/html5.js', array(), '3.7.3' ); - wp_script_add_data( 'twentysixteen-html5', 'conditional', 'lt IE 9' ); + wp_enqueue_script( 'omphaloskepsis-html5', get_template_directory_uri() . '/js/html5.js', array(), '3.7.3' ); + wp_script_add_data( 'omphaloskepsis-html5', 'conditional', 'lt IE 9' ); - wp_enqueue_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20160412', true ); + wp_enqueue_script( 'omphaloskepsis-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20160412', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } if ( is_singular() && wp_attachment_is_image() ) { - wp_enqueue_script( 'twentysixteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20160412' ); + wp_enqueue_script( 'omphaloskepsis-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20160412' ); } - wp_enqueue_script( 'twentysixteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20160412', true ); + wp_enqueue_script( 'omphaloskepsis-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20160412', true ); - wp_localize_script( 'twentysixteen-script', 'screenReaderText', array( - 'expand' => __( 'expand child menu', 'twentysixteen' ), - 'collapse' => __( 'collapse child menu', 'twentysixteen' ), + wp_localize_script( 'omphaloskepsis-script', 'screenReaderText', array( + 'expand' => __( 'expand child menu', 'omphaloskepsis' ), + 'collapse' => __( 'collapse child menu', 'omphaloskepsis' ), ) ); } -add_action( 'wp_enqueue_scripts', 'twentysixteen_scripts' ); +add_action( 'wp_enqueue_scripts', 'omphaloskepsis_scripts' ); /** * Adds custom classes to the array of body classes. * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 * * @param array $classes Classes for the body element. * @return array (Maybe) filtered body classes. */ -function twentysixteen_body_classes( $classes ) { +function omphaloskepsis_body_classes( $classes ) { // Adds a class of custom-background-image to sites with a custom background image. if ( get_background_image() ) { $classes[] = 'custom-background-image'; @@ -353,18 +351,18 @@ function twentysixteen_body_classes( $classes ) { return $classes; } -add_filter( 'body_class', 'twentysixteen_body_classes' ); +add_filter( 'body_class', 'omphaloskepsis_body_classes' ); /** * Converts a HEX value to RGB. * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 * * @param string $color The original color, in 3- or 6-digit hexadecimal form. * @return array Array containing RGB (red, green, and blue) values for the given * HEX code, empty array otherwise. */ -function twentysixteen_hex2rgb( $color ) { +function omphaloskepsis_hex2rgb( $color ) { $color = trim( $color, '#' ); if ( strlen( $color ) === 3 ) { @@ -396,14 +394,14 @@ require get_template_directory() . '/inc/customizer.php'; * Add custom image sizes attribute to enhance responsive image functionality * for content images * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 * * @param string $sizes A source size value for use in a 'sizes' attribute. * @param array $size Image size. Accepts an array of width and height * values in pixels (in that order). * @return string A source size value for use in a content image 'sizes' attribute. */ -function twentysixteen_content_image_sizes_attr( $sizes, $size ) { +function omphaloskepsis_content_image_sizes_attr( $sizes, $size ) { $width = $size[0]; 840 <= $width && $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px'; @@ -417,40 +415,165 @@ function twentysixteen_content_image_sizes_attr( $sizes, $size ) { return $sizes; } -add_filter( 'wp_calculate_image_sizes', 'twentysixteen_content_image_sizes_attr', 10 , 2 ); +add_filter( 'wp_calculate_image_sizes', 'omphaloskepsis_content_image_sizes_attr', 10 , 2 ); /** * Add custom image sizes attribute to enhance responsive image functionality * for post thumbnails * - * @since Twenty Sixteen 1.0 + * @since Omphaloskepsis 1.0 * * @param array $attr Attributes for the image markup. * @param int $attachment Image attachment ID. * @param array $size Registered image size or flat array of height and width dimensions. * @return string A source size value for use in a post thumbnail 'sizes' attribute. */ -function twentysixteen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { +function omphaloskepsis_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { if ( 'post-thumbnail' === $size ) { is_active_sidebar( 'sidebar-1' ) && $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 60vw, (max-width: 1362px) 62vw, 840px'; ! is_active_sidebar( 'sidebar-1' ) && $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 88vw, 1200px'; } return $attr; } -add_filter( 'wp_get_attachment_image_attributes', 'twentysixteen_post_thumbnail_sizes_attr', 10 , 3 ); +add_filter( 'wp_get_attachment_image_attributes', 'omphaloskepsis_post_thumbnail_sizes_attr', 10 , 3 ); /** * Modifies tag cloud widget arguments to have all tags in the widget same font size. * - * @since Twenty Sixteen 1.1 + * @since Omphaloskepsis 1.1 * * @param array $args Arguments for tag cloud widget. * @return array A new modified arguments. */ -function twentysixteen_widget_tag_cloud_args( $args ) { +function omphaloskepsis_widget_tag_cloud_args( $args ) { $args['largest'] = 1; $args['smallest'] = 1; $args['unit'] = 'em'; return $args; } -add_filter( 'widget_tag_cloud_args', 'twentysixteen_widget_tag_cloud_args' ); +add_filter( 'widget_tag_cloud_args', 'omphaloskepsis_widget_tag_cloud_args' ); + +// +function omphaloskepsis_the_content($content) { + global $post; + if ($post->post_type == "program") { + $links = '

Links

'; + if ($meta = get_post_meta($post->ID, 'Link', true)) + $links = $links . 'Download'; + if ($meta = get_post_meta($post->ID, 'Documentation', true)) + $links = $links . 'Documentation'; + if ($meta = get_post_meta($post->ID, 'Repo', true)) + $links = $links . 'Repo'; + if ($meta = get_post_meta($post->ID, 'Licence', true)) + $links = $links . 'Licence'; + if ($meta = get_post_meta($post->ID, 'MD5', true)) + $links = $links . '

MD5 checksum: '.$meta.'

'; + return $content . $links; + } elseif ($post->post_type == "website") { + $links = '

Links

'; + if ($meta = get_post_meta($post->ID, 'Link', true)) + $links = $links . 'Visit'; + if ($meta = get_post_meta($post->ID, 'Repo', true)) + $links = $links . 'Repo'; + if ($meta = get_post_meta($post->ID, 'Licence', true)) + $links = $links . 'Licence'; + return '

Summary

' . $content . $links; + } elseif ($post->post_type == "writing") { + $links = '

Links

'; + if ($meta = get_post_meta($post->ID, 'Link', true)) + $links = $links . 'Read'; + if ($meta = get_post_meta($post->ID, 'Licence', true)) + $links = $links . 'Licence'; + return '

Summary

' . $content . $links; + } elseif ($post->post_type == "other") { + $links = '

Links

'; + if ($meta = get_post_meta($post->ID, 'Link', true)) + $links = $links . 'Download'; + return '

Summary

' . $content . $links; + } + return $content; +} + +add_filter('the_content', 'omphaloskepsis_the_content', 10); + +function display_companies() { + echo "'; + + die(); +} +add_action('wp_ajax_display_companies', 'display_companies'); +add_action('wp_ajax_display_companies', 'display_companies'); diff --git a/header.php b/header.php index 946ced0..c33118e 100644 --- a/header.php +++ b/header.php @@ -25,3 +25,19 @@
+ + + \ No newline at end of file diff --git a/index.php b/index.php index ef91378..4cf4362 100644 --- a/index.php +++ b/index.php @@ -13,21 +13,7 @@ * @subpackage Omphaloskepsis * @since Omphaloskepsis 1.0 */ -?> - - class="no-js"> - - - - - - - - - - - > -
+get_header(); ?> diff --git a/js/markerclusterer.js b/js/markerclusterer.js new file mode 100644 index 0000000..672798e --- /dev/null +++ b/js/markerclusterer.js @@ -0,0 +1,1315 @@ +// ==ClosureCompiler== +// @compilation_level ADVANCED_OPTIMIZATIONS +// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/maps/google_maps_api_v3_3.js +// ==/ClosureCompiler== + +/** + * @name MarkerClusterer for Google Maps v3 + * @version version 1.0.1 + * @author Luke Mahe + * @fileoverview + * The library creates and manages per-zoom-level clusters for large amounts of + * markers. + *
+ * This is a v3 implementation of the + * v2 MarkerClusterer. + */ + +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * A Marker Clusterer that clusters markers. + * + * @param {google.maps.Map} map The Google map to attach to. + * @param {Array.=} opt_markers Optional markers to add to + * the cluster. + * @param {Object=} opt_options support the following options: + * 'gridSize': (number) The grid size of a cluster in pixels. + * 'maxZoom': (number) The maximum zoom level that a marker can be part of a + * cluster. + * 'zoomOnClick': (boolean) Whether the default behaviour of clicking on a + * cluster is to zoom into it. + * 'imagePath': (string) The base URL where the images representing + * clusters will be found. The full URL will be: + * {imagePath}[1-5].{imageExtension} + * Default: '../images/m'. + * 'imageExtension': (string) The suffix for images URL representing + * clusters will be found. See _imagePath_ for details. + * Default: 'png'. + * 'averageCenter': (boolean) Wether the center of each cluster should be + * the average of all markers in the cluster. + * 'minimumClusterSize': (number) The minimum number of markers to be in a + * cluster before the markers are hidden and a count + * is shown. + * 'styles': (object) An object that has style properties: + * 'url': (string) The image url. + * 'height': (number) The image height. + * 'width': (number) The image width. + * 'anchor': (Array) The anchor position of the label text. + * 'textColor': (string) The text color. + * 'textSize': (number) The text size. + * 'backgroundPosition': (string) The position of the backgound x, y. + * @constructor + * @extends google.maps.OverlayView + */ +function MarkerClusterer(map, opt_markers, opt_options) { + // MarkerClusterer implements google.maps.OverlayView interface. We use the + // extend function to extend MarkerClusterer with google.maps.OverlayView + // because it might not always be available when the code is defined so we + // look for it at the last possible moment. If it doesn't exist now then + // there is no point going ahead :) + this.extend(MarkerClusterer, google.maps.OverlayView); + this.map_ = map; + + /** + * @type {Array.} + * @private + */ + this.markers_ = []; + + /** + * @type {Array.} + */ + this.clusters_ = []; + + this.sizes = [53, 56, 66, 78, 90]; + + /** + * @private + */ + this.styles_ = []; + + /** + * @type {boolean} + * @private + */ + this.ready_ = false; + + var options = opt_options || {}; + + /** + * @type {number} + * @private + */ + this.gridSize_ = options['gridSize'] || 60; + + /** + * @private + */ + this.minClusterSize_ = options['minimumClusterSize'] || 2; + + + /** + * @type {?number} + * @private + */ + this.maxZoom_ = options['maxZoom'] || null; + + this.styles_ = options['styles'] || []; + + /** + * @type {string} + * @private + */ + this.imagePath_ = options['imagePath'] || + this.MARKER_CLUSTER_IMAGE_PATH_; + + /** + * @type {string} + * @private + */ + this.imageExtension_ = options['imageExtension'] || + this.MARKER_CLUSTER_IMAGE_EXTENSION_; + + /** + * @type {boolean} + * @private + */ + this.zoomOnClick_ = true; + + if (options['zoomOnClick'] != undefined) { + this.zoomOnClick_ = options['zoomOnClick']; + } + + /** + * @type {boolean} + * @private + */ + this.averageCenter_ = false; + + if (options['averageCenter'] != undefined) { + this.averageCenter_ = options['averageCenter']; + } + + this.setupStyles_(); + + this.setMap(map); + + /** + * @type {number} + * @private + */ + this.prevZoom_ = this.map_.getZoom(); + + // Add the map event listeners + var that = this; + google.maps.event.addListener(this.map_, 'zoom_changed', function() { + // Determines map type and prevent illegal zoom levels + var zoom = that.map_.getZoom(); + var minZoom = that.map_.minZoom || 0; + var maxZoom = Math.min(that.map_.maxZoom || 100, + that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom); + zoom = Math.min(Math.max(zoom,minZoom),maxZoom); + + if (that.prevZoom_ != zoom) { + that.prevZoom_ = zoom; + that.resetViewport(); + } + }); + + google.maps.event.addListener(this.map_, 'idle', function() { + that.redraw(); + }); + + // Finally, add the markers + if (opt_markers && (opt_markers.length || Object.keys(opt_markers).length)) { + this.addMarkers(opt_markers, false); + } +} + + +/** + * The marker cluster image path. + * + * @type {string} + * @private + */ +MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_ = '../images/m'; + + +/** + * The marker cluster image path. + * + * @type {string} + * @private + */ +MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_ = 'png'; + + +/** + * Extends a objects prototype by anothers. + * + * @param {Object} obj1 The object to be extended. + * @param {Object} obj2 The object to extend with. + * @return {Object} The new extended object. + * @ignore + */ +MarkerClusterer.prototype.extend = function(obj1, obj2) { + return (function(object) { + for (var property in object.prototype) { + this.prototype[property] = object.prototype[property]; + } + return this; + }).apply(obj1, [obj2]); +}; + + +/** + * Implementaion of the interface method. + * @ignore + */ +MarkerClusterer.prototype.onAdd = function() { + this.setReady_(true); +}; + +/** + * Implementaion of the interface method. + * @ignore + */ +MarkerClusterer.prototype.draw = function() {}; + +/** + * Sets up the styles object. + * + * @private + */ +MarkerClusterer.prototype.setupStyles_ = function() { + if (this.styles_.length) { + return; + } + + for (var i = 0, size; size = this.sizes[i]; i++) { + this.styles_.push({ + url: this.imagePath_ + (i + 1) + '.' + this.imageExtension_, + height: size, + width: size + }); + } +}; + +/** + * Fit the map to the bounds of the markers in the clusterer. + */ +MarkerClusterer.prototype.fitMapToMarkers = function() { + var markers = this.getMarkers(); + var bounds = new google.maps.LatLngBounds(); + for (var i = 0, marker; marker = markers[i]; i++) { + bounds.extend(marker.getPosition()); + } + + this.map_.fitBounds(bounds); +}; + + +/** + * Sets the styles. + * + * @param {Object} styles The style to set. + */ +MarkerClusterer.prototype.setStyles = function(styles) { + this.styles_ = styles; +}; + + +/** + * Gets the styles. + * + * @return {Object} The styles object. + */ +MarkerClusterer.prototype.getStyles = function() { + return this.styles_; +}; + + +/** + * Whether zoom on click is set. + * + * @return {boolean} True if zoomOnClick_ is set. + */ +MarkerClusterer.prototype.isZoomOnClick = function() { + return this.zoomOnClick_; +}; + +/** + * Whether average center is set. + * + * @return {boolean} True if averageCenter_ is set. + */ +MarkerClusterer.prototype.isAverageCenter = function() { + return this.averageCenter_; +}; + + +/** + * Returns the array of markers in the clusterer. + * + * @return {Array.} The markers. + */ +MarkerClusterer.prototype.getMarkers = function() { + return this.markers_; +}; + + +/** + * Returns the number of markers in the clusterer + * + * @return {Number} The number of markers. + */ +MarkerClusterer.prototype.getTotalMarkers = function() { + return this.markers_.length; +}; + + +/** + * Sets the max zoom for the clusterer. + * + * @param {number} maxZoom The max zoom level. + */ +MarkerClusterer.prototype.setMaxZoom = function(maxZoom) { + this.maxZoom_ = maxZoom; +}; + + +/** + * Gets the max zoom for the clusterer. + * + * @return {number} The max zoom level. + */ +MarkerClusterer.prototype.getMaxZoom = function() { + return this.maxZoom_; +}; + + +/** + * The function for calculating the cluster icon image. + * + * @param {Array.} markers The markers in the clusterer. + * @param {number} numStyles The number of styles available. + * @return {Object} A object properties: 'text' (string) and 'index' (number). + * @private + */ +MarkerClusterer.prototype.calculator_ = function(markers, numStyles) { + var index = 0; + var count = markers.length; + var dv = count; + while (dv !== 0) { + dv = parseInt(dv / 10, 10); + index++; + } + + index = Math.min(index, numStyles); + return { + text: count, + index: index + }; +}; + + +/** + * Set the calculator function. + * + * @param {function(Array, number)} calculator The function to set as the + * calculator. The function should return a object properties: + * 'text' (string) and 'index' (number). + * + */ +MarkerClusterer.prototype.setCalculator = function(calculator) { + this.calculator_ = calculator; +}; + + +/** + * Get the calculator function. + * + * @return {function(Array, number)} the calculator function. + */ +MarkerClusterer.prototype.getCalculator = function() { + return this.calculator_; +}; + + +/** + * Add an array of markers to the clusterer. + * + * @param {Array.} markers The markers to add. + * @param {boolean=} opt_nodraw Whether to redraw the clusters. + */ +MarkerClusterer.prototype.addMarkers = function(markers, opt_nodraw) { + if (markers.length) { + for (var i = 0, marker; marker = markers[i]; i++) { + this.pushMarkerTo_(marker); + } + } else if (Object.keys(markers).length) { + for (var marker in markers) { + this.pushMarkerTo_(markers[marker]); + } + } + if (!opt_nodraw) { + this.redraw(); + } +}; + + +/** + * Pushes a marker to the clusterer. + * + * @param {google.maps.Marker} marker The marker to add. + * @private + */ +MarkerClusterer.prototype.pushMarkerTo_ = function(marker) { + marker.isAdded = false; + if (marker['draggable']) { + // If the marker is draggable add a listener so we update the clusters on + // the drag end. + var that = this; + google.maps.event.addListener(marker, 'dragend', function() { + marker.isAdded = false; + that.repaint(); + }); + } + this.markers_.push(marker); +}; + + +/** + * Adds a marker to the clusterer and redraws if needed. + * + * @param {google.maps.Marker} marker The marker to add. + * @param {boolean=} opt_nodraw Whether to redraw the clusters. + */ +MarkerClusterer.prototype.addMarker = function(marker, opt_nodraw) { + this.pushMarkerTo_(marker); + if (!opt_nodraw) { + this.redraw(); + } +}; + + +/** + * Removes a marker and returns true if removed, false if not + * + * @param {google.maps.Marker} marker The marker to remove + * @return {boolean} Whether the marker was removed or not + * @private + */ +MarkerClusterer.prototype.removeMarker_ = function(marker) { + var index = -1; + if (this.markers_.indexOf) { + index = this.markers_.indexOf(marker); + } else { + for (var i = 0, m; m = this.markers_[i]; i++) { + if (m == marker) { + index = i; + break; + } + } + } + + if (index == -1) { + // Marker is not in our list of markers. + return false; + } + + marker.setMap(null); + + this.markers_.splice(index, 1); + + return true; +}; + + +/** + * Remove a marker from the cluster. + * + * @param {google.maps.Marker} marker The marker to remove. + * @param {boolean=} opt_nodraw Optional boolean to force no redraw. + * @return {boolean} True if the marker was removed. + */ +MarkerClusterer.prototype.removeMarker = function(marker, opt_nodraw) { + var removed = this.removeMarker_(marker); + + if (!opt_nodraw && removed) { + this.resetViewport(); + this.redraw(); + return true; + } else { + return false; + } +}; + + +/** + * Removes an array of markers from the cluster. + * + * @param {Array.} markers The markers to remove. + * @param {boolean=} opt_nodraw Optional boolean to force no redraw. + */ +MarkerClusterer.prototype.removeMarkers = function(markers, opt_nodraw) { + var removed = false; + + for (var i = 0, marker; marker = markers[i]; i++) { + var r = this.removeMarker_(marker); + removed = removed || r; + } + + if (!opt_nodraw && removed) { + this.resetViewport(); + this.redraw(); + return true; + } +}; + + +/** + * Sets the clusterer's ready state. + * + * @param {boolean} ready The state. + * @private + */ +MarkerClusterer.prototype.setReady_ = function(ready) { + if (!this.ready_) { + this.ready_ = ready; + this.createClusters_(); + } +}; + + +/** + * Returns the number of clusters in the clusterer. + * + * @return {number} The number of clusters. + */ +MarkerClusterer.prototype.getTotalClusters = function() { + return this.clusters_.length; +}; + + +/** + * Returns the google map that the clusterer is associated with. + * + * @return {google.maps.Map} The map. + */ +MarkerClusterer.prototype.getMap = function() { + return this.map_; +}; + + +/** + * Sets the google map that the clusterer is associated with. + * + * @param {google.maps.Map} map The map. + */ +MarkerClusterer.prototype.setMap = function(map) { + this.map_ = map; +}; + + +/** + * Returns the size of the grid. + * + * @return {number} The grid size. + */ +MarkerClusterer.prototype.getGridSize = function() { + return this.gridSize_; +}; + + +/** + * Sets the size of the grid. + * + * @param {number} size The grid size. + */ +MarkerClusterer.prototype.setGridSize = function(size) { + this.gridSize_ = size; +}; + + +/** + * Returns the min cluster size. + * + * @return {number} The grid size. + */ +MarkerClusterer.prototype.getMinClusterSize = function() { + return this.minClusterSize_; +}; + +/** + * Sets the min cluster size. + * + * @param {number} size The grid size. + */ +MarkerClusterer.prototype.setMinClusterSize = function(size) { + this.minClusterSize_ = size; +}; + + +/** + * Extends a bounds object by the grid size. + * + * @param {google.maps.LatLngBounds} bounds The bounds to extend. + * @return {google.maps.LatLngBounds} The extended bounds. + */ +MarkerClusterer.prototype.getExtendedBounds = function(bounds) { + var projection = this.getProjection(); + + // Turn the bounds into latlng. + var tr = new google.maps.LatLng(bounds.getNorthEast().lat(), + bounds.getNorthEast().lng()); + var bl = new google.maps.LatLng(bounds.getSouthWest().lat(), + bounds.getSouthWest().lng()); + + // Convert the points to pixels and the extend out by the grid size. + var trPix = projection.fromLatLngToDivPixel(tr); + trPix.x += this.gridSize_; + trPix.y -= this.gridSize_; + + var blPix = projection.fromLatLngToDivPixel(bl); + blPix.x -= this.gridSize_; + blPix.y += this.gridSize_; + + // Convert the pixel points back to LatLng + var ne = projection.fromDivPixelToLatLng(trPix); + var sw = projection.fromDivPixelToLatLng(blPix); + + // Extend the bounds to contain the new bounds. + bounds.extend(ne); + bounds.extend(sw); + + return bounds; +}; + + +/** + * Determins if a marker is contained in a bounds. + * + * @param {google.maps.Marker} marker The marker to check. + * @param {google.maps.LatLngBounds} bounds The bounds to check against. + * @return {boolean} True if the marker is in the bounds. + * @private + */ +MarkerClusterer.prototype.isMarkerInBounds_ = function(marker, bounds) { + return bounds.contains(marker.getPosition()); +}; + + +/** + * Clears all clusters and markers from the clusterer. + */ +MarkerClusterer.prototype.clearMarkers = function() { + this.resetViewport(true); + + // Set the markers a empty array. + this.markers_ = []; +}; + + +/** + * Clears all existing clusters and recreates them. + * @param {boolean} opt_hide To also hide the marker. + */ +MarkerClusterer.prototype.resetViewport = function(opt_hide) { + // Remove all the clusters + for (var i = 0, cluster; cluster = this.clusters_[i]; i++) { + cluster.remove(); + } + + // Reset the markers to not be added and to be invisible. + for (var i = 0, marker; marker = this.markers_[i]; i++) { + marker.isAdded = false; + if (opt_hide) { + marker.setMap(null); + } + } + + this.clusters_ = []; +}; + +/** + * + */ +MarkerClusterer.prototype.repaint = function() { + var oldClusters = this.clusters_.slice(); + this.clusters_.length = 0; + this.resetViewport(); + this.redraw(); + + // Remove the old clusters. + // Do it in a timeout so the other clusters have been drawn first. + window.setTimeout(function() { + for (var i = 0, cluster; cluster = oldClusters[i]; i++) { + cluster.remove(); + } + }, 0); +}; + + +/** + * Redraws the clusters. + */ +MarkerClusterer.prototype.redraw = function() { + this.createClusters_(); +}; + + +/** + * Calculates the distance between two latlng locations in km. + * @see http://www.movable-type.co.uk/scripts/latlong.html + * + * @param {google.maps.LatLng} p1 The first lat lng point. + * @param {google.maps.LatLng} p2 The second lat lng point. + * @return {number} The distance between the two points in km. + * @private +*/ +MarkerClusterer.prototype.distanceBetweenPoints_ = function(p1, p2) { + if (!p1 || !p2) { + return 0; + } + + var R = 6371; // Radius of the Earth in km + var dLat = (p2.lat() - p1.lat()) * Math.PI / 180; + var dLon = (p2.lng() - p1.lng()) * Math.PI / 180; + var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos(p1.lat() * Math.PI / 180) * Math.cos(p2.lat() * Math.PI / 180) * + Math.sin(dLon / 2) * Math.sin(dLon / 2); + var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + var d = R * c; + return d; +}; + + +/** + * Add a marker to a cluster, or creates a new cluster. + * + * @param {google.maps.Marker} marker The marker to add. + * @private + */ +MarkerClusterer.prototype.addToClosestCluster_ = function(marker) { + var distance = 40000; // Some large number + var clusterToAddTo = null; + var pos = marker.getPosition(); + for (var i = 0, cluster; cluster = this.clusters_[i]; i++) { + var center = cluster.getCenter(); + if (center) { + var d = this.distanceBetweenPoints_(center, marker.getPosition()); + if (d < distance) { + distance = d; + clusterToAddTo = cluster; + } + } + } + + if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) { + clusterToAddTo.addMarker(marker); + } else { + var cluster = new Cluster(this); + cluster.addMarker(marker); + this.clusters_.push(cluster); + } +}; + + +/** + * Creates the clusters. + * + * @private + */ +MarkerClusterer.prototype.createClusters_ = function() { + if (!this.ready_) { + return; + } + + // Get our current map view bounds. + // Create a new bounds object so we don't affect the map. + var mapBounds = new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(), + this.map_.getBounds().getNorthEast()); + var bounds = this.getExtendedBounds(mapBounds); + + for (var i = 0, marker; marker = this.markers_[i]; i++) { + if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds)) { + this.addToClosestCluster_(marker); + } + } +}; + + +/** + * A cluster that contains markers. + * + * @param {MarkerClusterer} markerClusterer The markerclusterer that this + * cluster is associated with. + * @constructor + * @ignore + */ +function Cluster(markerClusterer) { + this.markerClusterer_ = markerClusterer; + this.map_ = markerClusterer.getMap(); + this.gridSize_ = markerClusterer.getGridSize(); + this.minClusterSize_ = markerClusterer.getMinClusterSize(); + this.averageCenter_ = markerClusterer.isAverageCenter(); + this.center_ = null; + this.markers_ = []; + this.bounds_ = null; + this.clusterIcon_ = new ClusterIcon(this, markerClusterer.getStyles(), + markerClusterer.getGridSize()); +} + +/** + * Determins if a marker is already added to the cluster. + * + * @param {google.maps.Marker} marker The marker to check. + * @return {boolean} True if the marker is already added. + */ +Cluster.prototype.isMarkerAlreadyAdded = function(marker) { + if (this.markers_.indexOf) { + return this.markers_.indexOf(marker) != -1; + } else { + for (var i = 0, m; m = this.markers_[i]; i++) { + if (m == marker) { + return true; + } + } + } + return false; +}; + + +/** + * Add a marker the cluster. + * + * @param {google.maps.Marker} marker The marker to add. + * @return {boolean} True if the marker was added. + */ +Cluster.prototype.addMarker = function(marker) { + if (this.isMarkerAlreadyAdded(marker)) { + return false; + } + + if (!this.center_) { + this.center_ = marker.getPosition(); + this.calculateBounds_(); + } else { + if (this.averageCenter_) { + var l = this.markers_.length + 1; + var lat = (this.center_.lat() * (l-1) + marker.getPosition().lat()) / l; + var lng = (this.center_.lng() * (l-1) + marker.getPosition().lng()) / l; + this.center_ = new google.maps.LatLng(lat, lng); + this.calculateBounds_(); + } + } + + marker.isAdded = true; + this.markers_.push(marker); + + var len = this.markers_.length; + if (len < this.minClusterSize_ && marker.getMap() != this.map_) { + // Min cluster size not reached so show the marker. + marker.setMap(this.map_); + } + + if (len == this.minClusterSize_) { + // Hide the markers that were showing. + for (var i = 0; i < len; i++) { + this.markers_[i].setMap(null); + } + } + + if (len >= this.minClusterSize_) { + marker.setMap(null); + } + + this.updateIcon(); + return true; +}; + + +/** + * Returns the marker clusterer that the cluster is associated with. + * + * @return {MarkerClusterer} The associated marker clusterer. + */ +Cluster.prototype.getMarkerClusterer = function() { + return this.markerClusterer_; +}; + + +/** + * Returns the bounds of the cluster. + * + * @return {google.maps.LatLngBounds} the cluster bounds. + */ +Cluster.prototype.getBounds = function() { + var bounds = new google.maps.LatLngBounds(this.center_, this.center_); + var markers = this.getMarkers(); + for (var i = 0, marker; marker = markers[i]; i++) { + bounds.extend(marker.getPosition()); + } + return bounds; +}; + + +/** + * Removes the cluster + */ +Cluster.prototype.remove = function() { + this.clusterIcon_.remove(); + this.markers_.length = 0; + delete this.markers_; +}; + + +/** + * Returns the center of the cluster. + * + * @return {number} The cluster center. + */ +Cluster.prototype.getSize = function() { + return this.markers_.length; +}; + + +/** + * Returns the center of the cluster. + * + * @return {Array.} The cluster center. + */ +Cluster.prototype.getMarkers = function() { + return this.markers_; +}; + + +/** + * Returns the center of the cluster. + * + * @return {google.maps.LatLng} The cluster center. + */ +Cluster.prototype.getCenter = function() { + return this.center_; +}; + + +/** + * Calculated the extended bounds of the cluster with the grid. + * + * @private + */ +Cluster.prototype.calculateBounds_ = function() { + var bounds = new google.maps.LatLngBounds(this.center_, this.center_); + this.bounds_ = this.markerClusterer_.getExtendedBounds(bounds); +}; + + +/** + * Determines if a marker lies in the clusters bounds. + * + * @param {google.maps.Marker} marker The marker to check. + * @return {boolean} True if the marker lies in the bounds. + */ +Cluster.prototype.isMarkerInClusterBounds = function(marker) { + return this.bounds_.contains(marker.getPosition()); +}; + + +/** + * Returns the map that the cluster is associated with. + * + * @return {google.maps.Map} The map. + */ +Cluster.prototype.getMap = function() { + return this.map_; +}; + + +/** + * Updates the cluster icon + */ +Cluster.prototype.updateIcon = function() { + var zoom = this.map_.getZoom(); + var mz = this.markerClusterer_.getMaxZoom(); + + if (mz && zoom > mz) { + // The zoom is greater than our max zoom so show all the markers in cluster. + for (var i = 0, marker; marker = this.markers_[i]; i++) { + marker.setMap(this.map_); + } + return; + } + + if (this.markers_.length < this.minClusterSize_) { + // Min cluster size not yet reached. + this.clusterIcon_.hide(); + return; + } + + var numStyles = this.markerClusterer_.getStyles().length; + var sums = this.markerClusterer_.getCalculator()(this.markers_, numStyles); + this.clusterIcon_.setCenter(this.center_); + this.clusterIcon_.setSums(sums); + this.clusterIcon_.show(); +}; + + +/** + * A cluster icon + * + * @param {Cluster} cluster The cluster to be associated with. + * @param {Object} styles An object that has style properties: + * 'url': (string) The image url. + * 'height': (number) The image height. + * 'width': (number) The image width. + * 'anchor': (Array) The anchor position of the label text. + * 'textColor': (string) The text color. + * 'textSize': (number) The text size. + * 'backgroundPosition: (string) The background postition x, y. + * @param {number=} opt_padding Optional padding to apply to the cluster icon. + * @constructor + * @extends google.maps.OverlayView + * @ignore + */ +function ClusterIcon(cluster, styles, opt_padding) { + cluster.getMarkerClusterer().extend(ClusterIcon, google.maps.OverlayView); + + this.styles_ = styles; + this.padding_ = opt_padding || 0; + this.cluster_ = cluster; + this.center_ = null; + this.map_ = cluster.getMap(); + this.div_ = null; + this.sums_ = null; + this.visible_ = false; + + this.setMap(this.map_); +} + + +/** + * Triggers the clusterclick event and zoom's if the option is set. + */ +ClusterIcon.prototype.triggerClusterClick = function() { + var markerClusterer = this.cluster_.getMarkerClusterer(); + + // Trigger the clusterclick event. + google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_); + + if (markerClusterer.isZoomOnClick()) { + // Zoom into the cluster. + this.map_.fitBounds(this.cluster_.getBounds()); + } +}; + + +/** + * Adding the cluster icon to the dom. + * @ignore + */ +ClusterIcon.prototype.onAdd = function() { + this.div_ = document.createElement('DIV'); + if (this.visible_) { + var pos = this.getPosFromLatLng_(this.center_); + this.div_.style.cssText = this.createCss(pos); + this.div_.innerHTML = this.sums_.text; + } + + var panes = this.getPanes(); + panes.overlayMouseTarget.appendChild(this.div_); + + var that = this; + google.maps.event.addDomListener(this.div_, 'click', function() { + that.triggerClusterClick(); + }); +}; + + +/** + * Returns the position to place the div dending on the latlng. + * + * @param {google.maps.LatLng} latlng The position in latlng. + * @return {google.maps.Point} The position in pixels. + * @private + */ +ClusterIcon.prototype.getPosFromLatLng_ = function(latlng) { + var pos = this.getProjection().fromLatLngToDivPixel(latlng); + pos.x -= parseInt(this.width_ / 2, 10); + pos.y -= parseInt(this.height_ / 2, 10); + return pos; +}; + + +/** + * Draw the icon. + * @ignore + */ +ClusterIcon.prototype.draw = function() { + if (this.visible_) { + var pos = this.getPosFromLatLng_(this.center_); + this.div_.style.top = pos.y + 'px'; + this.div_.style.left = pos.x + 'px'; + } +}; + + +/** + * Hide the icon. + */ +ClusterIcon.prototype.hide = function() { + if (this.div_) { + this.div_.style.display = 'none'; + } + this.visible_ = false; +}; + + +/** + * Position and show the icon. + */ +ClusterIcon.prototype.show = function() { + if (this.div_) { + var pos = this.getPosFromLatLng_(this.center_); + this.div_.style.cssText = this.createCss(pos); + this.div_.style.display = ''; + } + this.visible_ = true; +}; + + +/** + * Remove the icon from the map + */ +ClusterIcon.prototype.remove = function() { + this.setMap(null); +}; + + +/** + * Implementation of the onRemove interface. + * @ignore + */ +ClusterIcon.prototype.onRemove = function() { + if (this.div_ && this.div_.parentNode) { + this.hide(); + this.div_.parentNode.removeChild(this.div_); + this.div_ = null; + } +}; + + +/** + * Set the sums of the icon. + * + * @param {Object} sums The sums containing: + * 'text': (string) The text to display in the icon. + * 'index': (number) The style index of the icon. + */ +ClusterIcon.prototype.setSums = function(sums) { + this.sums_ = sums; + this.text_ = sums.text; + this.index_ = sums.index; + if (this.div_) { + this.div_.innerHTML = sums.text; + } + + this.useStyle(); +}; + + +/** + * Sets the icon to the the styles. + */ +ClusterIcon.prototype.useStyle = function() { + var index = Math.max(0, this.sums_.index - 1); + index = Math.min(this.styles_.length - 1, index); + var style = this.styles_[index]; + this.url_ = style['url']; + this.height_ = style['height']; + this.width_ = style['width']; + this.textColor_ = style['textColor']; + this.anchor_ = style['anchor']; + this.textSize_ = style['textSize']; + this.backgroundPosition_ = style['backgroundPosition']; +}; + + +/** + * Sets the center of the icon. + * + * @param {google.maps.LatLng} center The latlng to set as the center. + */ +ClusterIcon.prototype.setCenter = function(center) { + this.center_ = center; +}; + + +/** + * Create the css text based on the position of the icon. + * + * @param {google.maps.Point} pos The position. + * @return {string} The css style text. + */ +ClusterIcon.prototype.createCss = function(pos) { + var style = []; + style.push('background-image:url(' + this.url_ + ');'); + var backgroundPosition = this.backgroundPosition_ ? this.backgroundPosition_ : '0 0'; + style.push('background-position:' + backgroundPosition + ';'); + + if (typeof this.anchor_ === 'object') { + if (typeof this.anchor_[0] === 'number' && this.anchor_[0] > 0 && + this.anchor_[0] < this.height_) { + style.push('height:' + (this.height_ - this.anchor_[0]) + + 'px; padding-top:' + this.anchor_[0] + 'px;'); + } else { + style.push('height:' + this.height_ + 'px; line-height:' + this.height_ + + 'px;'); + } + if (typeof this.anchor_[1] === 'number' && this.anchor_[1] > 0 && + this.anchor_[1] < this.width_) { + style.push('width:' + (this.width_ - this.anchor_[1]) + + 'px; padding-left:' + this.anchor_[1] + 'px;'); + } else { + style.push('width:' + this.width_ + 'px; text-align:center;'); + } + } else { + style.push('height:' + this.height_ + 'px; line-height:' + + this.height_ + 'px; width:' + this.width_ + 'px; text-align:center;'); + } + + var txtColor = this.textColor_ ? this.textColor_ : 'black'; + var txtSize = this.textSize_ ? this.textSize_ : 11; + + style.push('cursor:pointer; top:' + pos.y + 'px; left:' + + pos.x + 'px; color:' + txtColor + '; position:absolute; font-size:' + + txtSize + 'px; font-family:Arial,sans-serif; font-weight:bold'); + return style.join(''); +}; + + +// Export Symbols for Closure +// If you are not going to compile with closure then you can remove the +// code below. +window['MarkerClusterer'] = MarkerClusterer; +MarkerClusterer.prototype['addMarker'] = MarkerClusterer.prototype.addMarker; +MarkerClusterer.prototype['addMarkers'] = MarkerClusterer.prototype.addMarkers; +MarkerClusterer.prototype['clearMarkers'] = + MarkerClusterer.prototype.clearMarkers; +MarkerClusterer.prototype['fitMapToMarkers'] = + MarkerClusterer.prototype.fitMapToMarkers; +MarkerClusterer.prototype['getCalculator'] = + MarkerClusterer.prototype.getCalculator; +MarkerClusterer.prototype['getGridSize'] = + MarkerClusterer.prototype.getGridSize; +MarkerClusterer.prototype['getExtendedBounds'] = + MarkerClusterer.prototype.getExtendedBounds; +MarkerClusterer.prototype['getMap'] = MarkerClusterer.prototype.getMap; +MarkerClusterer.prototype['getMarkers'] = MarkerClusterer.prototype.getMarkers; +MarkerClusterer.prototype['getMaxZoom'] = MarkerClusterer.prototype.getMaxZoom; +MarkerClusterer.prototype['getStyles'] = MarkerClusterer.prototype.getStyles; +MarkerClusterer.prototype['getTotalClusters'] = + MarkerClusterer.prototype.getTotalClusters; +MarkerClusterer.prototype['getTotalMarkers'] = + MarkerClusterer.prototype.getTotalMarkers; +MarkerClusterer.prototype['redraw'] = MarkerClusterer.prototype.redraw; +MarkerClusterer.prototype['removeMarker'] = + MarkerClusterer.prototype.removeMarker; +MarkerClusterer.prototype['removeMarkers'] = + MarkerClusterer.prototype.removeMarkers; +MarkerClusterer.prototype['resetViewport'] = + MarkerClusterer.prototype.resetViewport; +MarkerClusterer.prototype['repaint'] = + MarkerClusterer.prototype.repaint; +MarkerClusterer.prototype['setCalculator'] = + MarkerClusterer.prototype.setCalculator; +MarkerClusterer.prototype['setGridSize'] = + MarkerClusterer.prototype.setGridSize; +MarkerClusterer.prototype['setMaxZoom'] = + MarkerClusterer.prototype.setMaxZoom; +MarkerClusterer.prototype['onAdd'] = MarkerClusterer.prototype.onAdd; +MarkerClusterer.prototype['draw'] = MarkerClusterer.prototype.draw; + +Cluster.prototype['getCenter'] = Cluster.prototype.getCenter; +Cluster.prototype['getSize'] = Cluster.prototype.getSize; +Cluster.prototype['getMarkers'] = Cluster.prototype.getMarkers; + +ClusterIcon.prototype['onAdd'] = ClusterIcon.prototype.onAdd; +ClusterIcon.prototype['draw'] = ClusterIcon.prototype.draw; +ClusterIcon.prototype['onRemove'] = ClusterIcon.prototype.onRemove; + +Object.keys = Object.keys || function(o) { + var result = []; + for(var name in o) { + if (o.hasOwnProperty(name)) + result.push(name); + } + return result; +}; diff --git a/page-experience-by-companies.php b/page-experience-by-companies.php index 49b674b..41d4006 100644 --- a/page-experience-by-companies.php +++ b/page-experience-by-companies.php @@ -1,65 +1 @@ - - $endDate) ? $endDate : $jEDate); - return (((strtotime($jSDate) < strtotime($endDate)) && (strtotime($jSDate) > strtotime($startDate))) && (strtotime($jEDate) > strtotime($startDate))); - } - - $loop = new WP_Query( $args ); - ?> -

Experience

by company

- false, 'taxonomy' => 'company', 'term_args' => array('parent' => 0))); - if ( ! empty( $terms ) ) { - echo "
"; - echo "
    "; - foreach ( (array) $terms as $term ) { - $imgURL = wp_get_attachment_image_src($term->image_id, 'detail')[0]; - $colour = get_term_meta($term->term_id, 'color', true); - $colour = ($colour != "") ? $colour : "var(--light)"; - if (!$imgURL) { - echo "taxonomy ))."\">
  • ".$term->name."
  • "; - } else { - echo "taxonomy ))."\">
  • "; - } - } - echo "
"; - echo "
"; - } - ?> - - - - -
- - - +

Experience

by company

Settings


Display companies with:







\ No newline at end of file diff --git a/page-experience-by-locations.php b/page-experience-by-locations.php new file mode 100644 index 0000000..9f02a1e --- /dev/null +++ b/page-experience-by-locations.php @@ -0,0 +1 @@ +

Experience

by location

0)); // Gets all of the top-level location terms. $terms = get_terms(array('taxonomy' => 'location', 'term_args' => array('parent' => 0))); ?>
parent != 0 && get_term($t->parent, 'location')->parent == 0; }); ?> parent != 0 && get_term($t->parent, 'location')->parent != 0 && get_term(get_term($t->parent, 'location')->parent, 'location')->parent != 0 && get_term(get_term(get_term($t->parent, 'location')->parent, 'location')->parent, 'location')->parent == 0; }); ?>
\ No newline at end of file diff --git a/page-experience.php b/page-experience.php index d10c7a9..d36a70a 100644 --- a/page-experience.php +++ b/page-experience.php @@ -1,91 +1 @@ - - $endDate) ? $endDate : $jEDate); - return (((strtotime($jSDate) < strtotime($endDate)) && (strtotime($jSDate) > strtotime($startDate))) && (strtotime($jEDate) > strtotime($startDate))); - } - - $args= array( - 'post_type' => array( 'job' ), - 'posts_per_page' => -1 - ); - - $loop = new WP_Query( $args ); - ?> -
', '' ); ?>
- false, 'taxonomy' => 'company')); - if ( ! empty( $terms ) ) { - print ''; - } - */?> - - - - - - -
-
- - - + $endDate) ? $endDate : $jEDate); return (((strtotime($jSDate) < strtotime($endDate)) && (strtotime($jSDate) > strtotime($startDate))) && (strtotime($jEDate) > strtotime($startDate))); } $args= array( 'post_type' => array( 'job' ), 'posts_per_page' => -1 ); $loop = new WP_Query( $args ); ?>
', '' ); ?>
false, 'taxonomy' => 'company')); if ( ! empty( $terms ) ) { print '
'; } */?>
\ No newline at end of file diff --git a/page-home.php b/page-home.php new file mode 100644 index 0000000..1a41d78 --- /dev/null +++ b/page-home.php @@ -0,0 +1,59 @@ + + +
+
+ + +
+
+
+ A picture of Ben Goldsworthy +
+
+
+
+
+ +
+ +
+
+ + +
+ + + +
+ + + diff --git a/page.php b/page.php index 315a3da..85b3c53 100644 --- a/page.php +++ b/page.php @@ -14,7 +14,7 @@ get_header(); ?>
-
+
- $startDate)); - } - - $company = get_queried_object(); - $args= array( - 'post_type' => array( 'job' ), - 'tax_query' => array( - array( - 'taxonomy' => 'company', - 'field' => 'slug', - 'terms' => $company->name, - ), - ), - 'posts_per_page' => -1 - ); - - $loop = new WP_Query( $args ) -?> - - -
-
- - -
-
-
-

Children

-
    - false, 'taxonomy' => 'company', 'term_args' => array('child_of' => get_queried_object()->term_id))); - foreach ( (array) $children as $child ) { - $imgURL = wp_get_attachment_image_src($child->image_id, 'detail')[0]; - $colour = get_term_meta($child->term_id, 'color', true); - $colour = ($colour != "") ? $colour : "var(--light)"; - echo "taxonomy ))."\">
  • "; - } - ?> -
-
-
- have_posts() ) : - echo "
"; - echo "

".ucwords($currSec)."s slug."\">View all ".$loop->post_count."

"; - echo "
"; - while ( $loop->have_posts() ) : $loop->the_post(); - get_template_part( 'template-parts/content', get_post_format() ); - endwhile; - echo "
"; - echo "
"; - endif; - } - ?> -
-
- - - + $startDate)); } $company = get_queried_object(); $args= array( 'post_type' => array( 'job' ), 'tax_query' => array( array( 'taxonomy' => 'company', 'field' => 'slug', 'terms' => $company->name, ), ), 'posts_per_page' => -1 ); $loop = new WP_Query( $args ) ?>
array( 'alt' => get_queried_object()->name.' logo', 'class' => 'taxonomy-background', ), 'before' => '
', 'after' => '
', 'image_size' => 'full' ) ); ?>
parent != 0) { $parents = apply_filters("taxonomy-images-get-terms", "", array('having_images' => false, 'taxonomy' => 'company', 'term_args' => array('include' => get_term_by('id', get_queried_object()->parent, 'company')->term_id))); if (count($parents) > 0) { echo '

Parent

'; echo '
    '; foreach ( (array) $parents as $parent ) { $imgURL = wp_get_attachment_image_src($parent->image_id)[0]; $colour = get_term_meta($parent->term_id, 'color', true); $colour = ($colour != "") ? $colour : "var(--light)"; echo "taxonomy ))."\">
  • "; } } } $children = apply_filters("taxonomy-images-get-terms", "", array('having_images' => false, 'taxonomy' => 'company', 'term_args' => array('parent' => get_queried_object()->term_id))); if (count($children) > 0) { echo '

    Children

    '; echo '
      '; foreach ( (array) $children as $child ) { $imgURL = wp_get_attachment_image_src($child->image_id, 'detail')[0]; $colour = get_term_meta($child->term_id, 'color', true); $colour = ($colour != "") ? $colour : "var(--light)"; echo "taxonomy ))."\">
    • "; } } ?>
have_posts() ) : echo "
"; echo "

".ucwords($currSec)."s View all ".$loop->post_count."

"; echo "
"; while (($loop->have_posts()) && ($i++ < 4)) : $loop->the_post(); get_template_part( 'template-parts/content', get_post_format() ); endwhile; echo "
"; echo "
"; endif; } ?>
\ No newline at end of file diff --git a/template-parts/content-page.php b/template-parts/content-page.php index 2b57d2b..3298324 100644 --- a/template-parts/content-page.php +++ b/template-parts/content-page.php @@ -9,13 +9,16 @@ ?>
> -
- ', '' ); ?> +
+
+ +
+

+
+
- - -
+
- -
> - -
-
-
', '' ); ?>
- -
-
- - -
- '', - 'link_before' => '', - 'link_after' => '', - 'pagelink' => '' . __( 'Page', 'twentysixteen' ) . ' %', - 'separator' => ', ', - ) ); - - if ( '' !== get_the_author_meta( 'description' ) ) { - get_template_part( 'template-parts/biography' ); - } - ?> -
- -
- - -
-
+ + +
> + +
+
+
+ 70) $small= "3em"; + elseif (strlen(get_the_title()) > 35) $small = "4em"; + elseif (strlen(get_the_title()) > 12) $small = "5em"; + else $small = "6em" + ?> +

+ + + + +

+ ', '

'); ?> + +
+ + name ?> + + + */ ?> +
+
+
+ +
+ '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentysixteen' ) . ' %', + 'separator' => ', ', + ) ); + + if ( '' !== get_the_author_meta( 'description' ) ) { + get_template_part( 'template-parts/biography' ); + } + ?> +
+ +
+ +
+
diff --git a/template-parts/content.php b/template-parts/content.php index 4bfb831..daafb90 100644 --- a/template-parts/content.php +++ b/template-parts/content.php @@ -12,15 +12,17 @@
- - - - - 70) $small= "vsmall"; - elseif (strlen(get_the_title()) > 35) $small = "small"; - the_title( '

', '

' ); - ?> +
+ 70) $small= "vsmall"; + elseif (strlen(get_the_title()) > 35) $small = "small"; + elseif (strlen(get_the_title()) > 12) $small = "qsmall"; + ?> +

+ + '.$versionNum.''; ?> +

+
diff --git a/updateCompanies.php b/updateCompanies.php new file mode 100644 index 0000000..70c379b --- /dev/null +++ b/updateCompanies.php @@ -0,0 +1 @@ +Hello world \ No newline at end of file