LuisSM
LuisSM

Reputation: 57

Google Maps V3, strokeWeight Polyline scalable

I have a problem: this is my map now:

enter image description here

I have circles in the map, and I can scale them. But I have polylines too, I tried to scale them by strokeWeight but this doesn't work. I need draw a route with a personalizable width, like the circle's radius. Any idea?

google.maps.event.addListener(this.markerEdit, 'mouseup', function() {
    if(me.poly!=null){
        var Options = {strokeWeight: 2000};
        me.poly.setOptions(Options);
    }
});

Or

google.maps.event.addListener(this.markerEdit, 'mouseup', function() {
    if(me.poly!=null){
        me.poly.setStrokeWeight(2000);
    }
});

I tried the two.

Thank you

Upvotes: 2

Views: 7812

Answers (2)

katim labidi
katim labidi

Reputation: 39

I have the same problem.

This is what i made :

google.maps.event.addListener(mapRelatorioMapa , 'zoom_changed', function(){
    var zoom = mapRelatorioMapa.getZoom() * larg /17 ; 
    for(var obj in redLine)
    {
        redLine[obj].setOptions({strokeWeight: zoom});
    }
});

So I get the zoom and try to multiply it , but it doesn't work so good I think that you have to try to find the real scale for each zoom and make a table.

Upvotes: 0

Milanzor
Milanzor

Reputation: 1930

I think you're using the wrong function to change the strokeweight.

Try using

me.poly.setOptions({strokeWeight: 2000});

Check out this example fiddle: http://jsfiddle.net/cx4Gm/ It should explain everything you need.

Upvotes: 1

Related Questions