Validate a variable according to the value

0

I'm having the following problem, I'm trying to build a structure that validates when the value is < > 0, If < > of 0, it must go by setting variable by variable, when for = 0, it should close the structure and end. Here's an example of what it would look like. I will post all code for better understanding, as follows:

     <script>
  var customLabel = {
    irrigando: {
      label: 'I'
    },
    plantando: {
      label: 'P'
    }
  };

    function initMap() {
    var map = new google.maps.Map(document.getElementById('map'), {
      center: new google.maps.LatLng(-9.80300419, -36.07060969),
      center: new google.maps.LatLng(-9.807158, -36.072932),
      center: new google.maps.LatLng(-9.813279, -36.076273),

      zoom: 14,
      scaleControl: true,
      streetViewControl: true,
      style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
        mapTypeIds: ['roadmap', 'terrain'],
      streetViewControlOptions: {
      position: google.maps.ControlPosition.LEFT_TOP
    },
    zoomControl: true,
    zoomControlOptions: {
    position: google.maps.ControlPosition.LEFT_TOP
},
    });
    var infoWindow = new google.maps.InfoWindow;
    // Define the LatLng coordinates for the polygon's path.



      // Change this depending on the name of your PHP or XML file
      downloadUrl('emitixml.php', function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName('marker');
        Array.prototype.forEach.call(markers, function(markerElem) {
          var name = markerElem.getAttribute('name');
          var address = markerElem.getAttribute('address');
          var situacao = markerElem.getAttribute('situacao');
          var type = markerElem.getAttribute('type');
          var cor = markerElem.getAttribute('cor');
          var marcadores1 = parseFloat(markerElem.getAttribute('lat1'));
          var marcadores2 = parseFloat(markerElem.getAttribute('lng1'));
          var marcadores3 = parseFloat(markerElem.getAttribute('lat2'));
          var marcadores4 = parseFloat(markerElem.getAttribute('lng2'));
          var marcadores5 = parseFloat(markerElem.getAttribute('lat3'));
          var marcadores6 = parseFloat(markerElem.getAttribute('lng3'));
          var marcadores7 = parseFloat(markerElem.getAttribute('lat4'));
          var marcadores8 = parseFloat(markerElem.getAttribute('lng4'));
          var marcadores9 = parseFloat(markerElem.getAttribute('lat5'));
          var marcadores10 = parseFloat(markerElem.getAttribute('lng5'));
          var marcadores11 = parseFloat(markerElem.getAttribute('lat6'));
          var marcadores12 = parseFloat(markerElem.getAttribute('lng6'));
          var point = new google.maps.LatLng(
              parseFloat(markerElem.getAttribute('lat')),
              parseFloat(markerElem.getAttribute('lng')));


      var triangleCoords = [ <> 0 ? {lat: marcadores1, lng: marcadores2},
                             <> 0 ? {lat: marcadores3, lng: marcadores4},
                             <> 0 ? {lat: marcadores5, lng: marcadores6},
                             <> 0 ? {lat: marcadores7, lng: marcadores8},
                             <> 0 ? {lat: marcadores9, lng: marcadores10},
                             <> 0 ? {lat: marcadores11, lng: marcadores12},

                           ];

           var bermudaTriangle = new google.maps.Polygon({
           paths: triangleCoords, 
           strokeColor: cor,
           strokeOpacity: 0.8,
           strokeWeight: 2,
           fillColor: cor,
           fillOpacity: 0.35
           }); 

            bermudaTriangle.setMap(map);



          var infowincontent = document.createElement('div');
          var strong = document.createElement('strong');
          strong.textContent = name
          infowincontent.appendChild(strong);
          infowincontent.appendChild(document.createElement('br'));

          var text = document.createElement('text');
          text.textContent =  address
          infowincontent.appendChild(text);

          var text = document.createElement('text');
          text.textContent =  situacao
          infowincontent.appendChild(text);

          var icon = customLabel[type] || {};
          var marker = new google.maps.Marker({
            map: map,
            position: point,
            label: icon.label
          });

          marker.addListener('click', function() {
            infoWindow.setContent(infowincontent);
            infoWindow.open(map, marker);
          });
        });
      });

    }



  function downloadUrl(url, callback) {
    var request = window.ActiveXObject ?
        new ActiveXObject('Microsoft.XMLHTTP') :
        new XMLHttpRequest;

    request.onreadystatechange = function() {
      if (request.readyState == 4) {
        request.onreadystatechange = doNothing;
        callback(request, request.status);
      }
    };

    request.open('GET', url, true);
    request.send(null);
  }

  function doNothing() {}
</script>
    
asked by anonymous 15.06.2017 / 17:15

0 answers