angularjs - Ng-Maps change route color of direction renderer -
i trying change blue route other color, unable change it.
plunker url: http://plnkr.co/edit/3dduoux7r91ljqqkp43e?p=preview
angular.module('ngmap').run(function($rootscope, ngmap) { $rootscope.loglatlng = function(e) { console.log('loc', e.latlng); } ngmap.getmap({id: 'locomotivemap'}).then(function(map) { var directionsdisplay = new google.maps.directionsrenderer; var polyline = new google.maps.polyline({ strokecolor: '#ff0000', strokeopacity: 0.7, strokeweight: 1 }); directionsdisplay.setoptions({polylineoptions: polyline}); directionsdisplay.setmap(map); console.log(directionsdisplay); }); $rootscope.waypoints = [ { location: { lat: 51.546550, lng: 0.026345 }, stopover: true }, { location: { lat: 51.5429188223739, lng: 0.034160614013671875 }, stopover: true }, { location: { lat: 51.5493953, lng: 0.0412878 }, stopover: true } ]; });
html:
<body ng-app="ngmap"> <div style="width: 100%; float:left; height: 100%"> <ng-map id="locomotivemap" zoom="14" style="height:90%"> <marker animation="animation.drop" position="51.546550, 0.026345" ></marker> <marker animation="animation.drop" position="51.5493953, 0.0412878"></marker> <directions draggable="true" waypoints="{{waypoints}}" suppress-markers="true" origin="51.546550, 0.026345" destination="51.5493953, 0.0412878" > </directions> </ng-map> </div> </body>
to specify color of line polylineoptions
property of directionsrendereroptions struct
intended.
in case of ng-map
library specified via polyline-options
attribute of directions
directive:
<directions polyline-options='{strokecolor: "red"}' draggable="true" waypoints="{{waypoints}}" suppress-markers="true" origin="51.546550, 0.026345" destination="51.5493953, 0.0412878"></directions>
example
angular.module('ngmap').run(function ($rootscope, ngmap) { $rootscope.loglatlng = function (e) { console.log('loc', e.latlng); } initmapdetails(); $rootscope.waypoints = [ { location: { lat: 51.546550, lng: 0.026345 }, stopover: true }, { location: { lat: 51.5429188223739, lng: 0.034160614013671875 }, stopover: true }, { location: { lat: 51.5493953, lng: 0.0412878 }, stopover: true } ]; function initmapdetails() { ngmap.getmap({ id: 'locomotivemap' }).then(function (map) { google.maps.event.addlistener(map, "tilesloaded", function () { }); }); } });
<script src="https://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places"></script> <script src="https://code.angularjs.org/1.3.15/angular.js"></script> <script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script> <div ng-app="ngmap" style="width: 100%; float:left; height: 100%"> <ng-map id="locomotivemap" zoom="14" style="height:90%"> <marker animation="animation.drop" position="51.546550, 0.026345"></marker> <marker animation="animation.drop" position="51.5493953, 0.0412878"></marker> <directions polyline-options='{strokecolor: "red"}' draggable="true" waypoints="{{waypoints}}" suppress-markers="true" origin="51.546550, 0.026345" destination="51.5493953, 0.0412878"> </directions> </ng-map> </div>
Comments
Post a Comment