Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. function ActualMarker1(){
  2. rIcon = L.icon({
  3. iconUrl: "marcadores/marker-icon-violet.png",
  4. })
  5. for ( var i=0; i < markers.length; ++i ){
  6. L.marker( [markers[0].lat, markers[0].lng], {icon: rIcon} )
  7. .bindPopup( 'Evasión Control' ).addTo( cities );
  8. }
  9. }
  10.  
  11. function ActualMarker2(){
  12. rIcon = L.icon({
  13. iconUrl: "marcadores/marker-icon-green.png",
  14. })
  15. for ( var i=0; i < markers.length; ++i ){
  16. L.marker( [markers[0].lat, markers[0].lng], {icon: rIcon} )
  17. .bindPopup( 'Emisiones Diesel' ).addTo( cities );
  18. }
  19. }
  20.  
  21. function ActualMarker3(){
  22. rIcon = L.icon({
  23. iconUrl: "marcadores/marker-icon-yellow.png",
  24. })
  25. for ( var i=0; i < markers.length; ++i ){
  26. L.marker( [markers[0].lat, markers[0].lng], {icon: rIcon} )
  27. .bindPopup( 'Control Taximetros' ).addTo( cities );
  28. }
  29. }
  30.  
  31. function ActualMarker4(){
  32. rIcon = L.icon({
  33. iconUrl: "marcadores/marker-icon-violet.png",
  34. })
  35. for ( var i=0; i < markers.length; ++i ){
  36. L.marker( [markers[1].lat, markers[1].lng], {icon: rIcon} )
  37. .bindPopup( 'Evasión Control' ).addTo( cities );
  38. }
  39. }
  40.  
  41. function ActualMarker5(){
  42. rIcon = L.icon({
  43. iconUrl: "marcadores/marker-icon-green.png",
  44. })
  45. for ( var i=0; i < markers.length; ++i ){
  46. L.marker( [markers[1].lat, markers[1].lng], {icon: rIcon} )
  47. .bindPopup( 'Emisiones Diesel' ).addTo( cities );
  48. }
  49. }
  50.  
  51. function ActualMarker6(){
  52. rIcon = L.icon({
  53. iconUrl: "marcadores/marker-icon-yellow.png",
  54. })
  55. for ( var i=0; i < markers.length; ++i ){
  56. L.marker( [markers[1].lat, markers[1].lng], {icon: rIcon} )
  57. .bindPopup( 'Control Taximetros' ).addTo( cities );
  58. }
  59. }
  60.  
  61. function ActualMarker7(){
  62. rIcon = L.icon({
  63. iconUrl: "marcadores/marker-icon-violet.png",
  64. })
  65. for ( var i=0; i < markers.length; ++i ){
  66. L.marker( [markers[2].lat, markers[2].lng], {icon: rIcon} )
  67. .bindPopup( 'Evasión Control' ).addTo( cities );
  68. }
  69. }
  70.  
  71. function ActualMarker8(){
  72. rIcon = L.icon({
  73. iconUrl: "marcadores/marker-icon-green.png",
  74. })
  75. for ( var i=0; i < markers.length; ++i ){
  76. L.marker( [markers[2].lat, markers[2].lng], {icon: rIcon} )
  77. .bindPopup( 'Emisiones Diesel' ).addTo( cities );
  78. }
  79. }
  80.  
  81. function ActualMarker9(){
  82. rIcon = L.icon({
  83. iconUrl: "marcadores/marker-icon-yellow.png",
  84. })
  85. for ( var i=0; i < markers.length; ++i ){
  86. L.marker( [markers[2].lat, markers[2].lng], {icon: rIcon} )
  87. .bindPopup( 'Control Taximetros' ).addTo( cities );
  88. }
  89. }
  90.  
  91. <?php
  92. for($i=0; $i<count($f_result); $i++){
  93.  
  94. if($f_result[0]->ot == 95)
  95. {
  96. echo "<script>";
  97. echo "ActualMarker1();";
  98. echo "</script>";
  99. }elseif($f_result[0]->ot == 98)
  100. {
  101. echo "<script>";
  102. echo "ActualMarker2();";
  103. echo "</script>";
  104. }elseif($f_result[0]->ot == 102)
  105. {
  106. echo "<script>";
  107. echo "ActualMarker3();";
  108. echo "</script>";
  109. }
  110. if($f_result[1]->ot == 95)
  111.  
  112. {
  113. echo "<script>";
  114. echo "ActualMarker4();";
  115. echo "</script>";
  116. }elseif($f_result[1]->ot == 98)
  117. {
  118. echo "<script>";
  119. echo "ActualMarker5();";
  120. echo "</script>";
  121. }elseif($f_result[1]->ot == 102)
  122. {
  123. echo "<script>";
  124. echo "ActualMarker6();";
  125. echo "</script>";
  126. }
  127. if($f_result[2]->ot == 95)
  128. {
  129. echo "<script>";
  130. echo "ActualMarker7();";
  131. echo "</script>";
  132. }elseif($f_result[2]->ot == 98)
  133. {
  134. echo "<script>";
  135. echo "ActualMarker8();";
  136. echo "</script>";
  137. }elseif($f_result[2]->ot == 102)
  138. {
  139. echo "<script>";
  140. echo "ActualMarker9();";
  141. echo "</script>";
  142. }else{
  143. echo "esto no esta funcionando bien";
  144. }
  145.  
  146. }
  147.  
  148. ?>
  149.  
  150. const valores = [
  151. {
  152. iconUrl: "marcadores/marker-icon-violet.png",
  153. markerIndex: 0,
  154. texto: 'Evasión Control'
  155. },
  156. {
  157. iconUrl: "marcadores/marker-icon-green.png",
  158. markerIndex: 0,
  159. texto: 'Emisiones Diesel'
  160. },
  161. ...
  162.  
  163. function ActualMarker(indice) {
  164. const iconUrls = [ "marcadores/marker-icon-violet.png", "marcadores/marker-icon-green.png", "marcadores/marker-icon-yellow.png" ];
  165. const textos = ['Evasión Control', 'Emisiones Diesel', 'Control Taximetros'];
  166.  
  167. const iconUrl = iconUrls[ (indice-1) % 3 ];
  168. const texto = textos[ (indice-1) % 3 ];
  169. const markerIndex = Math.floor( indice / 3 );
  170.  
  171. rIcon = L.icon({ iconUrl: iconUrl })
  172. for (var i = 0; i < markers.length; ++i) {
  173. L.marker([markers[ markerIndex ].lat, markers[ markerIndex ].lng], {
  174. icon: rIcon
  175. })
  176. .bindPopup( texto ).addTo(cities);
  177. }
  178. }
  179.  
  180. // no usas $i en ningún lugar del bucle, ¿seguro que es correcto?
  181. for($i=0; $i<count($f_result); $i++){
  182.  
  183. switch ($f_result[0]) {
  184. case 95: echo '<script>ActualMarker(1)</script>'; break;
  185. case 98: echo '<script>ActualMarker(2)</script>'; break;
  186. case 102: echo '<script>ActualMarker(3)</script>'; break;
  187. }
  188. switch ($f_result[1]) {
  189. case 95: echo '<script>ActualMarker(4)</script>'; break;
  190. case 98: echo '<script>ActualMarker(5)</script>'; break;
  191. case 102: echo '<script>ActualMarker(6)</script>'; break;
  192. }
  193. switch ($f_result[2]) {
  194. case 95: echo '<script>ActualMarker(7)</script>'; break;
  195. case 98: echo '<script>ActualMarker(8)</script>'; break;
  196. case 102: echo '<script>ActualMarker(9)</script>'; break;
  197. default: echo "esto no esta funcionando bien"; break;
  198. }
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement