Git Product home page Git Product logo

quasar-googlemaps-cypress's Introduction

titulo

Quasar GoogleMaps Cypress

Example of a Quasar app with Google Maps and Cypress automated tests

Technologies:

  • Quasar v1
  • Google Maps API
  • Google Maps Places API
  • Google Maps Directions API
  • Cypress

Objective

You will learn how to use the Google Maps APIs to add markers, draw circles, search for places and draw paths to the destinations in a Quasar app. Then we will test the application with Cypress, an amazing tool for testing front-end applications. For more examples about Cypress, visit the Vila do Silício blog.

Try the app now running on quasar-googlemaps.surge.sh.

Before Start

Install the latest version of Cypress by running this command:

npm install cypress --save-dev

Google Maps

Go to Google developers console and create a project.

google01

Activate the APIs and services.

google02

Search for the Places API and enable it.

google03

Create credentials with the API Key type.

google04

Copy the API key.

google05

Search for the Maps Javascript API and enable it.

google06

The same API Key will be used by default.

google07

Search for the Directions API and enable it.

google08

Three APIs will be used: Directions, Maps and Places.

google09

Quasar

Now let's go to the code. In the root folder of the project, add the map API key created before.

quasar01

Install the dependencies:

npm install

Run the app:

quasar dev

The main screen contains a search field and a map. The user position is detected and a red marker is positioned at the center of the map.

quasar02

The map contains two buttons at its right side: the Camera Button and the Circle Button.

quasar03

The Camera button animates the map camera toward the user's position.

quasar04

The Circle button with a plus icon opens a modal that allows the user to add a circle around its marker with a customized color, radius and opacity. If the Circle button has a minus icon, it will remove the circle.

quasar05

The circle has no effect in the map. It is just a fun feature to use ^_^.

quasar06

The search field above the map lists the places at each character typed.

quasar07

Click on one option and a blue marker will be added to the map at the place's position with its full address inside the info window

quasar08

Once the place is marked on the map, the Directions button will be visible next to the search field.

quasar09

After clicked, a path will be drawn between the origin (the user's position) and the destination (the place's position). The total distance between them will be shown at the bottom.

quasar10

After the path is drawn, the Clear button will be visible instead of the Directions button and it will allow to remove the place's marker and the drawn path.

quasar11

Cypress

Now let's test our application automatically. Inside the "/cypress/integration" folder are the test scripts to be executed. While keeping the application running, open the Cypress Browser with this command in another terminal:

npm run cypress

It will list the test files inside the "/cypress/integration" folder.

cypress01

Click on each option to open the test window, allow the geolocation detection when asked and wait for the result. Some of the test need the user interaction.

Center Camera Test

cypress02

Add Remove Circle Test

cypress03

Search Places Test

cypress04

Add Remove Directions Test

cypress05

quasar-googlemaps-cypress's People

Contributors

lucianopereira86 avatar

Watchers

James Cloos avatar

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.