Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$scope.path not working when click #1176

Open
pleasezoomout opened this issue Aug 2, 2017 · 0 comments
Open

$scope.path not working when click #1176

pleasezoomout opened this issue Aug 2, 2017 · 0 comments

Comments

@pleasezoomout
Copy link

I'm trying to make the path change when I click a btn but, it doesn't work .

I tried the paths-ajax-load-example but could't make it work.

html code

<leaflet paths="path" defaults="defaults" width="100%" height="100%" markers="markers" center="center"></leaflet>

<body ng-controller="HomeCtrl"> 
    <nav id="search">
        <form ng-submit="getPath()" class="form-inline pull-xs-right">
            <input class="form" type="text" ng-model="origin" name="origin" placeholder="Origin">
            </br>
            <input class="form" type="text" ng-model="destination" name="destination" placeholder="Destination">
            </br>
            <button type="submit" class="btn btn-default">Find path</button>
        </form>
    </nav>
</body>

Angular controller

angular.module('demoapp')

.controller("HomeCtrl", [ '$scope',  function($scope) {

    $scope.getPath = function() {

        angular.extend($scope, {

                center: {
                lat: 4.5656,
                lng: -74.09266,
                zoom: 12,
            }
        })

        $scope.path = {
                polyline: {
                    type: "polyline",
                    color: 'black',
                    weight: 5,
                    stroke: "true",
                    latlngs: [{lat: 4.5656, lng: -74.09266}, {lat: 4.56588, lng: -74.09306}]
                }
            }
        }
    } 
}]);

Any help will be appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant