Git Product home page Git Product logo

google-maps-tsp's Introduction

Google-Maps-TSP

Experimentos para el problema del viajero

TSP Solver for Google Maps API

This component enables Google Maps API developers to compute the fastest route that visits a given set of locations.

Different algorithms are selected based on the number of input locations, in order to produce results in a responsive manner. For large sets of points, the returned solution will be approximate. It is an NP-complete problem after all.

Code example: ``` // Your normal Google Map object initialization var myOptions = { zoom: zoom, center: center, mapTypeId: google.maps.MapTypeId.ROADMAP }; myMap = new google.maps.Map(div, myOptions); directionsPanel = document.getElementById("my_textual_div");

// Create the tsp object tsp = new BpTspSolver(myMap, directionsPanel);

// Set your preferences tsp.setAvoidHighways(true); tsp.setTravelMode(google.maps.DirectionsTravelMode.WALKING);

// Add points (by coordinates, or by address). // The first point added is the starting location. // The last point added is the final destination (in the case of A - Z mode) tsp.addWaypoint(latLng, addWaypointCallback); // Note: The callback is new for version 3, to ensure waypoints and addresses appear in the order they were added in. tsp.addAddress(address, addAddressCallback);

// Solve the problem (start and end up at the first location) tsp.solveRoundTrip(onSolveCallback); // Or, if you want to start in the first location and end at the last, // but don't care about the order of the points in between: tsp.solveAtoZ(onSolveCallback);

// Retrieve the solution (so you can display it to the user or do whatever :-) var dir = tsp.getGDirections(); // This is a normal GDirections object. // The order of the elements in dir now correspond to the optimal route.

// If you just want the permutation of the location indices that is the best route: var order = tsp.getOrder();

// If you want the duration matrix that was used to compute the route: var durations = tsp.getDurations();

// There are also other utility functions, see the source. ```

To get the source, click on the 'Source' tab and follow the instructions. You will need a subversion client.

google-maps-tsp's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.