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

  • SEARCH
  • Home
  • 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 6623985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:35:53+00:00 2026-05-25T21:35:53+00:00

I have never worked with Google maps API. For the school project I am

  • 0

I have never worked with Google maps API.

For the school project I am working on; I need to get a direction between two locations (this is easy part and I think I can do this),

However I also need to put an X mark; at every 10 miles along the way.

Is this even possible?

Thank You.

  • 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-25T21:35:53+00:00Added an answer on May 25, 2026 at 9:35 pm

    Ok, here’s a working solution that draws markers every 200 miles (I was working on big distances to check it worked on geodesic curved lines, which it does). To make this work for you, just change all the coordinates, and change 200 to 10

    <!DOCTYPE html>
    <html>
    <head>
    <title>lines with markers every x miles</title>
    
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
    html { height: 100% }
    body { height: 100%; margin: 0; padding: 0 }
    #map_canvas { height: 100% }
    </style>
    <!--- need to load the geometry library for calculating distances, see http://www.svennerberg.com/2011/04/calculating-distances-and-areas-in-google-maps-api-3/ --->
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false"></script>
    
    <script type="text/javascript"> 
        function initialize() {
            var startLatlng = new google.maps.LatLng(54.42838,-2.9623);
            var endLatLng = new google.maps.LatLng(52.908902,49.716793);
    
            var myOptions = {
                zoom: 4,
                center: new google.maps.LatLng(51.399206,18.457031),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
    
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
            var startMarker = new google.maps.Marker({
                position: startLatlng, 
                map: map
            });
    
            var endMarker = new google.maps.Marker({
                position: endLatLng, 
                map: map
            });
    
            // draw a line between the points
            var line = new google.maps.Polyline({
                path: [startLatlng, endLatLng],
                strokeColor: "##FF0000",
                strokeOpacity: 0.5,
                strokeWeight: 4,
                geodesic: true,
                map: map
            });
    
            // what's the distance between these two markers?
            var distance = google.maps.geometry.spherical.computeDistanceBetween(
                startLatlng, 
                endLatLng
            );
    
            // 200 miles in meters
            var markerDistance = 200 * 1609.344;
    
            var drawMarkers = true;
    
            var newLatLng = startLatlng;
    
            // stop as soon as we've gone beyond the end point 
            while (drawMarkers == true) {
                // what's the 'heading' between them?
                var heading = google.maps.geometry.spherical.computeHeading(
                    newLatLng, 
                    endLatLng
                );
    
                // get the latlng X miles from the starting point along this heading
                 var newLatLng = google.maps.geometry.spherical.computeOffset(
                    newLatLng,
                    markerDistance, 
                    heading
                );
    
                // draw a marker
                var newMarker = new google.maps.Marker({
                    position: newLatLng, 
                    map: map
                });
    
                // calculate the distance between our new marker and the end marker
                var newDistance = google.maps.geometry.spherical.computeDistanceBetween(
                    newLatLng, 
                    endLatLng
                );
    
                if (newDistance <= markerDistance) {
                    drawMarkers = false;
                }
            }
        }
    
        google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    </head>
    <body>
      <div id="map_canvas"></div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a SSIS project. I have never worked with SSIS before, and
I'm currently working with MVC 1.0 and have never worked with AJAX before and
For a project I'm using both Scala and Riak (two things I have never
I have never worked with json before. I am trying: http://api.worldbank.org//topics?format=JSON and make things
I have never worked with web services and rails, and obviously this is something
I might be an exception here but I have never worked on a team
So I've never worked with stored procedures and have not a whole lot of
I have never used virtualization, and am trying to get up to speed. My
I have never worked on classic ASP and unfortunately I am supposed to modify
I have just arrived at new company and have never worked with Qt before,

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.