Skip to content

Commit

Permalink
added startendsection, added zoomlevel fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mzeiher committed Jun 29, 2014
1 parent 89cf45f commit 5e89720
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 23 deletions.
5 changes: 3 additions & 2 deletions admin/js/travelermap-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@

$('#tm_place_at_address').prop('disabled', false);
$('#tm_save_changes').prop('disabled', false);
} else if (data.type === 'endsection') {
} else if (data.type === 'endsection' || data.type === 'startendsection') {
$('#tm_type').prop('disabled', false);
$('#tm_title').prop('disabled', false);
$('#tm_thumbnail').prop('disabled', false);
Expand Down Expand Up @@ -218,7 +218,7 @@
"arrival": $('#tm_arrival').val() !== '' ? Date.parse($('#tm_arrival').val()) : null,
"departure": $('#tm_departure').val() !== '' ? Date.parse($('#tm_departure').val()) : null
};
if (data.type === 'startsection' || data.type === 'endsection' || data.type === 'waypoint') {
if (data.type === 'startsection' || data.type === 'endsection' || data.type === 'startendsection' || data.type === 'waypoint') {
data.excludeFromPath = false;
$('#tm_excludefrompath').prop('checked', data.excludeFromPath);
}
Expand All @@ -231,6 +231,7 @@
$(_currentSelection).removeClass('media');
$(_currentSelection).removeClass('post');
$(_currentSelection).removeClass('startsection');
$(_currentSelection).removeClass('startendsection');
$(_currentSelection).removeClass('endsection');

$(_currentSelection).addClass(data.type);
Expand Down
1 change: 1 addition & 0 deletions admin/travelermap-editmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function travelermap_editmap() {
<option value="media">Media</option>
<option value="waypoint">Waypoint</option>
<option value="startsection">Start Section</option>
<option value="startendsection">Start-End Section</option>
<option value="endsection">End Section</option>
</select><br />
<label for="tm_icon">Marker Symbol</label>
Expand Down
21 changes: 19 additions & 2 deletions admin/travelermap-upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function travelermap_upgrade() {
if( version_compare($currentVersion, '1.1.0', '<')) {
travelermap_upgrade_1_0_0_to_1_1_0();
}
if( version_compare($currentVersion, '1.2.0', '<')) {
travelermap_upgrade_1_1_0_to_1_2_0();
}
}

function travelermap_upgrade_1_0_0_to_1_1_0() {
Expand All @@ -40,8 +43,22 @@ function travelermap_upgrade_1_0_0_to_1_1_0() {
update_option('travelermap_settings', $settings);
}

update_option("travelermap_version", TM_VERSION);
update_option("travelermap_db_version", TM_VERSION);
update_option("travelermap_version", '1.1.0');
update_option("travelermap_db_version", '1.1.0');

}

function travelermap_upgrade_1_1_0_to_1_2_0() {
$settings = get_option('traverlermap_settings');

if (!$settings) {
$settings = array(
);
update_option('travelermap_settings', $settings);
}

update_option("travelermap_version", '1.2.0');
update_option("travelermap_db_version", '1.2.0');

}

Expand Down
61 changes: 50 additions & 11 deletions frontend/js/travelermap-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
connectMaps : false,
height: 400,
spinner: true,
dateFormat: "dd.MM.yyyy"
dateFormat: "dd.MM.yyyy",
zoomLevel: 3
};

var _currentMap = null;
Expand Down Expand Up @@ -71,7 +72,7 @@
_mapWrapper.css('height', _mapOptions.height + "px");
}

