allenhwkim / angularjs-google-maps

The Simplest AngularJS Google Maps V3 Directive
http://ngmap.github.io
MIT License
1.52k stars 516 forks source link

Add options to DirectionsRenderer #834

Closed igler closed 7 years ago

igler commented 7 years ago

I'd like to add options to DirectionsRenderer through an attribute in directions-element. I thought maybe as an object that is passed to the DirectionsRenderer:

In markup:

<directions ... renderer-options="'{routeIndex: 1}'"...>

In code:

var showDirections = function(request) {
    directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            $timeout(function() {
                renderer.setDirections(response);
                renderer.setOptions(rendererOptions);
                ...

The routeIndex is stored in an entity when the user clicks through the different routes. Is that possible?

allenhwkim commented 7 years ago

This approach is little different from the original design, getting options from attribute individually. Please try it with route-index or options.

igler commented 7 years ago

Have tried both but they don't make it into the options variable in updateRoute-function (line 740) where I could pick them up.

igler commented 7 years ago

Have found another solution which does not require any changes on ngMap-code.