Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var DragZoom = new ol.interaction.DragZoom({
- condition: ol.events.condition.always
- });
- Load Feature on map (we have many:
- $.ajax({
- url: '/Map/GetPolygonsByQuadrante/',
- beforeSend: Processando("Obtendo dados..."),
- data: JSON.stringify({
- MinLat: MinLat1,
- MinLong: MinLong1,
- MaxLat: MaxLat1,
- MaxLong: MaxLong1,
- NivelZoom: NivZoom
- }),
- cache: false,
- async: true,
- type: "POST",
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- success: function (dataFromServer) {
- ClearLayerFromMap(VectorPolygon);
- MessLbl("lblMessage", "Ok!");
- try {
- var estilo;
- Polygons = new Array(dataFromServer.length);
- // Loop over each object
- for (var $i = 0; $i < dataFromServer.length; $i++) {
- var ativo = GetVisibleByLayer(dataFromServer[$i].Tipo);
- if (ativo === true) {
- var object = dataFromServer[$i];
- //verifica se o o layer existe
- //adiciona a linha num array do mapara para posterior identificação
- var pol = {
- Id: object.Id,
- Tipo: object.Tipo,
- Pontos: object.Pontos
- };
- Polygons[$i] = pol;
- var coordinates = null;
- coordinates = [object.Pontos.length + 1]; //tem que voltar ao polygono noi ponto inicial
- for (var $t = 0; $t < object.Pontos.length; $t++) {
- coordinates[$t] = [object.Pontos[$t].Longitude, object.Pontos[$t].Latitude];
- }
- coordinates[length - 1] = [object.Pontos[0].Longitude, object.Pontos[0].Latitude];
- estilo = GetStyleByLayer(object.Tipo);
- var init = 'pol-';
- DrawPolygon(init + object.Id, estilo, coordinates, SourcePolygon);
- }
- }
- ProcessandoClose();
- MessLbl("lblMessage", "Tot. polígonos: " + dataFromServer.length.toLocaleString('pt-BR'));
- ProcessandoClose();
- AtualizandoMapa = false;
- map.render();
- } catch (e) {
- MessLbl("lblMessage", "...");
- ProcessandoClose();
- TrataErro(e);
- }
- },
- error: function (json) {
- if (json !== undefined > 0 && json.responseText === "secao_invalida") {
- window.location.href = "/Home/";
- } else {
- MessLbl("lblMessage", "...");
- ProcessandoClose();
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement