Skip to content
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ lib-cov
*.mk
*.obj
*.ai
*.idea
.idea
*.iml

.DS_Store
.env
Expand All @@ -32,4 +33,4 @@ coverage
deployment

assets/robots.txt
sftp-config.json
sftp-config.json
6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

58 changes: 6 additions & 52 deletions client/geocode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,15 @@ var googleGeocode = require('./google_geocode');

module.exports = geocode;
module.exports.geocode = geocode;
module.exports.reverseAmigo = reverseAmigo;
module.exports.suggestAmigo = suggestAmigo;
module.exports.reverseGoogle = reverseGoogle;
module.exports.suggestGoogle = suggestGoogle;
module.exports.lookupPlaceId = lookupPlaceId;



/**
* Geocoding options (google or amigo)
* Geocoding options (google or Google)
**/

var geocodingOptions = {
// amigoSuggestions: function (text, res) {
// var bounding = res.body.boundingbox;
// var bounding_split = bounding.split(",");
// var boinding_first = bounding_split[0].split(" ");
// var boinding_second = bounding_split[1].split(" ");
// var parameter = {
// 'token': config.realtime_access_token() ,
// 'boundary.rect.min_lat': boinding_first[1],
// 'boundary.rect.min_lon': boinding_first[0],
// 'boundary.rect.max_lat': boinding_second[1],
// 'boundary.rect.max_lon': boinding_second[0],
// 'sources':'osm,oa',
// 'text': text
// };

// return {
// get: function () {
// return $.get('https://www.amigocloud.com/api/v1/me/geocoder/search', parameter).then(function (data) {
// return {
// body: data
// };
// });
// }
// };
// },

// amigoReverse: function (ll) {
// var parameter = {
// 'token':config.realtime_access_token() ,
// 'point.lon':ll[0],
// 'point.lat':ll[1]
// };

// return {
// parameter: parameter,
// endpoint: 'https://www.amigocloud.com/api/v1/me/geocoder/reverse'
// };
// },
googleGeocoder: googleGeocode.googleGeocoder,
googleSuggestions: googleGeocode.googleSuggestions,
googlePlacesLookup: googleGeocode.googlePlacesLookup,
Expand All @@ -67,10 +27,10 @@ var geocodingOptions = {
* Reverse geocode
*/

function reverseAmigo(ll, callback) {
function reverseGoogle(ll, callback) {
log('--> reverse geocoding %s', ll);

// var query = geocodingOptions.amigoReverse(ll);
// var query = geocodingOptions.GoogleReverse(ll);
var query = geocodingOptions.googleReverse(ll);
console.log('attempting to reverse geocode', ll)

Expand All @@ -94,17 +54,14 @@ function reverseAmigo(ll, callback) {
/**
* Suggestions!
*/
function suggestAmigo(text, callback) {
function suggestGoogle(text, callback) {
console.log('getting suggestions for "' + text + '"')
var res = {
"body": {
"boundingbox": "-122.858905792236 36.818080227785,-121.452655792236 38.220919766831"
}
}
var query_text = text;
//get('https://www.amigocloud.com/api/v1/users/1/projects/661/datasets/22492', {
// 'token': config.realtime_access_token()
//}, function(err, res) {
var query = geocodingOptions.googleSuggestions(text, res);
query.get().then(function() {
var res = query.futureRes;
Expand All @@ -126,9 +83,6 @@ function geocode(text, callback) {
}
}
var query_text = text;
//get('https://www.amigocloud.com/api/v1/users/1/projects/661/datasets/22492', {
// 'token': config.realtime_access_token()
//}, function(err, res) {
var query = geocodingOptions.googleGeocoder(text, res);
query.get().then(function() {
var res = query.futureRes;
Expand Down
119 changes: 86 additions & 33 deletions client/map-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var collision = require('./leaflet_layergroup_collision.js');
var session = require('session');

var center = config.geocode().center.split(',').map(parseFloat)
if (config.map_provider && config.map_provider() !== 'AmigoCloud') {
if (config.map_provider && config.map_provider() == 'Mapbox' ) {
L.mapbox.accessToken = config.mapbox_access_token();
}

Expand All @@ -17,57 +17,110 @@ module.exports = function (el) {
localStorage.removeItem('dataplan');
sessionStorage.removeItem('dataplan');

if (config.map_provider && config.map_provider() === 'AmigoCloud') {
if (config.map_provider && config.map_provider() === 'GoogleV3') {
southWest = L.latLng(35.946877085397, -123.480610897013);
northEast = L.latLng(40.763279543715, -118.789317362500);
map = (new L.amigo.map(el, {
amigoLogo: 'right',
loadAmigoLayers: false,
inertia: false,

map = (new L.map(el, {
zoomAnimation: true,
maxBounds: L.latLngBounds(southWest, northEast),
minZoom: 8
})).setView([center[1], center[0]], config.geocode().zoom);

L.amigo.auth.setToken(config.support_data_token());
var roadMutant = L.gridLayer.googleMutant({
maxZoom: 24,
type:'roadmap'
}).addTo(map);

blurLayer = L.tileLayer(
'https://www.amigocloud.com/api/v1/users/' +
'23/projects/3019/datasets/23835/tiles/{z}/{x}/{y}.png?' +
'token=' + config.support_data_token(), {
name: 'Uncovered Area'
}
);
var satMutant = L.gridLayer.googleMutant({
maxZoom: 24,
type:'satellite'
});

map.addAuthLayer({
id: config.mapbox_map_id(),
accessToken: config.mapbox_access_token(),
name: 'Gray',
provider: 'mapbox'
var terrainMutant = L.gridLayer.googleMutant({
maxZoom: 24,
type:'terrain'
});
map.addBaseLayer(L.amigo.AmigoGray);
map.layersControl.addBaseLayer(
L.bingLayer(
config.bing_key(), {
type: 'Road',
attribution: 'Bing Maps'
}
),
'Bing Road'
);
map.layersControl.addOverlay(blurLayer);
blurLayer.addTo(map);

var hybridMutant = L.gridLayer.googleMutant({
maxZoom: 24,
type:'hybrid'
});

var styleMutant = L.gridLayer.googleMutant({
styles: [
{elementType: 'labels', stylers: [{visibility: 'off'}]},
{featureType: 'water', stylers: [{color: '#444444'}]},
{featureType: 'landscape', stylers: [{color: '#eeeeee'}]},
{featureType: 'road', stylers: [{visibility: 'off'}]},
{featureType: 'poi', stylers: [{visibility: 'off'}]},
{featureType: 'transit', stylers: [{visibility: 'off'}]},
{featureType: 'administrative', stylers: [{visibility: 'off'}]},
{featureType: 'administrative.locality', stylers: [{visibility: 'off'}]}
],
maxZoom: 24,
type:'roadmap'
});

var trafficMutant = L.gridLayer.googleMutant({
maxZoom: 24,
type:'roadmap'
});
trafficMutant.addGoogleLayer('TrafficLayer');


var transitMutant = L.gridLayer.googleMutant({
maxZoom: 24,
type:'roadmap'
});
transitMutant.addGoogleLayer('TransitLayer');

L.control.layers({
Roadmap: roadMutant,
Aerial: satMutant,
Terrain: terrainMutant,
Hybrid: hybridMutant,
Styles: styleMutant,
Traffic: trafficMutant,
Transit: transitMutant
}, {}, {
collapsed: false
}).addTo(map);

//L.control.locate().addTo(map);

map.routes = []; // array to hold all route objects

module.exports.activeMap = map;

//map.realtimeControl = L.control.toggleRealTime().addTo(map);

realtime = mapModule.realtime();

} else if (config.map_provider && config.map_provider() === 'ESRI') {
southWest = L.latLng(35.946877085397, -123.480610897013);
northEast = L.latLng(40.763279543715, -118.789317362500);

map = (new L.map(el, {
zoomAnimation: true,
maxBounds: L.latLngBounds(southWest, northEast),
minZoom: 8
})).setView([center[1], center[0]], config.geocode().zoom);

/**
* @todo Add Layer Controls for switching ESRI basemaps
* @see https://esri.github.io/esri-leaflet/examples/switching-basemaps.html
*
*/
// L.esri.basemapLayer('Topographic').addTo(map);
// L.esri.basemapLayer('Imagery').addTo(map);
L.esri.basemapLayer('Streets').addTo(map);
// L.esri.basemapLayer('Terrain').addTo(map);
// L.esri.basemapLayer('Gray').addTo(map);

map.routes = []; // array to hold all route objects

module.exports.activeMap = map;

realtime = mapModule.realtime();

} else {

Expand Down
16 changes: 8 additions & 8 deletions client/map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module.exports = function(el, opts) {
};

// create a map in the el with given options
if (config.map_provider && config.map_provider() === 'AmigoCloud') {
return new Map(L.amigo.map(el, opts));
if (config.map_provider && config.map_provider() === 'GoogleV3') {
return new Map(L.map(el, opts));
} else {
return new Map(L.mapbox.map(el, config.mapbox_map_id(), opts));
}
Expand All @@ -30,9 +30,9 @@ module.exports.createMarker = function(opts) {

var marker;

if (config.map_provider && config.map_provider() === 'AmigoCloud') {
if (config.map_provider && config.map_provider() === 'GoogleV3') {
marker = L.marker(new L.LatLng(opts.coordinate[1], opts.coordinate[0]), {
icon: L.amigo.marker.icon({
icon: L.map.marker.icon({
'marker-size': opts.size || 'medium',
'marker-color': opts.color || '#ccc',
'marker-symbol': opts.icon || ''
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports.createMarker = function(opts) {
*/


if (config.map_provider() === 'AmigoCloud') {
if (config.map_provider() !== 'Mapbox') {
module.exports.realtime = function() {
debug('setting up empty socket connection');

Expand Down Expand Up @@ -177,7 +177,7 @@ module.exports.drawRoute = function (marker) {
queryUrl = projectUrl + '/sql?token=' + config.realtime_access_token() +
'&query=' + query + '&limit=1000';

L.amigo.utils.get(queryUrl).
L.map.utils.get(queryUrl).
then(function (data) {
if (!data.data.length) {
return;
Expand Down Expand Up @@ -383,8 +383,8 @@ module.exports.makePopup = function (point) {

function Map(map) {
this.map = map;
if (config.map_provider && config.map_provider() === 'AmigoCloud') {
this.featureLayer = L.amigo.featureLayer().addTo(map);
if (config.map_provider && config.map_provider() === 'GoogleV3') {
this.featureLayer = L.map.featureLayer().addTo(map);
} else {
this.featureLayer = L.mapbox.featureLayer().addTo(map);
}
Expand Down
4 changes: 2 additions & 2 deletions client/plan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Plan.prototype.setAddress = function(name, address, callback, extra) {
// this happens when the user clicks on one of the suggestions
// or hits enter in the from/to textbox
console.log('Looking up the Google Places details for place_id='+places_id+'')
var cb_amigo_placesid = function(err, place){
var cb_google_places = function(err, place){
console.log('Places ID callback', place)
if (place){
var lat_lng = place.geometry.location.lat()+','+place.geometry.location.lng();
Expand All @@ -284,7 +284,7 @@ Plan.prototype.setAddress = function(name, address, callback, extra) {
plan.setAddress('', '', callback);
}
}
geocode.lookupPlaceId(places_id, cb_amigo_placesid);
geocode.lookupPlaceId(places_id, cb_google_places);
} else {
// it's whole or part of a physical address/place name
// this happens when opening a link to Trip Planner which has addresses already in place
Expand Down
10 changes: 7 additions & 3 deletions client/planner.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
<!-- <link href="https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.css" rel="stylesheet"> -->
<link href="https://www.amigocloud.com/static/amigocloud-1.0.3/amigocloud-1.0.3.css" rel="stylesheet">
<link href="https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.css" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
<link rel="stylesheet" href="https://www.domoritz.de/leaflet-locatecontrol/dist/L.Control.Locate.min.css" />

<link href="{{static_url}}/build/planner-app/build.css?v={{version}}" rel="stylesheet">
Expand Down Expand Up @@ -51,7 +51,11 @@ <h1 style="text-align:center;">JavaScript must be enabled to use this website.</
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<script src="https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCy3D65qSh0YJt3gtMi_zk3hOGRxikC3k4&libraries=places"></script>
<script src="https://www.amigocloud.com/static/amigocloud-1.0.3/amigocloud-1.0.3.js"></script>
<!-- Load Leaflet from CDN-->
<script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet-src.js"></script>
<!-- Load Google & Esri Leaflet from CDN -->
<script src="https://unpkg.com/esri-leaflet@2.0.8"></script>
<script src="https://unpkg.com/leaflet.gridlayer.googlemutant@latest/Leaflet.GoogleMutant.js"></script>
<script src="https://www.domoritz.de/leaflet-locatecontrol/dist/L.Control.Locate.min.js"></script>
<script src="{{static_url}}/build/messages/en.js?v={{version}}"></script>
<script src="{{static_url}}/build/planner-app/build.js?v={{version}}"></script>
Expand Down
Loading