Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. var DragZoom = new ol.interaction.DragZoom({
  2. condition: ol.events.condition.always
  3. });
  4.  
  5. Load Feature on map (we have many:
  6. $.ajax({
  7. url: '/Map/GetPolygonsByQuadrante/',
  8. beforeSend: Processando("Obtendo dados..."),
  9. data: JSON.stringify({
  10. MinLat: MinLat1,
  11. MinLong: MinLong1,
  12. MaxLat: MaxLat1,
  13. MaxLong: MaxLong1,
  14. NivelZoom: NivZoom
  15. }),
  16. cache: false,
  17. async: true,
  18. type: "POST",
  19. dataType: "json",
  20. contentType: "application/json; charset=utf-8",
  21. success: function (dataFromServer) {
  22. ClearLayerFromMap(VectorPolygon);
  23. MessLbl("lblMessage", "Ok!");
  24. try {
  25. var estilo;
  26. Polygons = new Array(dataFromServer.length);
  27. // Loop over each object
  28. for (var $i = 0; $i < dataFromServer.length; $i++) {
  29. var ativo = GetVisibleByLayer(dataFromServer[$i].Tipo);
  30. if (ativo === true) {
  31. var object = dataFromServer[$i];
  32. //verifica se o o layer existe
  33. //adiciona a linha num array do mapara para posterior identificação
  34. var pol = {
  35. Id: object.Id,
  36. Tipo: object.Tipo,
  37. Pontos: object.Pontos
  38. };
  39. Polygons[$i] = pol;
  40. var coordinates = null;
  41. coordinates = [object.Pontos.length + 1]; //tem que voltar ao polygono noi ponto inicial
  42. for (var $t = 0; $t < object.Pontos.length; $t++) {
  43. coordinates[$t] = [object.Pontos[$t].Longitude, object.Pontos[$t].Latitude];
  44. }
  45. coordinates[length - 1] = [object.Pontos[0].Longitude, object.Pontos[0].Latitude];
  46. estilo = GetStyleByLayer(object.Tipo);
  47. var init = 'pol-';
  48. DrawPolygon(init + object.Id, estilo, coordinates, SourcePolygon);
  49. }
  50. }
  51. ProcessandoClose();
  52. MessLbl("lblMessage", "Tot. polígonos: " + dataFromServer.length.toLocaleString('pt-BR'));
  53. ProcessandoClose();
  54. AtualizandoMapa = false;
  55. map.render();
  56. } catch (e) {
  57. MessLbl("lblMessage", "...");
  58. ProcessandoClose();
  59. TrataErro(e);
  60. }
  61. },
  62. error: function (json) {
  63. if (json !== undefined > 0 && json.responseText === "secao_invalida") {
  64. window.location.href = "/Home/";
  65. } else {
  66. MessLbl("lblMessage", "...");
  67. ProcessandoClose();
  68. }
  69. }
  70. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement