function centerPlot(selectedPlot) {
    fetch('../api/v1.0/plots').then(function (plots) {
        return plots.json();
    }).then(function (plotsJson) {
        let rightPlot = {};
        data.forEach((plot) => {
            // Comparamos el id recibido de la tabla con el de cada parcela recibida del fetch y lo devolvemos a la siguiente funcion
            if (plot.id == selectedPlot) {
                rightPlot = plot;
            }
        });
        let lati = parseFloat(rightPlot.latitude);
        let long = parseFloat(rightPlot.longitude);

        // New map settings (centered around the field)
        let options = {
            zoom: 18,
            tilt: 0,
            center: {
                lat: lati,
                lng: long
            },
            mapTypeId: 'satellite',
            styles: [
                // Hide museums, monuments, etc.
                {
                    featureType: 'poi',
                    stylers: [{
                        visibility: "off"
                    }]
                },

                // Hide stations, bus stops, etc.
                {
                    featureType: 'transit',
                    stylers: [{
                        visibility: "off"
                    }]
                }
            ],
            rotateControl: false,
            mapTypeControl: false,
            fullscreenControl: false,
            streetViewControl: false
        };

        // Apply new settings to the map
        let map = new google.maps.Map(document.getElementById('map'), options);

        // Draw probes markers
        showPositions(rightPlot, map);

        // Draw field polygons
        drawTerrain(map, rightPlot.id);

    });
}
// It updates the map by centering it around the selected field(plot).

It updates the map by centering it around the selected field(plot).
It updates the map by centering it around the selected field ( plot ) .
function centerPlot(selectedPlot) {
    fetch('../api/v1.0/plots').then(function (plots) {
        return plots.json();
    }).then(function (plotsJson) {
        let rightPlot = {};
        data.forEach((plot) => {
            if (plot.id == selectedPlot) {
                rightPlot = plot;
            }
        });
        let lati = parseFloat(rightPlot.latitude);
        let long = parseFloat(rightPlot.longitude);
        let options = {
            zoom: 18,
            tilt: 0,
            center: {
                lat: lati,
                lng: long
            },
            mapTypeId: 'satellite',
            styles: [
                {
                    featureType: 'poi',
                    stylers: [{
                        visibility: "off"
                    }]
                },
                {
                    featureType: 'transit',
                    stylers: [{
                        visibility: "off"
                    }]
                }
            ],
            rotateControl: false,
            mapTypeControl: false,
            fullscreenControl: false,
            streetViewControl: false
        };
        let map = new google.maps.Map(document.getElementById('map'), options);
        showPositions(rightPlot, map);
        drawTerrain(map, rightPlot.id);
    });
}
function centerPlot ( selectedPlot ) { fetch ( '../api/v1.0/plots' ) . then ( function ( plots ) { return plots . json ( ) ; } ) . then ( function ( plotsJson ) { let rightPlot = { } ; data . forEach ( ( plot ) => { if ( plot . id == selectedPlot ) { rightPlot = plot ; } } ) ; let lati = parseFloat ( rightPlot . latitude ) ; let long = parseFloat ( rightPlot . longitude ) ; let options = { zoom : 18 , tilt : 0 , center : { lat : lati , lng : long } , mapTypeId : 'satellite' , styles : [ { featureType : 'poi' , stylers : [ { visibility : "off" } ] } , { featureType : 'transit' , stylers : [ { visibility : "off" } ] } ] , rotateControl : false , mapTypeControl : false , fullscreenControl : false , streetViewControl : false } ; let map = new google . maps . Map ( document . getElementById ( 'map' ) , options ) ; showPositions ( rightPlot , map ) ; drawTerrain ( map , rightPlot . id ) ; } ) ; }
It updates the map by centering it around the selected field(plot).
It updates the map by centering it around the selected field ( plot ) .
// Comparamos el id recibido de la tabla con el de cada parcela recibida del fetch y lo devolvemos a la siguiente funcion
 // New map settings (centered around the field)
 // Hide museums, monuments, etc.
 // Hide stations, bus stops, etc.
 // Apply new settings to the map
 // Draw probes markers
 // Draw field polygons
