Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. function showTrack() {
  2. var iconFeatures=[];
  3. var num = $('#tracker-grid').datagrid('getData').total;
  4.  
  5. for(var i=0; i<num; i++){
  6. var lon=$('#tracker-grid').datagrid('getRows')[i].longitude;
  7. var lat=$('#tracker-grid').datagrid('getRows')[i].latitude;
  8. var coord = ol.proj.fromLonLat([lon, lat]);
  9. var iconFeature = new ol.Feature({
  10. geometry: new ol.geom.Point(coord)
  11. });
  12. iconFeatures.push(iconFeature);
  13. }
  14.  
  15. var vectorSource = new ol.source.Vector({
  16. features: iconFeatures //add an array of features
  17. });
  18.  
  19. var iconStyle = new ol.style.Style({
  20.  
  21. image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
  22. scale: 0.5,
  23. anchor: [0.5, 46],
  24. anchorXUnits: 'fraction',
  25. anchorYUnits: 'pixels',
  26. opacity: 0.75,
  27. src: 'img/pin-blue.png'
  28. }))
  29. });
  30.  
  31. var vectorLayerLoc = new ol.layer.Vector({
  32. source: vectorSource,
  33. style: iconStyle
  34. });
  35.  
  36. map.addLayer(vectorLayerLoc);
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement