Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google maps #97

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion servers/dotNet/DisplayMap-Blue.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<meta charset="utf-8">

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maps.google.com/maps/api/js?v=3&sensor=false&libraries=adsense"></script>
<!--
<script src="//maps.google.com/maps/api/js?v=3"></script>
-->
<script src="js/maps.js"></script>
<script src="js/leaflet-0.7.5/leaflet.js"></script>
<script src="js/leaflet-plugins/google.js"></script>
Expand Down
4 changes: 3 additions & 1 deletion servers/dotNet/DisplayMap-Dark.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<meta charset="utf-8">

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maps.google.com/maps/api/js?v=3&sensor=false&libraries=adsense"></script>
<!--
<script src="//maps.google.com/maps/api/js?v=3"></script>
-->
<script src="js/maps.js"></script>
<script src="js/leaflet-0.7.5/leaflet.js"></script>
<script src="js/leaflet-plugins/google.js"></script>
Expand Down
4 changes: 3 additions & 1 deletion servers/dotNet/DisplayMap.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<meta charset="utf-8">

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maps.google.com/maps/api/js?v=3&sensor=false&libraries=adsense"></script>
<!--
<script src="//maps.google.com/maps/api/js?v=3"></script>
-->
<script src="js/maps.js"></script>
<script src="js/leaflet-0.7.5/leaflet.js"></script>
<script src="js/leaflet-plugins/google.js"></script>
Expand Down
70 changes: 40 additions & 30 deletions servers/dotNet/js/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,29 +147,37 @@

// use leaflet (http://leafletjs.com/) to create our map and map layers
var gpsTrackerMap = new L.map('map-canvas');

var openStreetMapsURL = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var openStreetMapsLayer = new L.TileLayer(openStreetMapsURL,
{attribution:'&copy;2014 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'});

// need to get your own bing maps key, http://www.microsoft.com/maps/create-a-bing-maps-key.aspx
// var bingMapsLayer = new L.BingLayer("GetAKey");
var googleMapsLayer = new L.Google('ROADMAP');

// this fixes the zoom buttons from freezing
// https://github.com/shramov/leaflet-plugins/issues/62
L.polyline([[0, 0], ]).addTo(gpsTrackerMap);

// this is the switcher control to switch between map types (upper right hand corner of map)
var layerSwitcher = new L.Control.Layers({}, {}); // add basemap layers below
layerSwitcher.addTo(gpsTrackerMap);

// this sets which map layer will first be displayed
gpsTrackerMap.addLayer(googleMapsLayer);

// this is the switcher control to switch between map types
gpsTrackerMap.addControl(new L.Control.Layers({
// 'Bing Maps':bingMapsLayer,
'Google Maps':googleMapsLayer,
'OpenStreetMaps':openStreetMapsLayer
}, {}));
// ------ OpenStreetMap basemap: ------
var openStreetMapsURL = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var openStreetMapsLayer = new L.TileLayer(openStreetMapsURL,
{attribution:'&copy;2014 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'});
layerSwitcher.addBaseLayer(openStreetMapsLayer, "OpenStreetMap");

// ------ OpenCycleMap basemap: ------
var openCycleMapsURL = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png';
var openCycleMapsLayer = new L.TileLayer(openCycleMapsURL,
{attribution:'&copy;2014 <a href="http://opencyclemap.org">OpenCycleMap</a> contributors'});
layerSwitcher.addBaseLayer(openCycleMapsLayer, "OpenCycleMap");

// ------ Google basemap: ------
if (typeof google != "undefined") {
var googleMapsLayer = new L.Google('ROADMAP');
layerSwitcher.addBaseLayer(googleMapsLayer, "Google Maps");
};

// this sets which map layer will be displayed by default,
gpsTrackerMap.addLayer(openStreetMapsLayer);
}

var finalLocation = false;
Expand Down Expand Up @@ -337,19 +345,21 @@
function displayCityName(latitude, longitude) {
var lat = parseFloat(latitude);
var lng = parseFloat(longitude);
var latlng = new google.maps.LatLng(lat, lng);
var reverseGeocoder = new google.maps.Geocoder();
reverseGeocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// results[0] is full address
if (results[1]) {
var reverseGeocoderResult = results[1].formatted_address;
showPermanentMessage(reverseGeocoderResult);
if (typeof google != "undefined") {
var latlng = new google.maps.LatLng(lat, lng);
var reverseGeocoder = new google.maps.Geocoder();
reverseGeocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// results[0] is full address
if (results[1]) {
var reverseGeocoderResult = results[1].formatted_address;
showPermanentMessage(reverseGeocoderResult);
}
} else {
console.log('Geocoder failed due to: ' + status);
}
} else {
console.log('Geocoder failed due to: ' + status);
}
});
});
}
}

function turnOffAutoRefresh() {
Expand Down
4 changes: 3 additions & 1 deletion servers/php/displaymap-blue.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maps.google.com/maps/api/js?v=3&sensor=false&libraries=adsense"></script>
<!--
<script src="http://maps.googleapis.com/maps/api/js?v=3"></script>
-->
<script src="js/maps.js"></script>
<script src="js/leaflet-0.7.5/leaflet.js"></script>
<script src="js/leaflet-plugins/google.js"></script>
Expand Down
4 changes: 3 additions & 1 deletion servers/php/displaymap-dark.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maps.google.com/maps/api/js?v=3&sensor=false&libraries=adsense"></script>
<!--
<script src="http://maps.googleapis.com/maps/api/js?v=3"></script>
-->
<script src="js/maps.js"></script>
<script src="js/leaflet-0.7.5/leaflet.js"></script>
<script src="js/leaflet-plugins/google.js"></script>
Expand Down
4 changes: 3 additions & 1 deletion servers/php/displaymap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maps.google.com/maps/api/js?v=3&sensor=false&libraries=adsense"></script>
<!--
<script src="http://maps.googleapis.com/maps/api/js?v=3"></script>
-->
<script src="js/maps.js"></script>
<script src="js/leaflet-0.7.5/leaflet.js"></script>
<script src="js/leaflet-plugins/google.js"></script>
Expand Down
74 changes: 45 additions & 29 deletions servers/php/js/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,29 +147,43 @@

// use leaflet (http://leafletjs.com/) to create our map and map layers
var gpsTrackerMap = new L.map('map-canvas');


// this fixes the zoom buttons from freezing
// https://github.com/shramov/leaflet-plugins/issues/62
L.polyline([[0, 0], ]).addTo(gpsTrackerMap);

// this is the switcher control to switch between map types (upper right hand corner of map)
var layerSwitcher = new L.Control.Layers({}, {}); // add basemap layers below
layerSwitcher.addTo(gpsTrackerMap);

// ------ OpenStreetMap basemap: ------
var openStreetMapsURL = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var openStreetMapsLayer = new L.TileLayer(openStreetMapsURL,
{attribution:'&copy;2014 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'});
layerSwitcher.addBaseLayer(openStreetMapsLayer, "OpenStreetMap");

// need to get your own bing maps key, http://www.microsoft.com/maps/create-a-bing-maps-key.aspx
// var bingMapsLayer = new L.BingLayer("GetAKey");
var googleMapsLayer = new L.Google('ROADMAP');

// this fixes the zoom buttons from freezing
// https://github.com/shramov/leaflet-plugins/issues/62
L.polyline([[0, 0], ]).addTo(gpsTrackerMap);

// this sets which map layer will first be displayed
gpsTrackerMap.addLayer(googleMapsLayer);
// ------ OpenCycleMap basemap: ------
var openCycleMapsURL = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png';
var openCycleMapsLayer = new L.TileLayer(openCycleMapsURL,
{attribution:'&copy;2014 <a href="http://opencyclemap.org">OpenCycleMap</a> contributors'});
layerSwitcher.addBaseLayer(openCycleMapsLayer, "OpenCycleMap");

// this is the switcher control to switch between map types
gpsTrackerMap.addControl(new L.Control.Layers({
// 'Bing Maps':bingMapsLayer,
'Google Maps':googleMapsLayer,
'OpenStreetMaps':openStreetMapsLayer
}, {}));
// ------ Bing basemap: ------
// need to get your own bing maps key, http://www.microsoft.com/maps/create-a-bing-maps-key.aspx
// and include the Bing API
// var bingMapsLayer = new L.BingLayer("AnH1IKGCBwAiBWfYAHMtIfIhMVybHFx2GxsReNP5W0z6P8kRa67_QwhM4PglI9yL");
// layerSwitcher.addBaseLayer(bingMapsLayer, "Bing Maps");

// ------ Google basemap: ------
if (typeof google != "undefined") {
var googleMapsLayer = new L.Google('ROADMAP');
layerSwitcher.addBaseLayer(googleMapsLayer, "Google Maps");
};

// this sets which map layer will be displayed by default,
gpsTrackerMap.addLayer(openStreetMapsLayer);
}

