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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:31:51+00:00 2026-05-22T03:31:51+00:00

OK, so I have a polygon that is represented as an encoded polyline. I’d

  • 0

OK, so I have a polygon that is represented as an encoded polyline. I’d like to put this on a map, but can’t figure out the syntax. Here’s what I got:

  setRegion = new google.maps.Polyline({
    locations: "}~kvHmzrr@ba\hnc@jiu@r{Zqx~@hjp@pwEhnc@zhu@zflAbxn@fhjBvqHroaAgcnAp}gAeahAtqGkngAinc@_h|@r{Zad\y|_D}_y@swg@ysg@}llBpoZqa{@xrw@~eBaaX}{uAero@uqGadY}nr@`dYs_NquNgbjAf{l@|yh@bfc@}nr@z}q@i|i@zgz@r{ZhjFr}gApob@ff}@laIsen@dgYhdPvbIren@",
    levels: "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
    strokeColor: "#FF0000",
    strokeOpacity: 0.8,
    strokeWeight: 2,
    fillColor: "#FF0000",
    fillOpacity: 0.35
  });

  setRegion.setMap(map);

Which I created using the Polyline Encoder Tool. From this same page I got its use, which is:

The polyline encoding will appear in
the Encoded Polyline and Encoded
Levels fields below. Use these values
for locations and levels when you
create your google.maps.Polyline

However, the polygon does not appear. Anybody any idea what is going wrong?

UPDATE

I tried this, but get the error Uncaught TypeError: Cannot read property 'encoding' of undefined.

<!doctype html> 
<html> 
<head> 
<title>Test</title> 
<meta charset="iso-8859-1"> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false"></script>

<style type="text/css"> 
#map {width:670px;height:600px;}
</style> 
<script type='text/javascript'>
function initialize() {
    var myLatlng = new google.maps.LatLng(51.65905179951626, 7.3835928124999555);
    var myOptions = {
        zoom: 8,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map"), myOptions);
    var decodedPath = google.maps.geometry.encoding.decodePath("}~kvHmzrr@ba\hnc@jiu@r{Zqx~@hjp@pwEhnc@zhu@zflAbxn@fhjBvqHroaAgcnAp}gAeahAtqGkngAinc@_h|@r{Zad\y|_D}_y@swg@ysg@}llBpoZqa{@xrw@~eBaaX}{uAero@uqGadY}nr@`dYs_NquNgbjAf{l@|yh@bfc@}nr@z}q@i|i@zgz@r{ZhjFr}gApob@ff}@laIsen@dgYhdPvbIren@");
    var decodedLevels = decodeLevels("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB");

    setRegion = new google.maps.Polyline({
        locations: decodedPath,
        levels: decodedLevels,
        strokeColor: "#FF0000",
        strokeOpacity: 1.0,
        strokeWeight: 2
    });
    setRegion.setMap(map);

}

function decodeLevels(encodedLevelsString) {
    var decodedLevels = [];

    for (var i = 0; i < encodedLevelsString.length; ++i) {
        var level = encodedLevelsString.charCodeAt(i) - 63;
        decodedLevels.push(level);
    }
    return decodedLevels;
}


</script> 
</head> 


<body onload="initialize()"> 

<div id="map"></div>

</body> 
</html>
  • 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-22T03:31:51+00:00Added an answer on May 22, 2026 at 3:31 am

    google.maps.geometry.encoding.decodePath(encodedPath:string)

    http://code.google.com/apis/maps/documentation/javascript/reference.html#encoding

    From that page:

    var decodedPath = google.maps.geometry.encoding.decodePath(encodedPolyline);
    var decodedLevels = decodeLevels(encodedLevels);
    
    // Decode an encoded levels string into an array of levels.
    function decodeLevels(encodedLevelsString) {
      var decodedLevels = [];
    
      for (var i = 0; i < encodedLevelsString.length; ++i) {
        var level = encodedLevelsString.charCodeAt(i) - 63;
        decodedLevels.push(level);
      }
    
      return decodedLevels;
    }
    

    Make sure the geometry libaray is being loaded per: http://code.google.com/apis/maps/documentation/javascript/basics.html#Libraries

    Working example of the encoded polyline at: http://jsfiddle.net/ryanrolds/ukRsp/

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

Sidebar

Related Questions

I can't figure out what is up with this. I have a Scene class
I have a two dimensional polygon mesh made of connected triangles represented like this:
I have a polygon soup of triangles that I would like to construct a
I have a simple polygon (convex or concave, but no holes) that I need
i have an application that shows a simple square polygon represented on a GLSurfaceView.
I have a polygon with V vertices and n number of openings. How can
I have a problem when constructing a polygon. The error message says something like:
I want to fill a polygon shape that I have drawn via Core Graphics
Imagine that you have some polygon on the center of the screen (let's say
I have a polygon and a terrain model (can be either grid or TIN).

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.