javascript - Google Maps API custom marker animation and orientation along path -


i trying create google map app shows route source destination in straight line ('as crow flies'). have general app working. can put in start , end destination , draw line start finish. also, have generic marker moves along straight line route start finish. want replace generic marker custom drawn marker. also, custom marker oriented in line route. in other words if custom marker car want car facing right direction goes along route.

i see demo, not sure how doing this. http://www.morethanamap.com/demos/visualization/flights

any suggestions?

thanks!

you'll need set iconsequence polyline. iconsequence requires symbol, example-svg car : https://upload.wikimedia.org/wikipedia/commons/f/f6/car.svgpypaertv)

demo:

function initialize() {        var origin = new google.maps.latlng(39.904211, 116.407394),      destination = new google.maps.latlng(40.4167754, -3.703790),      map = new google.maps.map(document.getelementbyid('map-canvas'), {        center: origin,        zoom: 3      }),      line = new google.maps.polyline({        geodesic: true,        path: [origin, origin],        icons: [{          icon: {            path: 'm 236.54427,9.8485 c 220.2445,9.8485 204.45277,15.405415 191.41289,25.550223 l 97.337229,97.995127 l -135.0706,131.12201 c -150.90459,133.65817 -161.13586,149.44963 -156.32358,165.14237 l -132.57022,244.60846 l -86.188678,244.60846 c -90.823109,289.62242 -60.00389,319.2235 -20.679452,319.2235 c 18.644986,319.2235 49.844083,285.73585 44.829779,244.60846 l 425.19586,244.60846 c 419.65783,289.49008 452.23789,319.2235 490.70508,319.2235 c 529.17227,319.2235 561.22444,285.70267 556.21433,244.60846 l 651.04018,244.60846 c 659.88863,244.60846 667.48002,236.98237 667.48,227.63005 l 667.48,137.76012 c 667.48,129.20037 661.30023,122.08284 653.22799,120.97335 l 491.76774,97.995127 l 427.82125,32.635149 c 413.84999,18.051989 394.74442,10.165524 374.56372,9.8485 l 236.54427,9.8485 z m 304.42883,37.42226 l 378.62679,37.42226 c 389.64854,37.42226 399.73373,43.261111 405.94316,52.613356 l 424.25825,80.825395 c 428.78955,88.722668 423.85522,96.409133 415.38198,97.803717 l 304.42883,97.803717 l 304.42883,37.42226 z m 224.60508,37.549916 l 283.42586,37.549916 l 283.42586,97.803717 l 132.59212,97.803717 l 200.10167,45.97523 c 207.08728,40.585799 215.91189,37.549914 224.60508,37.549916 z',            scale: .05,            fillcolor: 'blue',            fillopacity: 1,            rotation: 90,            anchor: new google.maps.point(0, 200)          },            offset: '100%'        }]      }),        pct = 0,      timer = setinterval(function() {          pct += .002;          line.setpath([origin, google.maps.geometry.spherical.interpolate(origin, destination, pct)]);        line.setmap(map);        map.setcenter(line.getpath().getat(1));        if (pct >= 1) clearinterval(timer)      }, 50);          }    google.maps.event.adddomlistener(window, 'load', initialize);
html,  body,  #map-canvas {    height: 100%;    margin: 0;    padding: 0;  }
<div id="map-canvas"></div>  <script src="https://maps.googleapis.com/maps/api/js?v=3&libraries=geometry"></script>


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -