BIG CHANGE - Removed Gogole maps. Leafletjs instead.

-- NextGen Gallery is not working, due next gen image format changed -- I'll fix soon
This commit is contained in:
bastianonm 2018-08-01 12:18:31 +00:00
parent 277560810a
commit 5151dbf37c
4 changed files with 51 additions and 81 deletions

View File

@ -332,6 +332,7 @@ var WPGPXMAPS = {
this.EventSelectChart = null, this.EventSelectChart = null,
this.Polylines = [], this.Polylines = [],
this.CurrentPositionMarker = null, this.CurrentPositionMarker = null,
this.CurrentGPSPositionMarker = null,
this.init = function(targetElement, mapType, scrollWheelZoom, ThunderforestApiKey){ this.init = function(targetElement, mapType, scrollWheelZoom, ThunderforestApiKey){
this.map = L.map(targetElement, this.map = L.map(targetElement,
@ -822,9 +823,8 @@ var WPGPXMAPS = {
} }
} }
var bounds = new google.maps.LatLngBounds(); //var bounds = new google.maps.LatLngBounds();
var markerCurrentPosition = null;
if ( usegpsposition == "true" ) if ( usegpsposition == "true" )
{ {
@ -832,37 +832,32 @@ var WPGPXMAPS = {
// Try HTML5 geolocation // Try HTML5 geolocation
if(navigator.geolocation) { if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) { var context = map;
navigator.geolocation.watchPosition(function(position)
{
var radius = position.coords.accuracy / 2;
// user position // user position
var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var pos = [position.coords.latitude, position.coords.longitude];
// draw current position marker if (context.CurrentGPSPositionMarker == null)
markerCurrentPosition = new google.maps.Marker({
position: pos,
map: map,
title: "you",
animation: google.maps.Animation.DROP,
zIndex: 10
});
if (currentpositioncon)
{ {
markerCurrentPosition.setIcon(currentpositioncon); context.CurrentGPSPositionMarker = L.marker(pos)
.addTo(context.map)
.bindPopup("You are within " + radius + " meters from this point")
.openPopup();
} }
this.map.Bounds.push([position.coords.latitude, position.coords.longitude]); else
this.map.CenterMap();
}, function() {});
navigator.geolocation.watchPosition(function(position){
// move current position marker
if (markerCurrentPosition != null)
{ {
markerCurrentPosition.setPosition(new google.maps.LatLng(position.coords.latitude, position.coords.longitude)); context.CurrentGPSPositionMarker.setLatLng(pos);
} }
context.Bounds.push(pos);
context.CenterMap();
}, },
function(e){ function(e){
// some errors // some errors
@ -902,8 +897,8 @@ var WPGPXMAPS = {
imageLat = imageLat.replace(",", "."); imageLat = imageLat.replace(",", ".");
imageLon = imageLon.replace(",", "."); imageLon = imageLon.replace(",", ".");
var p = new google.maps.LatLng(imageLat, imageLon); //var p = new google.maps.LatLng(imageLat, imageLon);
bounds.extend(p); //bounds.extend(p);
var mc = new CustomMarker(map, p, imageUrl, img_w, img_h ); var mc = new CustomMarker(map, p, imageUrl, img_w, img_h );
@ -1035,37 +1030,6 @@ var WPGPXMAPS = {
$("div > ul > li > a", $_tab).click(FixMapSize); $("div > ul > li > a", $_tab).click(FixMapSize);
} }
var controlUIcenter = null;
var idFirstCenterChanged = true;
google.maps.event.addListener(map, 'center_changed', function() {
if (idFirstCenterChanged == true)
{
idFirstCenterChanged = false;
return;
}
if (controlUIcenter == null)
{
// Set CSS for the control border
controlUIcenter = document.createElement('img');
controlUIcenter.src = pluginUrl + "/wp-gpx-maps/img/backToCenter.png";
controlUIcenter.style.cursor = 'pointer';
controlUIcenter.title = lng.backToCenter;
controlDiv.appendChild(controlUIcenter);
// Setup the click event listeners
google.maps.event.addDomListener(controlUIcenter, 'click', function(event) {
map.setCenter(bounds.getCenter());
map.fitBounds(bounds);
controlDiv.removeChild(controlUIcenter);
controlUIcenter = null;
return false;
});
}
});
var graphh = jQuery('#myChart_' + params.targetId).css("height"); var graphh = jQuery('#myChart_' + params.targetId).css("height");

View File

@ -2,10 +2,10 @@
Contributors: bastianonm, Stephan Klein, Michel Selerin Contributors: bastianonm, Stephan Klein, Michel Selerin
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8VHWLRW6JBTML Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8VHWLRW6JBTML
Tags: maps, gpx, gps, graph, chart, google maps, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence Tags: maps, gpx, gps, graph, chart, leaflet, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence
Requires at least: 2.0.0 Requires at least: 2.0.0
Tested up to: 4.9.4 Tested up to: 4.9.7
Stable tag: 1.5.05 Stable tag: 1.6.01
Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map. Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map.
@ -153,6 +153,9 @@ Yes!
1. Altitude & Speed & Hearth rate 1. Altitude & Speed & Hearth rate
== Changelog == == Changelog ==
= 1.6.01 =
* Removed Gogole maps. Leafletjs instead.
* -- NextGen Gallery is not working, due next gen image format changed -- I'll fix soon
= 1.5.05 = = 1.5.05 =
* renamed javascript functions to avoid collision with other plugins * renamed javascript functions to avoid collision with other plugins
* reduced chart line thickness * reduced chart line thickness

View File

@ -3,7 +3,7 @@
* Plugin Name: WP-GPX-Maps * Plugin Name: WP-GPX-Maps
* Plugin URI: http://www.devfarm.it/ * Plugin URI: http://www.devfarm.it/
* Description: Draws a GPX track with altitude chart * Description: Draws a GPX track with altitude chart
* Version: 1.6-beta * Version: 1.6.01
* Author: Bastianon Massimo * Author: Bastianon Massimo
* Author URI: http://www.devfarm.it/ * Author URI: http://www.devfarm.it/
* Text Domain: wp-gpx-maps * Text Domain: wp-gpx-maps
@ -77,8 +77,9 @@ function enqueue_WP_GPX_Maps_scripts() {
/* chartjs */ /* chartjs */
wp_register_script('chartjs', plugins_url( '/js/Chart.min.js', __FILE__ ), array(), "2.7.2" ); wp_register_script('chartjs', plugins_url( '/js/Chart.min.js', __FILE__ ), array(), "2.7.2" );
wp_register_script('WP-GPX-Maps', plugins_url( '/js/WP-GPX-Maps.js', __FILE__ ), array('jquery','googlemaps','chartjs'), "1.5.05_8" ); wp_register_script('WP-GPX-Maps', plugins_url( '/js/WP-GPX-Maps.js', __FILE__ ), array('jquery','leaflet','chartjs'), "1.5.05_8" );
/*
$wpgpxmaps_googlemapsv3_apikey = get_option('wpgpxmaps_googlemapsv3_apikey'); $wpgpxmaps_googlemapsv3_apikey = get_option('wpgpxmaps_googlemapsv3_apikey');
if ($wpgpxmaps_googlemapsv3_apikey) { if ($wpgpxmaps_googlemapsv3_apikey) {
@ -87,6 +88,7 @@ function enqueue_WP_GPX_Maps_scripts() {
else { else {
wp_enqueue_script('googlemaps', '//maps.googleapis.com/maps/api/js', null, null); wp_enqueue_script('googlemaps', '//maps.googleapis.com/maps/api/js', null, null);
} }
*/
wp_enqueue_script('leaflet'); wp_enqueue_script('leaflet');
wp_enqueue_script('leaflet.fullscreen'); wp_enqueue_script('leaflet.fullscreen');
@ -608,10 +610,9 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$ngimgs_data = ''; $ngimgs_data = '';
if ( $ngGalleries != '' || $ngImages != '' ) { if ( $ngGalleries != '' || $ngImages != '' ) {
//print_r($points);
$ngimgs = getNGGalleryImages($ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error); $ngimgs = getNGGalleryImages($ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error);
$ngimgs_data =''; $ngimgs_data ='';
foreach ($ngimgs as $img) { foreach ($ngimgs as $img) {
$data = $img['data']; $data = $img['data'];
$data = str_replace("\n","",$data); $data = str_replace("\n","",$data);

View File

@ -34,6 +34,8 @@
array_push($pictures, nggdb::find_image($i)); array_push($pictures, nggdb::find_image($i));
} }
// print_r ($pictures);
foreach ($pictures as $p) { foreach ($pictures as $p) {
$item = array(); $item = array();