var finalLocation = false;
Expand Down Expand Up @@ -337,19 +351,21 @@
function displayCityName(latitude, longitude) {
var lat = parseFloat(latitude);
var lng = parseFloat(longitude);
var latlng = new google.maps.LatLng(lat, lng);
var reverseGeocoder = new google.maps.Geocoder();
reverseGeocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// results[0] is full address
if (results[1]) {
var reverseGeocoderResult = results[1].formatted_address;
showPermanentMessage(reverseGeocoderResult);
if (typeof google != "undefined") {
var latlng = new google.maps.LatLng(lat, lng);
var reverseGeocoder = new google.maps.Geocoder();
reverseGeocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// results[0] is full address
if (results[1]) {
var reverseGeocoderResult = results[1].formatted_address;
showPermanentMessage(reverseGeocoderResult);
}
} else {
console.log('Geocoder failed due to: ' + status);
}
} else {
console.log('Geocoder failed due to: ' + status);
}
});
});
}
}

function turnOffAutoRefresh() {
Expand Down
79 changes: 48 additions & 31 deletions servers/wordpress/gps-tracker/public/assets/js/gpstracker-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,29 +150,44 @@ jQuery(document).ready(function($) {

// use leaflet (http://leafletjs.com/) to create our map and map layers
var gpsTrackerMap = new L.map('map-canvas');


// this fixes the zoom buttons from freezing
// https://github.com/shramov/leaflet-plugins/issues/62
L.polyline([[0, 0], ]).addTo(gpsTrackerMap);

// this is the switcher control to switch between map types (upper right hand corner of map)
var layerSwitcher = new L.Control.Layers({}, {}); // add basemap layers below
layerSwitcher.addTo(gpsTrackerMap);

// ------ OpenStreetMap basemap: ------
var openStreetMapsURL = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var openStreetMapsLayer = new L.TileLayer(openStreetMapsURL,
{attribution:'&copy;2014 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'});
layerSwitcher.addBaseLayer(openStreetMapsLayer, "OpenStreetMap");

// ------ OpenCycleMap basemap: ------
var openCycleMapsURL = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png';
var openCycleMapsLayer = new L.TileLayer(openCycleMapsURL,
{attribution:'&copy;2014 <a href="http://opencyclemap.org">OpenCycleMap</a> contributors'});
layerSwitcher.addBaseLayer(openCycleMapsLayer, "OpenCycleMap");

// ------ Bing basemap: ------
// need to get your own bing maps key, http://www.microsoft.com/maps/create-a-bing-maps-key.aspx
// var bingMapsLayer = new L.BingLayer("GetAKey");
var googleMapsLayer = new L.Google('ROADMAP');

// this fixes the zoom buttons from freezing
// https://github.com/shramov/leaflet-plugins/issues/62
L.polyline([[0, 0], ]).addTo(gpsTrackerMap);
// and include the Bing API
// var bingMapsLayer = new L.BingLayer("AnH1IKGCBwAiBWfYAHMtIfIhMVybHFx2GxsReNP5W0z6P8kRa67_QwhM4PglI9yL");
// layerSwitcher.addBaseLayer(bingMapsLayer, "Bing Maps");

// this sets which map layer will first be displayed, go ahead and change it to bingMapsLayer or openStreetMapsLayer to see
gpsTrackerMap.addLayer(googleMapsLayer);
// ------ Google basemap: ------
if (typeof google != "undefined") {
var googleMapsLayer = new L.Google('ROADMAP');
layerSwitcher.addBaseLayer(googleMapsLayer, "Google Maps");
};

// this sets which map layer will be displayed by default,
gpsTrackerMap.addLayer(openStreetMapsLayer);

// this is the switcher control to switch between map types (upper right hand corner of map)
gpsTrackerMap.addControl(new L.Control.Layers({
// 'Bing Maps':bingMapsLayer,
'Google Maps':googleMapsLayer,
'OpenStreetMaps':openStreetMapsLayer
}, {}));
}

var locationArray = [];
Expand Down Expand Up @@ -333,22 +348,24 @@ jQuery(document).ready(function($) {
function displayCityName(latitude, longitude) {
var lat = parseFloat(latitude);
var lng = parseFloat(longitude);
var latlng = new google.maps.LatLng(lat, lng);
reverseGeocoder = new google.maps.Geocoder();
reverseGeocoder.geocode({'latLng': latlng}, function(results, status) {

if (status == google.maps.GeocoderStatus.OK) {
// results[0] is full address
if (results[1]) {
reverseGeocoderResult = results[1].formatted_address;
showPermanentMessage(reverseGeocoderResult);
} else {
console.log('No results found');
}
} else {
console.log('Geocoder failed due to: ' + status);
}
});
if (typeof google != "undefined") {
var latlng = new google.maps.LatLng(lat, lng);
reverseGeocoder = new google.maps.Geocoder();
reverseGeocoder.geocode({'latLng': latlng}, function(results, status) {

if (status == google.maps.GeocoderStatus.OK) {
// results[0] is full address
if (results[1]) {
reverseGeocoderResult = results[1].formatted_address;
showPermanentMessage(reverseGeocoderResult);
} else {
console.log('No results found');
}
} else {
console.log('Geocoder failed due to: ' + status);
}
});
}
}

function deleteRoute() {
Expand Down
2 changes: 1 addition & 1 deletion servers/wordpress/gps-tracker/public/class-gpstracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function enqueue_styles() {
* @since 1.0.0
*/
public function enqueue_scripts() {
wp_enqueue_script( $this->plugin_slug . '-gpstracker-google-maps', '//maps.google.com/maps/api/js?v=3&sensor=false&libraries=adsense', array(), self::VERSION );
// wp_enqueue_script( $this->plugin_slug . '-gpstracker-google-maps', '//maps.google.com/maps/api/js?v=3&sensor=false&libraries=adsense', array(), self::VERSION );
wp_enqueue_script( $this->plugin_slug . '-gpstracker-map-js', plugins_url( 'assets/js/gpstracker-map.js', __FILE__ ), array('jquery'), self::VERSION );
wp_enqueue_script( $this->plugin_slug . '-gpstracker-leaflet-js', plugins_url( 'assets/js/leaflet-0.7.5/leaflet.js', __FILE__ ), array('jquery'), self::VERSION );
wp_enqueue_script( $this->plugin_slug . '-gpstracker-google-js', plugins_url( 'assets/js/leaflet-plugins/google.js', __FILE__ ), array('jquery'), self::VERSION );
Expand Down