haki
haki

Reputation: 9779

How to draw a path as a straight line in google maps?

I'm using polyline to draw a path on a map using google maps v3 api. This is my code :

var polyline = new google.maps.Polyline({
          path: path,
          strokeColor: color,
          strokeOpacity: 10,
          strokeWeight: 1,
          editable: true              
        });
polyline.setMap(map);   

This is a partial outcome

enter image description here

I'm trying to draw this path without the circles on it - I want just a regular straight line. If it's possible, I would like to control it's thickness.

EDIT : It's the editable : true that makes the line appear with circles.

Upvotes: 0

Views: 2814

Answers (1)

loxxy
loxxy

Reputation: 13151

Isn't straight what is given in the official docs, as well?

Still, Here is a fiddle for you to play with.

var mapOptions = { zoom: 2, center: new google.maps.LatLng(0, 60) };
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var path = [
new google.maps.LatLng(10,20),
new google.maps.LatLng(0,40),
new google.maps.LatLng(50,60)];
var pathOptions = { path: path, strokeColor: "red", strokeWeight: 2 }
var myPath = new google.maps.Polyline(pathOptions);
myPath.setMap(map);

Upvotes: 1

Related Questions