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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:06:12+00:00 2026-06-07T14:06:12+00:00

I need a help, I tried to change my polyline color, it dont works,

  • 0

I need a help, I tried to change my polyline color, it dont works, I dont know if my solution for the drawline is right, please, help me =) I will poste 2 codes of my normal code and one code with my try. thanks =)

//This is My complete code
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</style>

<script type="text/javascript"
src="https://maps.google.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
var infowindow, map, path = [], service = new google.maps.DirectionsService(), poly;


var directionDisplay;
var directionsService = new google.maps.DirectionsService();


function initialize() 
{
directionsDisplay = new google.maps.DirectionsRenderer();
 directionsDisplay.setPanel(document.getElementById("directionsPanel"));
var latlng = new google.maps.LatLng(41.850033, -87.6500523);
 var myOptions = 
{
  zoom: 8,
  center: latlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP,
   mapTypeControlOptions: {
  mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID]
},
disableDoubleClickZoom: true, //Desabilitar atalho do zoom por clique

draggableCursor: "crosshair" //Cursor do Mouse em +

};


var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

directionsDisplay.setMap(map);


// FAZ A ROTA



google.maps.event.addListener(map, "click", function(evt) {
if (path.length == 0) {
  path.push(evt.latLng);
  poly = new google.maps.Polyline ({ map: map});
  poly.setPath(path);
} else {
  service.route({
    origin: path[path.length - 1],
    destination: evt.latLng,
    travelMode: google.maps.DirectionsTravelMode.DRIVING  //Pode ser Walking, Driving ou Bicycling

  }, function(result, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      path = path.concat(result.routes[0].overview_path);
      poly.setPath(path);
       }
     });
    }
  });




//Marcador
/*var marker = new google.maps.Marker({ position: latlng,   title:"Hello World!"});
marker.setMap(map);

setMap()*/
var image = 'http://i47.tinypic.com/11wg1o0.png'
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(41.810033, -87.8500523),
icon : image,
draggable: true


});
    var marker2 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(41.850033, -87.6500523),
draggable: true


});

var pointA = marker;
var pointB = marker2;

//var jsonObj = Maps.newDirectionFinder().setOrigin(pointA).setDestination(pointB).getDirections();



//  InfoBox
var content = '<iframe width="560" height="315"        src="http://www.youtube.com/embed/v2ORAUREQUo" frameborder="0" allowfullscreen></iframe> ';

infowindow = new google.maps.InfoWindow({
content: content    
});
google.maps.event.addListener(marker, 'click', function() 
{
      infowindow.open(map, this);
    });

    // rotas de bike
    var bikeLayer = new google.maps.BicyclingLayer();
    bikeLayer.setMap(map);  


  }

</script>
</head>
<body onload="initialize()">
  <div id="map_canvas" style="width:100%; height:100%"></div>
</body>

</html>

This is the part that’s do the rote

google.maps.event.addListener(map, "click", function(evt) {
if (path.length == 0) {
  path.push(evt.latLng);
  poly = new google.maps.Polyline ({ map: map});
  poly.setPath(path);
} else {
  service.route({
    origin: path[path.length - 1],
    destination: evt.latLng,
    travelMode: google.maps.DirectionsTravelMode.DRIVING  //Pode ser Walking, Driving ou Bicycling

  }, function(result, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      path = path.concat(result.routes[0].overview_path);
      poly.setPath(path);
       }
     });
    }
  });

To finish, thats my try of put collor

var polylineOptions = {
   strokeColor:"#FF0000",
   strokeOpacity: 1, 
   strokeWeight: 2, 
   zIndex: 5
}
google.maps.event.addListener(map, "click", function(evt) {
  if (path.length == 0) {
  path.push(evt.latLng);
  poly = new google.maps.Polyline (polylineOptions)({map: map});
  poly.setPath(path);
 } else {
  service.route({
    origin: path[path.length - 1],
    destination: evt.latLng,
    travelMode: google.maps.DirectionsTravelMode.DRIVING  //Pode ser Walking, Driving ou Bicycling

  },  function(result, status) {
      if (status == google.maps.DirectionsStatus.OK) {
      path = path.concat(result.routes[0].overview_path);
      poly.setPath(path);
     }
    });
   }
 });

Whats the error ?

  • 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-06-07T14:06:14+00:00Added an answer on June 7, 2026 at 2:06 pm

    This doesn’t look like the right syntax to me:

    poly = new google.maps.Polyline (polylineOptions)({map: map});
    

    Instead I’d say either add the map attribute to your polylineOptions, or call the setMap function on the poly object.

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

Sidebar

Related Questions

First of all I am in DESPERATE need of help here PLEASE I will
I need your help. This works so far that I will get alerts when
I need help to align CSS buttons. I tried many different variations and I
I need help with some CSS styling. I've tried various options with Firebug and
I need your help. I tried to play an audio file stored in Assets
I need help finding why I'm getting a null pointer exception. I've tried going
I need help please, How do I return a matrix from a function in
I need help finding where and how to change the size and crop of
I need a help in javah and android-ndk. I tryed to generate H-file for
Need help, function getFamily() { FB.api('/me/family', function(response) { alert(JSON.stringify(response)); }); } With the above

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.