Skip to content

Fix errors with non-float coordinates and add support for HTTPS URLs, asupport for providing valid Google Maps API keys #6

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

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
11 changes: 11 additions & 0 deletions app/indexHtml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var fs = require('fs');

// render index.html and replace MAPS_API_KEY
module.exports = function(app, publicDir) {
var indexHtml = fs.readFileSync(publicDir + '/index.html').toString()
.replace('%MAPS_API_KEY%', process.env.MAPS_API_KEY || 'AIzaSyDrn605l7RPadiwdzsOlRw9O28lxfYBJ6s');
app.get('/', function(req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.send(indexHtml);
});
};
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<link rel="stylesheet" href="style.css"/>

<!-- Google Maps API -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDrn605l7RPadiwdzsOlRw9O28lxfYBJ6s"></script>
<script src="//maps.googleapis.com/maps/api/js?key=%MAPS_API_KEY%"></script>

<!-- Modernizr -->
<script src="../bower_components/modernizr/bin/modernizr"></script>
Expand Down
10 changes: 5 additions & 5 deletions public/js/gservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ angular.module('gservice', [])
var initialize = function(latitude, longitude, filter) {

// Uses the selected lat, long as starting point
var myLatLng = {lat: selectedLat, lng: selectedLong};
var myLatLng = {lat: Number.parseFloat(selectedLat), lng: Number.parseFloat(selectedLong)};

// If map has not been created...
if (!map){
Expand All @@ -119,10 +119,10 @@ angular.module('gservice', [])

// If a filter was used set the icons yellow, otherwise blue
if(filter){
icon = "http://maps.google.com/mapfiles/ms/icons/yellow-dot.png";
icon = "//maps.google.com/mapfiles/ms/icons/yellow-dot.png";
}
else{
icon = "http://maps.google.com/mapfiles/ms/icons/blue-dot.png";
icon = "//maps.google.com/mapfiles/ms/icons/blue-dot.png";
}

// Loop through each location in the array and place a marker
Expand All @@ -149,7 +149,7 @@ angular.module('gservice', [])
position: initialLocation,
animation: google.maps.Animation.BOUNCE,
map: map,
icon: 'http://maps.google.com/mapfiles/ms/icons/red-dot.png'
icon: '//maps.google.com/mapfiles/ms/icons/red-dot.png'
});
lastMarker = marker;

Expand All @@ -162,7 +162,7 @@ angular.module('gservice', [])
position: e.latLng,
animation: google.maps.Animation.BOUNCE,
map: map,
icon: 'http://maps.google.com/mapfiles/ms/icons/red-dot.png'
icon: '//maps.google.com/mapfiles/ms/icons/red-dot.png'
});

// When a new spot is selected, delete the old red bouncing marker
Expand Down
5 changes: 4 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ var app = express();
// Express Configuration
// -----------------------------------------------------
// Sets the connection to MongoDB
mongoose.connect(database.mongolab.url);
mongoose.connect(database.local.url);

// replace MAPS_API_KEY in index.html
require('./app/indexHtml.js')(app, __dirname + '/public');

// Logging and Parsing
app.use(express.static(__dirname + '/public')); // sets the static files location to public
Expand Down