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 1087793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:59:08+00:00 2026-05-16T22:59:08+00:00

I can decode the points, I just need to figure out how to loop

  • 0

I can decode the points, I just need to figure out how to loop through the array of points and produce

[
new google.maps.LatLng(39.112456,-84.574779),
new google.maps.LatLng(39.314153,-84.261379),
new google.maps.LatLng(39.197099,-84.667579),
new google.maps.LatLng(39.16836,-84.479381)
];

Code available at http://pastebin.com/Zf6hi4AB

Any help is appreciated.

<!--- this is the original function --->
function decodeLine (encoded) {
  var len = encoded.length;
  var index = 0;
  var array = [];
  var lat = 0;
  var lng = 0;

  while (index < len) {
    var b;
    var shift = 0;
    var result = 0;
    do {
      b = encoded.charCodeAt(index++) - 63;
      result |= (b & 0x1f) << shift;
      shift += 5;
    } while (b >= 0x20);
    var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
    lat += dlat;

    shift = 0;
    result = 0;
    do {
      b = encoded.charCodeAt(index++) - 63;
      result |= (b & 0x1f) << shift;
      shift += 5;
    } while (b >= 0x20);
    var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
    lng += dlng;

    array.push([lat * 1e-5, lng * 1e-5]);
  }

  return array;




<!---  this is what i am trying --->
function decodeLine(encoded) {
  var len = encoded.length;
  var index = 0;
  var array = [];
  var lat = 0;
  var lng = 0;

  while (index < len) {
    var b;
    var shift = 0;
    var result = 0;
    do {
      b = encoded.charCodeAt(index++) - 63;
      result |= (b & 0x1f) << shift;
      shift += 5;
    } while (b >= 0x20);
    var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
    lat += dlat;

    shift = 0;
    result = 0;
    do {
      b = encoded.charCodeAt(index++) - 63;
      result |= (b & 0x1f) << shift;
      shift += 5;
    } while (b >= 0x20);
    var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
    lng += dlng;

    array.push([new google.maps.LatLng(lat * 1e-5, lng * 1e-5)]);
  }

  return array;
}




<!--- this is how i trying to use it --->
var polygon_#fips#Coords = [];
    var polygon_#fips#Coords = [decodeLine('#points#')];
    var polygon_#fips#;


    polygon_#fips# = new google.maps.Polygon({
      paths: polygon_#fips#Coords,
      strokeColor: "##FF0000",
      strokeOpacity: 0.8,
      strokeWeight: 3,
      fillColor: "###polyfillcolor#",
      fillOpacity: 0.35
    });

    polygon_#fips#.setMap(map);

<!--- this is the orinigal use --->
var polygon_#fips#Coords = [];
    var polygon_#fips#Coords = [
            new google.maps.LatLng(39.112456,-84.574779),
            new google.maps.LatLng(39.314153,-84.261379),
            new google.maps.LatLng(39.197099,-84.667579),
            new google.maps.LatLng(39.16836,-84.479381)
    ];

    var polygon_#fips#;


    polygon_#fips# = new google.maps.Polygon({
      paths: polygon_#fips#Coords,
      strokeColor: "##FF0000",
      strokeOpacity: 0.8,
      strokeWeight: 3,
      fillColor: "###polyfillcolor#",
      fillOpacity: 0.35
    });

    polygon_#fips#.setMap(map);
  • 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-16T22:59:09+00:00Added an answer on May 16, 2026 at 10:59 pm

    OK I think I see what you’re saying. Try changing

     var polygon_#fips#Coords = [decodeLine('#points#')];
    

    to

     var polygon_#fips#Coords = decodeLine('#points#');
    

    Also in decodeLine() change

     array.push([new google.maps.LatLng(lat * 1e-5, lng * 1e-5)]);
    

    to

     array.push(new google.maps.LatLng(lat * 1e-5, lng * 1e-5));
    

    What you were doing is adding a new array of google.maps.LatLng to the end of your array, so you ended up with an array of arrays of google.maps.LatLng.
    With this change, you should end up with an array of google.maps.LatLng, which is what you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to utilize the Google Maps API. I just found out a minute
I need to use Google Maps (v3) to check whether an address typed into
Guys I am becoming completely nut on this...and can't figure out at all how
I'm looking for a method in which I can decode and encode text to
How can I decode a hex string to an ascii string? I want to
How can I decode a json response in C#?
If we can't decode the MD5 hash string, then what is the purpose of
Can anyone please decode the following nested IIF to a CASE statement in SQL..
I can't seem to decode this base64 string which is in the footer of
How can I use Speex to encode/decode from within python? Are there any wrappers?

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.