_map = L.map(_mapWrapper[0]).setView([0,0], 3);;
_map = L.map(_mapWrapper[0]).setView([0,0], _mapOptions.zoomLevel);;
_map.on('popupopen', function(e) {
var px = _map.project(e.popup._latlng);
px.y -= e.popup._container.clientHeight/2;
Expand Down Expand Up @@ -225,8 +226,8 @@
currentLine.addLatLng([feature.lat, feature.lng]);
currentLine.bindPopup(feature.title);
currentLine['tm_data'] = feature;
group.addLayer(currentLine);
feature['_lf_object'] = currentLine;
group.addLayer(currentLine);
currentLine = L.geodesicPolyline([],{color:lineColor});
currentLine.addLatLng([feature.lat, feature.lng]); //add as starting point
isInSection = false;
Expand All @@ -236,6 +237,32 @@
isInFuture = true;
}
}
} else if(feature.type === 'startendsection') {
currentLine.addLatLng([feature.lat, feature.lng]);
currentLine.bindPopup(feature.title);
currentLine['tm_data'] = feature;
group.addLayer(currentLine);
feature['_lf_object'] = currentLine;
currentLine = L.geodesicPolyline([],{color:lineColor});
currentLine.on('mouseover', function(evt) {
evt.target.setStyle({opacity: 1});
});
currentLine.on('mouseout', function(evt) {
evt.target.setStyle({opacity: 0.5});
});
currentLine.on('popupopen', function(evt) {
evt.target.setStyle({opacity: 1});
});
currentLine.on('popupclose', function(evt) {
evt.target.setStyle({opacity: 0.5});
});
currentLine.addLatLng([feature.lat, feature.lng]); //add as starting point
var nextPoint = _findNextWaypointMarker(data,i+1);
if(nextPoint) {
if(nextPoint.arrival && nextPoint.arrival >= new Date().getTime()) {
isInFuture = true;
}
}
}

