Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6908877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:37:05+00:00 2026-05-27T08:37:05+00:00

I reading stuff about the Google API and I wanted to implement the usual

  • 0

I reading stuff about the Google API and I wanted to implement the usual Google driving directions that Google maps has for 2 different points. Here’s my code so far

(function() {
  window.onload = function() {

// Creating a map
var options = {
  zoom: 5,
  center: new google.maps.LatLng(36.1834, -117.4960),
  mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), options);

// Creating an array that will contain the points for the polyline
var route = [
  new google.maps.LatLng(37.7671, -122.4206),
  new google.maps.LatLng(34.0485, -118.2568)
];

// Creating the polyline object
var polyline = new google.maps.Polyline({
  path: route,
  strokeColor: "#ff0000",
  strokeOpacity: 0.6,
  strokeWeight: 5
});

// Adding the polyline to the map
polyline.setMap(map);

  };
 })();

It has a straight line between the two cities…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:37:05+00:00Added an answer on May 27, 2026 at 8:37 am

    Here’s an example of using the DirectionsService:

    var directionsService = new google.maps.DirectionsService();
    var directionsDisplay;
    var homeLatlng;
    
    function initialize() {
        homeLatlng = new google.maps.LatLng(37.7671, -122.4206);
    
        var myOptions = {
            zoom: 10,
            center: homeLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
        var infowindow = new google.maps.InfoWindow({
            content: ''
        });
    
        directionsDisplay = new google.maps.DirectionsRenderer({
            draggable: false,
            map: map, 
            markerOptions: {
                draggable: false
            },
            panel: document.getElementById("directionsPanel"),
            infoWindow: infowindow
        });
    
        var request = {
            origin:homeLatlng,
            destination:new google.maps.LatLng(34.0485, -118.2568),
            travelMode: google.maps.DirectionsTravelMode[DRIVING],
            unitSystem: google.maps.UnitSystem[METRIC]
        };
    
        directionsService.route(request, function(result, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(result);
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remember reading about quoting stuff when doing a SQL query and that when
I am a newbie to google app engine stuff. I am reading about app
Guys, I HAVE tried reading tons of stuff about EJB. And I don't get
I was reading in Google's documentation about improving site speed. One of their recommendations
I've been reading a lot of stuff about functional programming lately, and I can
Quick question, I've been reading about some .Net stuff and the way some people
Everytime I'm looking for AutoMapper stuff on StackOverflow, I'm reading something about ValueInjecter .
Reading all about PHP frameworks, CodeIgniter seems really nice in that I like it's
I've been reading a bunch of stuff about security and I'm just now starting
Well, I've been reading 2 hours about mysql_real_escape() and addslashes() and stuff, but my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.