From b2cbcc624ac74e61eaea68101c0250dc51dde072 Mon Sep 17 00:00:00 2001 From: Jens Nilsson Date: Tue, 4 Nov 2014 17:31:29 +0100 Subject: [PATCH] Resolved an issue where polylines, polygons and rectangles wouldn't be rendered to the map when no markers were present on the map. --- acf-leaflet_field.php | 4 ++-- js/input.js.php | 3 ++- js/leaflet-frontend.js | 2 +- leaflet_field-v3.php | 2 +- leaflet_field-v4.php | 2 +- leaflet_field-v5.php | 2 +- readme.txt | 10 ++++++++-- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/acf-leaflet_field.php b/acf-leaflet_field.php index b914ce0..f4d6de5 100644 --- a/acf-leaflet_field.php +++ b/acf-leaflet_field.php @@ -3,7 +3,7 @@ Plugin Name: Advanced Custom Fields: Leaflet Field Plugin URI: https://github.com/jensjns/acf-leaflet-field Description: Adds a Leaflet map-field to Advanced Custom Fields. - Version: 1.2.0 + Version: 1.2.1 Author: Jens Nilsson Author URI: http://jensnilsson.nu/ License: GPLv2 or later @@ -114,7 +114,7 @@ function the_leaflet_field( $field_name, $post_id = false ) { // enqueue scripts wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'leaflet', plugins_url( '/js/leaflet/leaflet.js', __FILE__ ), array(), '0.7.3', true ); - wp_enqueue_script( 'leaflet-frontend', plugins_url( '/js/leaflet-frontend.js', __FILE__ ), array( 'jquery', 'leaflet' ), '1.2.0', true ); + wp_enqueue_script( 'leaflet-frontend', plugins_url( '/js/leaflet-frontend.js', __FILE__ ), array( 'jquery', 'leaflet' ), '1.2.1', true ); wp_localize_script( 'leaflet-frontend', 'leaflet_field', $field_obj ); echo '
'; } diff --git a/js/input.js.php b/js/input.js.php index 9265909..2d0aaa9 100644 --- a/js/input.js.php +++ b/js/input.js.php @@ -139,7 +139,8 @@ function render_leaflet_map(uid) { window.maps[uid].addControl(drawControl); // render existing markers if we have any - if( Object.keys(window.map_settings[uid].markers).length > 0 ) { + console.log(window.map_settings[uid]); + if( Object.keys(window.map_settings[uid].markers).length > 0 || (window.map_settings[uid].drawnItems && window.map_settings[uid].drawnItems.features.length > 0) ) { var newMarkers = {}; $.each(window.map_settings[uid].markers, function(index, marker) { //var newMarker = L.marker(marker.geometry.coordinates, {draggable: true}); diff --git a/js/leaflet-frontend.js b/js/leaflet-frontend.js index c9d2cc2..8e0dc90 100644 --- a/js/leaflet-frontend.js +++ b/js/leaflet-frontend.js @@ -49,7 +49,7 @@ jQuery(document).ready(function($) { maxZoom: 18 }).addTo(map); - if( Object.keys(map_settings.markers).length > 0 ) { + if( Object.keys(map_settings.markers).length > 0 || (window.map_settings.drawnItems && window.map_settings.drawnItems.features.length > 0) ) { $.each(map_settings.markers, function(index, marker) { L.geoJson(marker, { onEachFeature:function(feature, layer){ diff --git a/leaflet_field-v3.php b/leaflet_field-v3.php index d1dc796..6f3da04 100644 --- a/leaflet_field-v3.php +++ b/leaflet_field-v3.php @@ -63,7 +63,7 @@ function __construct($parent) $this->settings = array( 'path' => $this->helpers_get_path( __FILE__ ), 'dir' => $this->helpers_get_dir( __FILE__ ), - 'version' => '1.2.0' + 'version' => '1.2.1' ); } diff --git a/leaflet_field-v4.php b/leaflet_field-v4.php index fc7cce4..fe1668f 100644 --- a/leaflet_field-v4.php +++ b/leaflet_field-v4.php @@ -62,7 +62,7 @@ function __construct() $this->settings = array( 'path' => apply_filters( 'acf/helpers/get_path', __FILE__ ), 'dir' => apply_filters( 'acf/helpers/get_dir', __FILE__ ), - 'version' => '1.2.0' + 'version' => '1.2.1' ); add_action( 'acf/field_group/admin_head', array( $this, 'conditional_options' ) ); diff --git a/leaflet_field-v5.php b/leaflet_field-v5.php index 39edce6..ca8c3ad 100644 --- a/leaflet_field-v5.php +++ b/leaflet_field-v5.php @@ -65,7 +65,7 @@ function __construct() { $this->settings = array( 'path' => apply_filters( 'acf/helpers/get_path', __FILE__ ), 'dir' => apply_filters( 'acf/helpers/get_dir', __FILE__ ), - 'version' => '1.2.0' + 'version' => '1.2.1' ); add_action( 'acf/field_group/admin_head', array( $this, 'conditional_options' ) ); diff --git a/readme.txt b/readme.txt index c214a9a..1176d2a 100644 --- a/readme.txt +++ b/readme.txt @@ -11,13 +11,13 @@ Addon for Advanced Custom Fields that adds a Leaflet field to the available fiel == Description == -This plugin adds a [Leaflet](http://leafletjs.com) map field to the [Advanced Custom Fields](http://www.advancedcustomfields.com/) plugin. Use it to display beutiful maps with markers along with your posts and pages. +This plugin adds a [Leaflet](http://leafletjs.com) map field to the [Advanced Custom Fields](http://www.advancedcustomfields.com/) plugin. Use it to display maps with markers, lines and shapes along with your posts and pages. * Add multiple markers with popups to the map. * Draw polylines, polygons and rectangles. * The field stores both your zoom-level and viewport location. * Function to render the map in your theme is included in the plugin: ``, just plug and play! -* Supports ACF3, ACF4 and ACF5 (Pro) +* Supports ACF4 and ACF5 (Pro) == Installation == @@ -54,6 +54,9 @@ This is not a standalone plugin, you need to have [Advanced Custom Fields](http: == Changelog == += 1.2.1 = +* Fixed a bug where polylines, polygons and rectangles wouldn't be rendered to the map when no markers were present on the map. + = 1.2.0 = * More polished UI. * Added support for drawing polylines, polygons and rectangles. @@ -83,6 +86,9 @@ This is not a standalone plugin, you need to have [Advanced Custom Fields](http: == Upgrade Notice == += 1.2.1 = +* Fixed a bug where polylines, polygons and rectangles wouldn't be rendered to the map when no markers were present on the map. + = 1.2.0 = * More polished UI. * Added support for drawing polylines, polygons and rectangles.