if(isInFuture) {
Expand All @@ -248,7 +275,16 @@

function _findStartSection(data, start) {
for(var i = start; i >= 0; i--) {
if(data[i].type === 'startsection') {
if(data[i].type === 'startsection' || data[i].type === 'startendsection') {
return data[i];
}
}
return null;
}

function _findEndSection(data, start) {
for(var i = start; i < data.length; i++) {
if(data[i].type === 'startendsection' || data[i].type === 'endsection') {
return data[i];
}
}
Expand All @@ -257,7 +293,7 @@

function _findNextWaypointMarker(data, start) {
for(var i = start; i < data.length; i++) {
if((data[i].type === "waypoint" || data[i].type === "startsection" || data[i].type === "endsection" || data[i].type==='marker' || data[i].type === 'media' || data[i].type === 'post') && !data[i].excludeFromPath) {
if((data[i].type === "waypoint" || data[i].type === "startsection" || data[i].type === "startendsection" || data[i].type === "endsection" || data[i].type==='marker' || data[i].type === 'media' || data[i].type === 'post') && !data[i].excludeFromPath) {
return data[i];
}
}
Expand All @@ -277,7 +313,7 @@
var wp = L.circleMarker([feature.lat, feature.lng], {radius: 5, fillOpacity:1, color:lineColor}).bindPopup(feature.title);
markerLayer.addLayer(wp);
}
} else if(feature.type === 'startsection' || feature.type === 'endsection') {
} else if(feature.type === 'startsection' || feature.type === 'endsection' || feature.type === 'startendsection') {
var wp = L.circleMarker([feature.lat, feature.lng], {radius: 5, fillOpacity:1, color:lineColor});
if(feature.title) {
wp.bindPopup(feature.title)
Expand Down Expand Up @@ -316,15 +352,18 @@
wrapper.append(img);
}
var dateInfo = '<span>';
if(feature.type === 'endsection') {
var start = _findStartSection(data, position);
if(start && start.arrival) {
if(feature.type === 'endsection' || feature.type === 'startendsection') {
var start = _findStartSection(data, position-1);
if(start && start.departure) {
dateInfo += "Start: " + $.format.date(start.departure, _mapOptions.dateFormat) + ' | ';
} else if(start && start.arrival) {
dateInfo += "Start: " + $.format.date(start.arrival, _mapOptions.dateFormat) + ' | ';
}
if(feature.departure) {
if(feature.arrival) {
dateInfo += "End: " + $.format.date(feature.arrival, _mapOptions.dateFormat) + ' | ';
} else if(feature.departure) {
dateInfo += "End: " + $.format.date(feature.departure, _mapOptions.dateFormat) + ' | ';
}

} else {
if(feature.date) {
dateInfo += 'Date: ' + $.format.date(feature.date, _mapOptions.dateFormat) + ' | ';
Expand Down
5 changes: 3 additions & 2 deletions frontend/travelermap-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function travelermap_show_map($atts, $content = null) {
"height" => '400',
"id" => '',
"connectmaps" => 'false',
'spinner' => 'true'
'spinner' => 'true',
'zoomlevel' => '3'
), $atts ) );

$dateFormat = get_option('date_format');
Expand Down Expand Up @@ -71,7 +72,7 @@ function travelermap_show_map($atts, $content = null) {
$output .= ",";
$output .= "$('#tm_map_$map_id')";
$output .= ",";
$output .= "{connectMaps:$connectmaps, height:$height, spinner:$spinner, dateFormat:'$dateFormat'}";
$output .= "{connectMaps:$connectmaps, height:$height, spinner:$spinner, dateFormat:'$dateFormat', zoomLevel:$zoomlevel}";
$output .= ');';
$output .= '});';
$output .= '})(jQuery);';
Expand Down
8 changes: 8 additions & 0 deletions media/tm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ ul#tm_pointlist > li.endsection {
border-left: 1px solid #000;
}

ul#tm_pointlist > li.startendsection {
border: 1px solid #000;
}

ul#tm_pointlist > li.startsection > i:before {
content: "\f105";
}
Expand All @@ -111,6 +115,10 @@ ul#tm_pointlist > li.endsection > i:before {
content: "\f104";
}

ul#tm_pointlist > li.startendsection > i:before {
content: "\f101";
}

ul#tm_pointlist > li.media > i:before {
content: "\f030";
}
Expand Down
13 changes: 9 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ Contributors: Mathis Zeiher
Donate link: http://bitschubser.org
Tags: travel, map, waypoints
Requires at least: 3.9.0
Tested up to: 3.9.0
Stable tag: 1.1.0
Tested up to: 3.9.1
Stable tag: 1.2.0
License: MIT
License URI: http://opensource.org/licenses/MIT

A simple Plugin to create travel routes and manage maps

== Description ==

This Pluigin allow the creation of travel maps with routes and point of interests.
This plugin allows the creation of travel maps with routes and point of interests.
The points or route section can be linked with posts or media attachments.

To place the maps within posts use the shortcode [tm_map id=""] where id is either the map id or
a comma separated list of map ids to display.
Additional parameters for the shortcode are: connectmaps="true|false" to connect the maps in the order
specified in the comma separated id list and spinner="true|false" to disable the spinner to navigate
through markers.
through markers, zoomlevel="0-16" to set the initial zoom level (0 min, 16 max level)

example:
[tm_map id="1"]
Expand Down Expand Up @@ -51,6 +51,11 @@ Go to http://blog.bitschubser.org and ask in the wp-travelermap section or here

== Changelog ==

= 1.2.0 =
* added zoomlevel to shortcode to set initial zoom level
* added startendsection marker type to create consecutive sections
* fixed some bugs

= 1.1.0 =
* added ability to place marker in admin menu to a specific address (no marker dragging anymore)
* fixed some bugs
Expand Down
4 changes: 2 additions & 2 deletions wp-travelermap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: wp-travelermap
Plugin URI: http://bitschubser.org/projects/wp-travelermap
Description: A simple Plugin to create travel routes and manage maps
Version: 1.1.0
Version: 1.2.0
Author: Mathis Zeiher
Author URI: http://bitschubser.org/
Expand Down Expand Up @@ -31,7 +31,7 @@
if ( ! defined( 'ABSPATH' ) ) exit;

if ( ! defined( 'TM_VERSION' ) )
define( 'TM_VERSION', '1.1.0' );
define( 'TM_VERSION', '1.2.0' );

if ( ! defined( 'TM_URL' ) )
define( 'TM_URL', plugin_dir_url( __FILE__ ) );
Expand Down

0 comments on commit 5e89720

Please sign in to comment.