Giter VIP home page Giter VIP logo

alscotty / mapmyrunclone Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 89.98 MB

Fullstack web app inspired by MapMyRun; featuring Google Maps integration, likes/following, user-auth, activity feed, and workout downloads as GPX files

Home Page: https://rapmymun.herokuapp.com/

Ruby 0.77% JavaScript 98.47% CoffeeScript 0.01% CSS 0.63% HTML 0.12%
activity-feed distance workouts roads dashboard

mapmyrunclone's Introduction

RapMyMun

RapMyMun

RapMyMun is a fitness web application inspired by MapMyRun that allows for user running route creation. Users can log workout details, including duration, distance, and the route traveled. The app was created with React.js and Redux on the frontend, and Ruby on Rails/PostgreSQL on the backend.

The project was designed and built in a week, with some additional improvements added later on.

Highlights

  • Integrates Google Maps API to create run routes and enable distance tracking based on geolocation
  • Adheres to React and ES6 best practices to generate a true single page reactive web app experience
  • Developed a fluid UI to mimic the original website using SASS and HTML5
  • Implemented user authentication with BCrypt password encryption

home page

Features

Route Creation

create route

  • using Google Maps directions for rendering route and calculating distance:
    calcAndDisplayRoute(){
        let waypts=[]
        for(let i=0; i<this.state.coordinates.length; i++){
            waypts.push({
                location: this.state.coordinates[i],
                stopover:false
            });
        }
        
        const {coordinates,directionsService,directionsRenderer}=this.state;
        directionsService.route({
            origin: coordinates[0],
            destination: coordinates[coordinates.length-1],
            waypoints:waypts,
            optimizeWaypoints: false,
            travelMode: 'WALKING'
        }, (response, status)=> {
            if(status === 'OK'){
                directionsRenderer.setDirections(response);
                //calc miles
                var route=response.routes;
                let dist=route[0].legs[0].distance.value;
                let routeInfo = { ...this.state.routeInfo };
                routeInfo.miles = (dist * 0.00062137).toFixed(2);
                this.setState({ routeInfo })
            } else {
                window.alert('Directions request failed due to' + status)
            } 
        });
    }
  • Adding Google Roads API to keep the route on roads and prevent route from going through buildings, etc.
    snapPoint(lat,lng){
        let posArr=[lat,lng]
        $.get('https://roads.googleapis.com/v1/snapToRoads', {
            interpolate: true,
            key: window.googleAPIKey,
            path: posArr.join(",")
        },(data)=>{
            this.processSnappedPosData(data)
        });
    }

Activity Feed

  • Map rendering for routes on activity feed:
    renderIndMap(coordinates){
        let ren= new google.maps.DirectionsRenderer();
        let dir= new google.maps.DirectionsService();

        let map= new google.maps.Map(document.getElementById(`index-map-${this.props.route.id}`), {
            center: { lat: 37.773972, lng: -122.431297 },
            zoom: 13,
            maxZoom: 15,
            disableDefaultUI: true,
            gestureHandling:'none'
        });
        ren.setMap(map);

        let waypts = []
        for (let i = 0; i < coordinates.length; i++) {
            waypts.push({
                location: coordinates[i],
                stopover: false
            });
        }

Dashboard for Workouts

workouts

  • Workout dashboard dynamically renders depending on information provided (saved with a route, miles, time, etc.)
      {workout.time !=0 && workout.miles ? (
                    <span>
                    <br/>
                    Time:{workout.time} min.
                    </span>
                    )
                    : ''}
                    <br/>
                    {workout.route ? (
                    (<span>
                        {`${workout.route.miles} miles`}
                    </span>)
                    ): 
                    (<span>
                        {`${workout.miles} miles`}
                    </span>)
                }

Additional Resources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.