Skip to content

Commit

Permalink
Merge pull request #4 from fpsampayo/featureCatastroHistorico
Browse files Browse the repository at this point in the history
Feature catastro historico
  • Loading branch information
fpsampayo authored Jul 4, 2017
2 parents 9f651c8 + bdce35b commit d73444f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
6 changes: 5 additions & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ <h4 class="panel-title">
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body" id="medidor">
Por implementar
<div id="sandbox-container">
<div class="input-group date">
<input id="fecha-catastro" type="text" class="form-control"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>
</div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"dependencies": {
"bootstrap": "^3.3.7",
"bootstrap-datepicker": "^1.7.0",
"jquery": "^3.2.1",
"leaflet": "^1.1.0",
"leaflet-measure": "^2.1.7",
Expand Down
22 changes: 21 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import 'jquery'
import 'bootstrap'
import Map from './map'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-datepicker'
import '../node_modules/bootstrap-datepicker/dist/locales/bootstrap-datepicker.es.min'
import '../node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css'
import './styles/styles.css'
import CatastroParser from './catastroParser'

Expand All @@ -16,7 +19,7 @@ const btnSidebar = document.getElementById('menu-toggle')

const btnSearch = document.getElementById('btn-search')
const imputRefCat = document.getElementById('navRefCatForm')
const navHistorico = document.getElementById('nav-historico')
const inputFechaCatastro = document.getElementById('fecha-catastro')

const sideNav = document.getElementById('mySidenav')

Expand Down Expand Up @@ -51,3 +54,20 @@ btnSidebar.addEventListener('click', (evt) => {
if (document.body.clientWidth >= 767) {
sideNav.classList.toggle('toggled')
}

$('#sandbox-container .input-group.date').datepicker({
format: "dd/mm/yyyy",
language: "es",
daysOfWeekHighlighted: "0,6",
autoclose: true,
clearBtn: true,
todayHighlight: true
}).on('changeDate', function(e) {
var dd = e.date.getDate()
var mm = e.date.getMonth() + 1
var yyyy = e.date.getFullYear()
var dateString = yyyy + '-' + mm + '-' + dd
map.catastroHistorico(dateString)
}).on('clearDate', function(e) {
map.desactivaCatastroHistorico()
})
27 changes: 19 additions & 8 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class Map {

const catastroUrl = 'https://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx?'

const catastroBase = L.nonTiledLayer.wms(
this.catastroBase = L.nonTiledLayer.wms(
catastroUrl,
{
maxZoom: MAX_ZOOM,
Expand Down Expand Up @@ -82,7 +82,7 @@ export default class Map {

const baseMaps = {
PNOA: pnoa,
Catastro: catastroBase,
Catastro: this.catastroBase,
'Google Satellite': satellite
}

Expand Down Expand Up @@ -110,15 +110,26 @@ export default class Map {
this.clearHighLight()
this.highlight.addData(geoJson)
}

catastroHistorico() {
/**
* Activa el catastro histórico para la fecha seleccionada
* @param {string} dateString - Fecha en formato yyyy-mm-dd
*/
catastroHistorico(dateString) {

this.catastroOverlay._wmsUrl = "https://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx?TIME=2017-07-01"
this.catastroOverlay.addTo(this.map)

this.catastroOverlay._wmsUrl = "https://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx?TIME=" + dateString
this.catastroBase._wmsUrl = "https://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx?TIME=" + dateString
this.catastroOverlay.redraw()
this.catastroBase.redraw()
}

console.log(this.map)
/**
* Desactiva el catastro histórico
*/
desactivaCatastroHistorico() {
this.catastroOverlay._wmsUrl = "https://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx?"
this.catastroBase._wmsUrl = "https://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx?"
this.catastroOverlay.redraw()
this.catastroBase.redraw()
}
}

0 comments on commit d73444f

Please sign in to comment.