diff --git a/WP-GPX-Maps.js b/WP-GPX-Maps.js index 362f856..7b8c7f4 100644 --- a/WP-GPX-Maps.js +++ b/WP-GPX-Maps.js @@ -47,7 +47,14 @@ function _wpgpxmaps(params) var color1 = params.color1; var color2 = params.color2; var color3 = params.color3; - + var chartFrom1 = params.chartFrom1; + var chartTo1 = params.chartTo1; + var chartFrom2 = params.chartFrom2; + var chartTo2 = params.chartTo2; + var startIcon = params.startIcon; + var endIcon = params.endIcon; + var currentIcon = params.currentIcon; + var el = document.getElementById("wpgpxmaps_" + targetId); var el_map = document.getElementById("map_" + targetId); var el_chart = document.getElementById("chart_" + targetId); @@ -99,6 +106,33 @@ function _wpgpxmaps(params) bounds.extend(p); } + if (startIcon != '') + { + var startIconImage = new google.maps.MarkerImage(startIcon); + var startMarker = new google.maps.Marker({ + position: points[0], + map: map, + title: "Start", + animation: google.maps.Animation.DROP, + icon: startIconImage, + zIndex: 10 + }); + } + + if (endIcon != '') + { + var endIconImage = new google.maps.MarkerImage(endIcon); + var startMarker = new google.maps.Marker({ + position: points[ points.length -1 ], + map: map, + title: "Start", + animation: google.maps.Animation.DROP, + icon: endIconImage, + zIndex: 10 + }); + + } + var poly = new google.maps.Polyline({ path: points, strokeColor: color1, @@ -110,7 +144,12 @@ function _wpgpxmaps(params) map.fitBounds(bounds); var first = getItemFromArray(mapData,0) - var current = new google.maps.MarkerImage("http://maps.google.com/mapfiles/kml/pal4/icon25.png", + if (currentIcon == '') + { + currentIcon = "http://maps.google.com/mapfiles/kml/pal4/icon25.png"; + } + + var current = new google.maps.MarkerImage(currentIcon, new google.maps.Size(32, 32), new google.maps.Point(0,0), new google.maps.Point(16, 16) @@ -164,6 +203,18 @@ function _wpgpxmaps(params) data.addColumn('number', "Distance"); data.addColumn('number', "Altitude"); + if (!isNumeric(chartFrom1)) + chartFrom1 = null; + + if (!isNumeric(chartTo1)) + chartTo1 = null; + + if (!isNumeric(chartFrom2)) + chartFrom2 = null; + + if (!isNumeric(chartTo2)) + chartTo2 = null; + var options = { curveType: "function", strictFirstColumnType: true, hAxis : {format : numberFormat1}, @@ -174,6 +225,12 @@ function _wpgpxmaps(params) tooltip: { showColorCode: true}, fontSize:11 }; + + if ( chartFrom1 != null || chartTo1 != null ) + { + options.vAxis.viewWindowMode = "explicit"; + options.vAxis.viewWindow = { min : chartFrom1, max : chartTo1}; + } if (showSpeed) { @@ -192,12 +249,27 @@ function _wpgpxmaps(params) speedFormat = "#,##0.#m/s"; } data.addColumn('number', "Speed"); + options.vAxes = { 0:{format : numberFormat2, targetAxisIndex : 0}, 1:{format : speedFormat, targetAxisIndex : 1} }; + + if ( chartFrom1 != null || chartTo1 != null ) + { + options.vAxes[0].viewWindowMode = "explicit"; + options.vAxes[0].viewWindow = { min : chartFrom1, max : chartTo1}; + } + + if ( chartFrom2 != null || chartTo2 != null ) + { + options.vAxes[1].viewWindowMode = "explicit"; + options.vAxes[1].viewWindow = { min : chartFrom2, max : chartTo2}; + } + options.series = { 0:{color: color2, visibleInLegend: true, targetAxisIndex : 0}, 1:{color: color3, visibleInLegend: true, targetAxisIndex : 1} }; + options.chartArea.width="85%"; //alert(el_chart.clientWidth); } @@ -278,6 +350,11 @@ function getClosestIndex(points,lat,lon) return ii; } +function isNumeric(input){ + var RE = /^-{0,1}\d*\.{0,1}\d+$/; + return (RE.test(input)); +} + function dist(lat1,lon1,lat2,lon2) { // mathematically not correct but fast diff --git a/readme.txt b/readme.txt index f1df88e..3effbb2 100644 --- a/readme.txt +++ b/readme.txt @@ -1,17 +1,20 @@ === WP GPX Maps === Contributors: bastianonm -Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=bastianonm@hotmail.com&item_name=WP-GRX-Maps&item_number=WP-GRX-Maps&amount=5¤cy_code=EUR -Tags: maps, gpx, gps, graph, google maps, google chart, track, garmin +Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=bastianonm@hotmail.com&item_name=WP%20GPX%20Maps&item_number=Donation +Tags: maps, gpx, gps, graph, chart, google maps, google chart, track, garmin Requires at least: 2.0.0 Tested up to: 3.3 -Stable tag: 1.1.9 +Stable tag: 1.1.10 License: GPLv2 or later Draws a gpx track with altitude graph == Description == + This plugin has, as input, the GPX file with the track you've made and as output it shows the map of the track and an interactive altitude graph (where available). +Fully configurable: custom colors and icons to make the map look like your site. + - iphone/ipad/ipod Compatible Try this plugin: http://www.pedemontanadelgrappa.it/category/mappe/ @@ -72,6 +75,21 @@ The attributes are: 1. uomspeed: the unit of measure of speed are: 0, 1, 2 (0 = m/s, 1 = km/h, 2 = miles/h) +1. chartFrom1: minimun value for altitude chart + +1. chartTo1: maxumin value for altitude chart + +1. chartFrom2: minimun value for speed chart + +1. chartTo2: maxumin value for speed chart + +1. startIcon: Start track icon + +1. endIcon: End track icon + +1. currentIcon: Current position icon (when mouse hover) + + = What happening if I've a very large gpx? = This plugin will print a small amout of points to speedup javascript and pageload. @@ -85,6 +103,10 @@ Yes! 2. Admin area - Settings == Changelog == += 1.1.10 = +* Configurable Map Icons +* Chart scale configuration (max and min values) += 1.1.9 = = 1.1.8 = * cache issues fixed * added speed when not present in the gpx (derived from datetime) @@ -140,6 +162,8 @@ Yes! * Initial release == Upgrade Notice == += 1.1.10 = += 1.1.9 = = 1.1.8 = = 1.1.7 = = 1.1.6 = diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php index 9a63384..8fc324d 100644 --- a/wp-gpx-maps.php +++ b/wp-gpx-maps.php @@ -3,7 +3,7 @@ Plugin Name: WP-GPX-Maps Plugin URI: http://www.darwinner.it/ Description: Draws a gpx track with altitude graph -Version: 1.1.9 +Version: 1.1.10 Author: Bastianon Massimo Author URI: http://www.pedemontanadelgrappa.it/ License: GPL @@ -46,7 +46,7 @@ function enqueue_WP_GPX_Maps_scripts() google.load('visualization', '1', {'packages':['corechart']}); google.load("maps", "3", {other_params: 'sensor=false'}); - + '; - + return $output; } @@ -276,6 +290,13 @@ function WP_GPX_Maps_install() { add_option("wpgpxmaps_graph_line_color", '#3366cc', '', 'yes'); add_option("wpgpxmaps_graph_line_color_speed", '#ff0000', '', 'yes'); add_option("wpgpxmaps_map_line_color", '#3366cc', '', 'yes'); + add_option("wpgpxmaps_graph_offset_from1", '', '', 'yes'); + add_option("wpgpxmaps_graph_offset_to1", '', '', 'yes'); + add_option("wpgpxmaps_graph_offset_from2", '', '', 'yes'); + add_option("wpgpxmaps_graph_offset_to2", '', '', 'yes'); + add_option("wpgpxmaps_map_start_icon", '', '', 'yes'); + add_option("wpgpxmaps_map_end_icon", '', '', 'yes'); + add_option("wpgpxmaps_map_current_icon", '', '', 'yes'); } function WP_GPX_Maps_remove() { @@ -292,6 +313,13 @@ function WP_GPX_Maps_remove() { delete_option('wpgpxmaps_graph_line_color'); delete_option('wpgpxmaps_map_line_color'); delete_option('wpgpxmaps_graph_line_color_speed'); + delete_option('wpgpxmaps_graph_offset_from1'); + delete_option('wpgpxmaps_graph_offset_to1'); + delete_option('wpgpxmaps_graph_offset_from2'); + delete_option('wpgpxmaps_graph_offset_to2'); + delete_option('wpgpxmaps_map_start_icon'); + delete_option('wpgpxmaps_map_end_icon'); + delete_option('wpgpxmaps_map_current_icon'); } ?> diff --git a/wp-gpx-maps_admin.php b/wp-gpx-maps_admin.php index 015be56..56ecfe5 100644 --- a/wp-gpx-maps_admin.php +++ b/wp-gpx-maps_admin.php @@ -85,21 +85,11 @@ function WP_GPX_Maps_html_page() {

You can also use gpx from other sites: [sgpx gpx="http://www.someone.com/somewhere/somefile.gpx"]


- Full set of attributes: [sgpx - gpx="< gpx file name >" - width=100% - mheight=450px - gheight=200px - mtype=SATELLITE - waypoints=true - donotreducegpx=false - pointsoffset=10 - uom=0 - mlinecolor=#3366cc - glinecolor=#3366cc] + Full set of attributes: [sgpx gpx="< gpx file name >" +    >> read below all the optional attributes <<    + ]

diff --git a/wp-gpx-maps_admin_settings.php b/wp-gpx-maps_admin_settings.php index 4149c87..5403f96 100644 --- a/wp-gpx-maps_admin_settings.php +++ b/wp-gpx-maps_admin_settings.php @@ -21,7 +21,6 @@ -

Map and Chart size

@@ -45,6 +44,18 @@
+

+ + + +

+ + +
+
+ + +

Maps

@@ -69,12 +80,52 @@ > TERRAIN: maps with physical features such as terrain and vegetation.
+ + + + + + + + + + + + + + + +
Start Icon: + (Url to image) Leave empty to hide +
End Icon: + (Url to image) Leave empty to hide +
Current Position Icon: + (Url to image) Leave empty for default +
+ +

+ + + +

+ +
+
+
+ +

Chart

+ + + + - + @@ -111,9 +166,32 @@ + + + +
Altitude line color: + +
Unit of measure:
Altitude line color:Altitude display offset: - + From + + To + + (leave empty for auto scale)
Show speed: - onchange="this.value = (this.checked)" />Show Speed (where available) + onchange="this.value = (this.checked)" />Show Speed
Speed display offset: + From + + To + + (leave empty for auto scale) +
+ +

+ + + +

+ +
+
+
+ + +

Advanced options (Do not edit if you don't know what you are doing!)

@@ -133,10 +211,11 @@ - +

-
\ No newline at end of file + +
\ No newline at end of file