Skip to content

Commit

Permalink
Resolved an issue where polylines, polygons and rectangles wouldn't b…
Browse files Browse the repository at this point in the history
…e rendered to the map when no markers were present on the map.
  • Loading branch information
jensjns committed Nov 4, 2014
1 parent 0980cd8 commit b2cbcc6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions acf-leaflet_field.php
Expand Up @@ -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
Expand Down Expand Up @@ -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 '<div id="' . $field_obj['id'] . '_map" class="leaflet-map" style="height:' . $field_obj['height'] . 'px;"></div>';
}
Expand Down
3 changes: 2 additions & 1 deletion js/input.js.php
Expand Up @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion js/leaflet-frontend.js
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion leaflet_field-v3.php
Expand Up @@ -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'
);

}
Expand Down
2 changes: 1 addition & 1 deletion leaflet_field-v4.php
Expand Up @@ -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' ) );
Expand Down
2 changes: 1 addition & 1 deletion leaflet_field-v5.php
Expand Up @@ -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' ) );
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Expand Up @@ -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: `<?php the_leaflet_field( 'my_leaflet_field' ); ?>`, just plug and play!
* Supports ACF3, ACF4 and ACF5 (Pro)
* Supports ACF4 and ACF5 (Pro)

== Installation ==

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b2cbcc6

Please sign in to comment.