मैं ताहो बेसिन में बर्फ भार की गणना करने में सक्षम होने के लिए Google मानचित्र एपीआई और कस्टम जेस्क्रिप्ट का उपयोग कर रहा हूं।

एक काउंटी को छोड़कर यह सब अपेक्षानुसार काम करता है...एल डोराडो, जो काम नहीं करता है, और मैं इस मुद्दे को अलग करने में सक्षम नहीं हूं।

यदि आप स्निपेट लोड करते हैं (पूर्ण स्क्रीन में सर्वश्रेष्ठ) तो आप देख सकते हैं कि यह एल डोराडो काउंटी को छोड़कर झील के चारों ओर सभी काउंटी के लिए काम करता है।

नोट: त्रुटि को पुन: उत्पन्न करने के लिए: पूर्ण स्क्रीन और गोटो साउथ लेक ताहो में स्निपेट लोड करें और उस शहर पर क्लिक करें जो एल डोराडो काउंटी है और इसमें त्रुटियां हैं।

var points = {
  westPlacer: [
    {
      lat: 39.373490,
      long: -120.235205
    }, {
      lat: 39.359037,
      long: -120.235319
    }, {
      lat: 39.343940,
      long: -120.235506
    }, {
      lat: 39.329288,
      long: -120.235731
    }, {
      lat: 39.314982,
      long: -120.236251
    }, {
      lat: 39.300705,
      long: -120.236422
    }, {
      lat: 39.285794,
      long: -120.236672
    }, {
      lat: 39.271297,
      long: -120.236402
    }, {
      lat: 39.256740,
      long: -120.236290
    }, {
      lat: 39.242320,
      long: -120.236151
    }, {
      lat: 39.227314,
      long: -120.236011
    }, {
      lat: 39.213102,
      long: -120.235911
    }, {
      lat: 39.198786,
      long: -120.235766
    }, {
      lat: 39.184576,
      long: -120.236484
    }, {
      lat: 39.184575,
      long: -120.236484
    }, {
      lat: 39.184119,
      long: -120.228208
    }, {
      lat: 39.170143,
      long: -120.228036
    }, {
      lat: 39.154701,
      long: -120.190700
    }, {
      lat: 39.154700,
      long: -120.190700
    }, {
      lat: 39.140015,
      long: -120.190456
    }, {
      lat: 39.125517,
      long: -120.190547
    }, {
      lat: 39.111406,
      long: -120.190561
    }, {
      lat: 39.096556,
      long: -120.190558
    }, {
      lat: 39.082067,
      long: -120.190534
    }, {
      lat: 39.077698,
      long: -120.188443
    }, {
      lat: 39.074887,
      long: -120.187134
    }, {
      lat: 39.071210,
      long: -120.185336
    }, {
      lat: 39.067491,
      long: -120.183625
    }, {
      lat: 39.053039,
      long: -120.183695
    }, {
      lat: 39.038354,
      long: -120.183683
    },
  ],
  eastPlacer: [
    {
      lat: 39.373603,
      long: -120.216838
    }, {
      lat: 39.358984,
      long: -120.216856
    }, {
      lat: 39.344107,
      long: -120.216683
    }, {
      lat: 39.329376,
      long: -120.216833
    }, {
      lat: 39.315090,
      long: -120.217128
    }, {
      lat: 39.300554,
      long: -120.217113
    }, {
      lat: 39.285834,
      long: -120.217154
    }, {
      lat: 39.271439,
      long: -120.217729
    }, {
      lat: 39.256922,
      long: -120.217728
    }, {
      lat: 39.242498,
      long: -120.217577
    }, {
      lat: 39.227876,
      long: -120.217551
    }, {
      lat: 39.213208,
      long: -120.217543
    }, {
      lat: 39.198558,
      long: -120.217517
    }, {
      lat: 39.183976,
      long: -120.217368
    }, {
      lat: 39.183975,
      long: -120.217368
    }, {
      lat: 39.183805,
      long: -120.172043
    }, {
      lat: 39.168931,
      long: -120.171713
    }, {
      lat: 39.154654,
      long: -120.171681
    }, {
      lat: 39.154653,
      long: -120.171681
    }, {
      lat: 39.139767,
      long: -120.171765
    }, {
      lat: 39.125323,
      long: -120.171739
    }, {
      lat: 39.111128,
      long: -120.171530
    }, {
      lat: 39.096527,
      long: -120.171580
    }, {
      lat: 39.082052,
      long: -120.171833
    }, {
      lat: 39.080031,
      long: -120.170910
    }, {
      lat: 39.076672,
      long: -120.169374
    }, {
      lat: 39.072898,
      long: -120.167611
    }, {
      lat: 39.067501,
      long: -120.165205
    }, {
      lat: 39.053084,
      long: -120.164571
    }, {
      lat: 39.038447,
      long: -120.165066
    }
  ]
};

var loads = {
  westWashoe: [
    {
      elevation: 5000,
      snowload: 30
    }, {
      elevation: 5100,
      snowload: 41
    }, {
      elevation: 5200,
      snowload: 52
    }, {
      elevation: 5300,
      snowload: 64
    }, {
      elevation: 5400,
      snowload: 75
    }, {
      elevation: 5500,
      snowload: 86
    }, {
      elevation: 6000,
      snowload: 142
    }, {
      elevation: 6500,
      snowload: 171
    }, {
      elevation: 7000,
      snowload: 200
    }, {
      elevation: 7500,
      snowload: 215
    }, {
      elevation: 8000,
      snowload: 229
    }, {
      elevation: 8500,
      snowload: 243
    }, {
      elevation: 9000,
      snowload: 271
    }, {
      elevation: 9500,
      snowload: 300
    }, {
      elevation: 10000,
      snowload: 357
    }
  ],
  eastWashoe: [
    {
      elevation: 5000,
      snowload: 30
    }, {
      elevation: 5100,
      snowload: 31
    }, {
      elevation: 5200,
      snowload: 33
    }, {
      elevation: 5300,
      snowload: 34
    }, {
      elevation: 5400,
      snowload: 35
    }, {
      elevation: 5500,
      snowload: 37
    }, {
      elevation: 6000,
      snowload: 43
    }, {
      elevation: 6500,
      snowload: 43
    }, {
      elevation: 7000,
      snowload: 57
    }, {
      elevation: 7500,
      snowload: 57
    }, {
      elevation: 8000,
      snowload: 86
    }, {
      elevation: 8500,
      snowload: 86
    }, {
      elevation: 9000,
      snowload: 114
    }, {
      elevation: 9500,
      snowload: 142
    }
  ],
  basinWashoe: [
    {
      elevation: 6000,
      snowload: 220
    }, {
      elevation: 6500,
      snowload: 235
    }, {
      elevation: 7000,
      snowload: 250
    }, {
      elevation: 7500,
      snowload: 265
    }, {
      elevation: 8000,
      snowload: 280
    }, {
      elevation: 8500,
      snowload: 295
    }, {
      elevation: 9000,
      snowload: 330
    }, {
      elevation: 9500,
      snowload: 390
    }, {
      elevation: 10000,
      snowload: 420
    }
  ],
  westPlacer: [
    {
      elevation: 1000,
      snowload: 10,
      snowdensity: 20,
      snowdepth: 3.0
    }, {
      elevation: 1600,
      snowload: 20,
      snowdensity: 20,
      snowdepth: 3.0
    }, {
      elevation: 2500,
      snowload: 29,
      snowdensity: 20,
      snowdepth: 3.0
    }, {
      elevation: 3000,
      snowload: 55,
      snowdensity: 20,
      snowdepth: 3.0
    }, {
      elevation: 3500,
      snowload: 70,
      snowdensity: 20,
      snowdepth: 3.8
    }, {
      elevation: 4000,
      snowload: 100,
      snowdensity: 20,
      snowdepth: 5.0
    }, {
      elevation: 4500,
      snowload: 160,
      snowdensity: 22.7,
      snowdepth: 6.5
    }, {
      elevation: 5000,
      snowload: 200,
      snowdensity: 24.5,
      snowdepth: 8.2
    }, {
      elevation: 5500,
      snowload: 260,
      snowdensity: 26.7,
      snowdepth: 9.7
    }, {
      elevation: 6000,
      snowload: 315,
      snowdensity: 27.0,
      snowdepth: 11.7
    }, {
      elevation: 6500,
      snowload: 375,
      snowdensity: 29.6,
      snowdepth: 12.7
    }, {
      elevation: 7000,
      snowload: 430,
      snowdensity: 30.1,
      snowdepth: 14.3
    }, {
      elevation: 7500,
      snowload: 490,
      snowdensity: 30.6,
      snowdepth: 16.0
    }, {
      elevation: 7501,
      snowload: 545,
      snowdensity: 32.4,
      snowdepth: 16.8
    }
  ],
  eastPlacer: [
    {
      elevation: 5500,
      snowload: 130,
      snowdensity: 23.6,
      snowdepth: 5.5
    }, {
      elevation: 6000,
      snowload: 190,
      snowdensity: 23.8,
      snowdepth: 7.9
    }, {
      elevation: 6500,
      snowload: 245,
      snowdensity: 24.5,
      snowdepth: 10.0
    }, {
      elevation: 7000,
      snowload: 300,
      snowdensity: 25.0,
      snowdepth: 12.0
    }, {
      elevation: 7500,
      snowload: 360,
      snowdensity: 25.2,
      snowdepth: 14.3
    }, {
      elevation: 8000,
      snowload: 400,
      snowdensity: 25.5,
      snowdepth: 15.7
    }, {
      elevation: 8001,
      snowload: 445,
      snowdensity: 25.7,
      snowdepth: 17.3
    }
  ],
  westElDorado: [
    {
      elevation: 2000,
      snowload: 20
    }, {
      elevation: 2500,
      snowload: 32
    }, {
      elevation: 3000,
      snowload: 45
    }, {
      elevation: 3500,
      snowload: 56
    }, {
      elevation: 4000,
      snowload: 68
    }, {
      elevation: 4500,
      snowload: 80
    }, {
      elevation: 5000,
      snowload: 90
    }, {
      elevation: 5500,
      snowload: 100
    }, {
      elevation: 6000,
      snowload: 110
    }, {
      elevation: 6500,
      snowload: 120
    }, {
      elevation: 7000,
      snowload: 128
    }, {
      elevation: 7500,
      snowload: 135
    }
  ],
  basinElDorado: [
    {
      elevation: 6000,
      snowload: 145
    }, {
      elevation: 6500,
      snowload: 160
    }, {
      elevation: 7000,
      snowload: 170
    }, {
      elevation: 7500,
      snowload: 180
    }
  ]
};

var countyCalculations = {
  Washoe_County: function(latLng, elevation) {
    var eastInfo = getSnowInfoForRegion("eastWashoe", elevation);
    var westInfo = getSnowInfoForRegion("westWashoe", elevation);
    var basinInfo = getSnowInfoForRegion("basinWashoe", elevation);

    return {
      county: "Washoe",
      snowload: "<br/>- if east of 395: " + round(eastInfo.snowload, 2) + " psf<br/>- if west of 395: " + round(westInfo.snowload, 2) + " psf<br/>- if in Tahoe Basin: " + round(basinInfo.snowload, 2) + " psf",
      //snowdensity: "<br/>- if east of 395: " + round(eastInfo.snowdensity, 2) + " pcf<br/>- if west of 395: " + round(westInfo.snowdensity, 2) + " pcf<br/>- if in Tahoe Basin: " + round(basinInfo.snowdensity, 2) + " pcf",
      //snowdepth: "<br/>- if east of 395: " + round(eastInfo.snowdepth, 2) + " feet<br/>- if west of 395: " + round(westInfo.snowdepth, 2) + " feet<br/>- if in Tahoe Basin: " + round(basinInfo.snowdepth, 2) + " feet"
    };
  },

  Placer_County: function(latLng, elevation) {
    // get closest basin border reference points
    var eastReferencePoint = getNearestPointForRegionByLatitude("eastPlacer", latLng.lat());
    var westReferencePoint = getNearestPointForRegionByLatitude("westPlacer", latLng.lat());

    // is the longitude east of or in the basin
    var eastSnowInfo;
    if(latLng.lng() > westReferencePoint.long)
      eastSnowInfo = getSnowInfoForRegion("eastPlacer", elevation);

    // is the longitude west of or in the basin
    var westSnowInfo;
    if(latLng.lng() < eastReferencePoint.long)
      westSnowInfo = getSnowInfoForRegion("westPlacer", elevation);

    var snowload;
    var snowdensity;
    var snowdepth;

    // east AND not west snowloads calculated (longitude is east of the basin)
    if(eastSnowInfo && !westSnowInfo) {
      snowload = eastSnowInfo.snowload;
      snowdensity = eastSnowInfo.snowdensity;
      snowdepth = eastSnowInfo.snowdepth;
    }

    // west AND now east snowloads calculated (longitude is west of the basin)
    if(!eastSnowInfo && westSnowInfo) {
      snowload = westSnowInfo.snowload;
      snowdensity = westSnowInfo.snowdensity;
      snowdepth = westSnowInfo.snowdepth;
    }

    // were the east AND west snowloads calculated (longitude is in the basin)
    if(eastSnowInfo && westSnowInfo) {
      snowload = interpolate(latLng.lng(), westReferencePoint.long, eastReferencePoint.long, westSnowInfo.snowload, eastSnowInfo.snowload);
      snowdensity = interpolate(latLng.lng(), westReferencePoint.long, eastReferencePoint.long, westSnowInfo.snowdensity, eastSnowInfo.snowdensity);
      snowdepth = interpolate(latLng.lng(), westReferencePoint.long, eastReferencePoint.long, westSnowInfo.snowdepth, eastSnowInfo.snowdepth);
    }

    return {
      county: "Placer",
      snowload: round(snowload, 2) + " psf",
      snowdensity: round(snowdensity, 2) + " pcf",
      snowdepth: round(snowdepth, 2) + " feet"
    };
  },

  Nevada_County: function(latLng, elevation) {
    // Truckee uses Placer county algorithm
    var info = countyCalculations.Placer_County(latLng, elevation);
    info.county = "Nevada (Truckee only)";
    return info;
  },

  El_Dorado_County: function(latLng, elevation) {
    var westInfo = getSnowInfoForRegion("westElDorado", elevation);
    var basinInfo = getSnowInfoForRegion("basinElDorado", elevation);

    return {
      county: "El Dorado",
      snowload: "<br/>- if on West Slope: " + round(westInfo.snowload, 2) + " psf<br/>- if in Tahoe Basin: " + round(basinInfo.snowload, 2) + " psf",
      //snowdensity: "<br/>- if on West Slope: " + round(westInfo.snowdensity, 2) + " pcf<br/>- if in Tahoe Basin: " + round(basinInfo.snowdensity, 2) + " pcf",
      //snowdepth: "<br/>- if on West Slope: " + round(westInfo.snowdepth, 2) + " feet<br/>- if in Tahoe Basin: " + round(basinInfo.snowdepth, 2) + " feet"
    };
  },

  Douglas_County: function(latLng, elevation) {
    return {
      county: "Douglas",
      snowload: (elevation <= 6000 ? 30 : 150) + " psf"
    };
  }
};

calculateSnowInfo = function(input, elevationOverride, success, error) {
  var geocoderService = new google.maps.Geocoder();
  geocoderService.geocode(input, function(results, status) {
    if(status != google.maps.GeocoderStatus.OK)
      error("Failed to translate address to coordinates via Google: " + status);
    else {
      var location = (input.latLng ? input.latLng : results[0].geometry.location);
      var formattedAddress = results[0].formatted_address;
      var county;
      var city;

      var result = results[0];
      for(componentIndex in result.address_components) {
        var component = result.address_components[componentIndex];
        for(typeIndex in component.types) {
          if(component.types[typeIndex] == "locality")
            city = component.long_name;
          if(component.types[typeIndex] == "administrative_area_level_2")
            county = component.long_name;
        }
      }

      var countyCalculate;
      if(!county) {
        error("Unable to determine county from address");
        return;
      }

      county = county.replace(" ", "_");

      if(countyCalculations[county]) {
        if(county == "Nevada" && city != "Truckee") {
          error("The address provided appears to be in Nevada county outside the limits of Truckee.  Only Truckee addresses are supported for this county.");
          return;
        }
        countyCalculate = countyCalculations[county];
      } else {
        error("The address provided appears to be in " + county + " county (only Placer, Washoe, Nevada, El Dorado, and Douglas counties are supported)");
        return;
      }

      if(elevationOverride) {
        var info = countyCalculate(location, elevationOverride);
        info.location = location;
        info.formattedAddress = formattedAddress;
        info.elevation = elevation + " feet (overriden)";
        success(info);
      } else {
        var elevationService = new google.maps.ElevationService();
        elevationService.getElevationForLocations({
          locations: [location]
        }, function(results, status) {
          if(status != google.maps.ElevationStatus.OK)
            error("Failed to get elevation data from Google: " + status);
          else {
            elevation = Math.round(results[0].elevation * 3.2808399);

            var info = countyCalculate(location, elevation);
            info.location = location;
            info.formattedAddress = formattedAddress;
            info.elevation = elevation + " feet";
            success(info);
          }
        });
      }
    }
  });
}

getNearestPointForRegionByLatitude = function(region, latitude) {
  var pointsRegion = points[region];

  var bestPoint;
  var bestDelta;

  for(pointIndex in pointsRegion) {
    point = pointsRegion[pointIndex];
    delta = Math.abs(point.lat - latitude);
    if(!bestPoint || delta < bestDelta) {
      bestDelta = delta;
      bestPoint = point;
    }
  }

  return bestPoint;
}

getSnowInfoForRegion = function(region, elevation) {
  var loadsRegion = loads[region];

  var lowerLoadInfo = loadsRegion[0];
  for(loadInfoIndex in loadsRegion) {
    loadInfo = loadsRegion[loadInfoIndex];
    if(loadInfo.elevation > elevation)
      break;
    lowerLoadInfo = loadInfo;
  }

  var upperLoadInfo = loadsRegion[loadsRegion.length - 1];
  for(loadInfoIndex in loadsRegion) {
    loadInfo = loadsRegion[loadInfoIndex];
    if(loadInfo.elevation >= elevation) {
      upperLoadInfo = loadInfo;
      break;
    }
  }

  var results = {};
  if(lowerLoadInfo.elevation == upperLoadInfo.elevation)
    return {
      snowload: lowerLoadInfo.snowload,
      snowdensity: lowerLoadInfo.snowdensity,
      snowdepth: lowerLoadInfo.snowdepth
    };
  else
    return {
      snowload: interpolate(elevation, lowerLoadInfo.elevation, upperLoadInfo.elevation, lowerLoadInfo.snowload, upperLoadInfo.snowload),
      snowdensity: interpolate(elevation, lowerLoadInfo.elevation, upperLoadInfo.elevation, lowerLoadInfo.snowdensity, upperLoadInfo.snowdensity),
      snowdepth: interpolate(elevation, lowerLoadInfo.elevation, upperLoadInfo.elevation, lowerLoadInfo.snowdepth, upperLoadInfo.snowdepth)
    };
}

interpolate = function(source, sourceLower, sourceUpper, targetLower, targetUpper) {
  return (((source - sourceLower) / (sourceUpper - sourceLower)) * (targetUpper - targetLower)) + targetLower;
}

round = function(number, places) {
  var offset = 10 * places;
  return Math.round(number * offset) / offset;
}
/*
Title:      Zachary Engineering OVER_RIDE STYLES
Author:     matt@mattabron.com // Matt Abron: visualjelly.com 

.inside-page #wrapper #container .container_12 .main-content .grid_8.alpha .post_block .socshare .facebookdiv {
    float: right;
}
#map_canvas {
    float: left;
    height: 870px;
    width: 607px;
    background-color: aqua;
}
#map3d {
    float: left;
    height: 870px;
    width: 607px;
    margin-top: 15px;
    margin-left: 15px;
}
.inside-page #wrapper #container .container_12 .main-content .grid_12.alpha.omega .project #snoload_wrap_v2 #snoload_form #address, #latitude, #longitude, #county, #latitude2, #longitude2, #county2, #elevation, #snowloadResult {
    float: right;
    width: 140px;
    margin-bottom: 9px;
}
.inside-page #wrapper #container .container_12 .main-content .grid_12.alpha.omega .project #snoload_wrap_v2 #snoload_form button {
    margin-left: 10px;
    width: 200px;
}
.snoLoad_Label {
    float: left;
    padding-top: 7px;
    text-transform: uppercase;
    font-size: 12px;
}
.snoLoad_Label_consec {
    float: left;
    padding-top: 16px;
    text-transform: uppercase;
    font-size: 12px;
}
    
#snoLoadVersion {
    height: 160px;
    width: 216px;
    position: absolute;
    left: 126px;
    top: -545px;
    z-index: 50;
}
.SnoLoadCentered {
    text-align: center;
    text-transform: uppercase;
}
#wrapper #container .container_12 .main-content .grid_12.alpha.omega .project #snoload_wrap_v2 #map_canvas p {
    font-size: 10px;
}
#element.style {
    cursor: url("http://maps.gstatic.com/mapfiles/openhand_8_8.cur"), default;
    left: 0;
    position: absolute;
    top: 0;
    z-index: 1;
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="index, follow" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>ZACHARY ENGINEERING | Residential Engineering | Verion3</title>

<!-- CSS Start //-->

<link href="css/custom.css" rel="stylesheet" type="text/css">

<!-- JS Start //--> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
    
    
<script type="text/javascript">
    var $ = jQuery.noConflict();
</script> 
    
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBBiAQWE_6cpjMhaItS0N6Ew3KjHb6JOqg&sensor=true">
</script> 

<script type="text/javascript" src="js/snowloadCalculator.js"></script>
<!-- Custom Functions - Main Js file --> 
<script type="text/javascript">
      var map;
      var infowindow = new google.maps.InfoWindow();

      function initialize() {
        var myOptions = {
          center: new google.maps.LatLng(39.085304, -120.031185),
          zoom: 11,
          mapTypeId: google.maps.MapTypeId.HYBRID
        };
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        google.maps.event.addListener(map, 'click', function(clickEvent) {calculateByLocation(clickEvent.latLng);});
      }

      function calculateByAddress(address, elevationOverride) {
        calculateSnowInfo({address: address}, elevationOverride, successCallback, errorCallback);
      }

      function calculateByLocation(latLng, elevationOverride) {
        calculateSnowInfo({latLng: latLng}, elevationOverride, successCallback, errorCallback);
      }

      function successCallback(info) {
        var content = "Address: " + info.formattedAddress + "<br/>County: " + info.county + "<br/>Elevation: " + info.elevation + "<br/>Ground Snow Load: " + info.snowload + "<br/>";
        content += "Snow Density: " + (info.snowdensity ? info.snowdensity : "no data") + "<br/>";
        content += "Maximum Anticipated Snow Depth: " + (info.snowdensity ? info.snowdepth : "no data");
<!--Location: " + info.location + "<br/>-->
        
        infowindow.setContent(content);
        infowindow.setPosition(info.location);
        
        infowindow.open(map);

        map.setCenter(info.location);
        map.setZoom(19);
        
        $("#address").val(info.formattedAddress);
        $("#addressElevation").val(info.elevation);
        $("#latitude").val(info.location.lat());
        $("#longitude").val(info.location.lng());
        $("#locationElevation").val(info.elevation);
      }

      function errorCallback(errorMessage) {alert(errorMessage);}
</script> 
<script type="text/javascript">
/*// Redirect if mobile device
    SA.redirection_mobile ({
      noredirection_param:"noredirection",
      mobile_url : "#", // If we develop a Zachary Mobile Site, We can lite up this to redirect
      mobile_prefix : "http",
      cookie_hours : "2" 
    });*/

$(window).load(function() {
    

    // load hidden map
    loadHiddenMap();
});

</script> 
<!-- JS End //--> 

<!-- Start Facebook Like Open Graph Tags -->
<meta property="og:title" content="Zachary Engineering" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://visualjelly.com" />
<meta property="og:image" content="#" />
<meta property="og:site_name" content="Zachary Engineering" />
<meta property="fb:admins" content="#" />
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-32880370-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>
<body onload="initialize()">
<body>
<div>
  <div>
    <div>
      <div>
        <div>
          <div>
            <div id="snoload_wrap_v2">
              <div id="map_canvas"></div>
              <div id="snoload_form">
                <span class="snoLoad_Label">Address</span>
                <input id="address" type="text"/>
                <!--<span class="snoLoad_Label">Elevation (optional)</span>
                <input id="addressElevation" type="text"/><br/>-->
                <button onClick="calculateByAddress($('#address').val(), $('#addressElevation').val())">Calculate</button>
                <span class="snoLoad_Label">Latitude</span>
                <input id="latitude" type="text"/>
                <span class="snoLoad_Label">Longitude</span>
                <input id="longitude" type="text"/>
                <!--<span class="snoLoad_Label_consec">Elevation (optional)</span>
                <input id="locationElevation" type="text"/><br/>-->
                <button onClick="calculateByLocation(new google.maps.LatLng($('#latitude').val(), $('#longitude').val()), $('#locationElevation').val())">Calculate</button>
                <!--<span class="snoLoad_Label">Result</span> 
                <input id="snowloadResult" type="text"/>-->               
  
              </div>
            </div>
          </div>       
        </div>
      </div>
    </div>
</body>
</html>
0
Matt 28 अक्टूबर 2020, 16:21

1 उत्तर

सबसे बढ़िया उत्तर

समस्या यह है कि "एल डोरैडो काउंटी" में दो स्थान हैं, अन्य सभी में केवल एक है।

String.replace केवल इस तरह से बुलाए जाने पर एक सबस्ट्रिंग का पहला उदाहरण:

सबस्ट्र
एक स्ट्रिंग जिसे newSubstr द्वारा प्रतिस्थापित किया जाना है। इसे एक शाब्दिक स्ट्रिंग के रूप में माना जाता है और is नियमित अभिव्यक्ति के रूप में व्याख्या नहीं की गई। केवल पहली घटना को बदला जाएगा

तो यह कोड:

  county = county.replace(" ", "_");

केवल "El_Dorado काउंटी" की उपज देने वाले पहले स्थान को प्रतिस्थापित करता है, जो "El_Dorado_County" से मेल नहीं खाता। सभी रिक्त स्थान को बदलने के लिए रेगेक्स का प्रयोग करें:

regexp (पैटर्न)
एक RegExp वस्तु या शाब्दिक। मैच या मैचों को newSubstr या निर्दिष्ट फ़ंक्शन द्वारा लौटाए गए मान से बदल दिया जाता है।

इस कदर:

  const regex = /\s/gi;
  county = county.replace(regex, "_");

screenshot of resulting map

कार्य कोड स्निपेट:

var points = {
  westPlacer: [
    {
      lat: 39.373490,
      long: -120.235205
    }, {
      lat: 39.359037,
      long: -120.235319
    }, {
      lat: 39.343940,
      long: -120.235506
    }, {
      lat: 39.329288,
      long: -120.235731
    }, {
      lat: 39.314982,
      long: -120.236251
    }, {
      lat: 39.300705,
      long: -120.236422
    }, {
      lat: 39.285794,
      long: -120.236672
    }, {
      lat: 39.271297,
      long: -120.236402
    }, {
      lat: 39.256740,
      long: -120.236290
    }, {
      lat: 39.242320,
      long: -120.236151
    }, {
      lat: 39.227314,
      long: -120.236011
    }, {
      lat: 39.213102,
      long: -120.235911
    }, {
      lat: 39.198786,
      long: -120.235766
    }, {
      lat: 39.184576,
      long: -120.236484
    }, {
      lat: 39.184575,
      long: -120.236484
    }, {
      lat: 39.184119,
      long: -120.228208
    }, {
      lat: 39.170143,
      long: -120.228036
    }, {
      lat: 39.154701,
      long: -120.190700
    }, {
      lat: 39.154700,
      long: -120.190700
    }, {
      lat: 39.140015,
      long: -120.190456
    }, {
      lat: 39.125517,
      long: -120.190547
    }, {
      lat: 39.111406,
      long: -120.190561
    }, {
      lat: 39.096556,
      long: -120.190558
    }, {
      lat: 39.082067,
      long: -120.190534
    }, {
      lat: 39.077698,
      long: -120.188443
    }, {
      lat: 39.074887,
      long: -120.187134
    }, {
      lat: 39.071210,
      long: -120.185336
    }, {
      lat: 39.067491,
      long: -120.183625
    }, {
      lat: 39.053039,
      long: -120.183695
    }, {
      lat: 39.038354,
      long: -120.183683
    },
  ],
  eastPlacer: [
    {
      lat: 39.373603,
      long: -120.216838
    }, {
      lat: 39.358984,
      long: -120.216856
    }, {
      lat: 39.344107,
      long: -120.216683
    }, {
      lat: 39.329376,
      long: -120.216833
    }, {
      lat: 39.315090,
      long: -120.217128
    }, {
      lat: 39.300554,
      long: -120.217113
    }, {
      lat: 39.285834,
      long: -120.217154
    }, {
      lat: 39.271439,
      long: -120.217729
    }, {
      lat: 39.256922,
      long: -120.217728
    }, {
      lat: 39.242498,
      long: -120.217577
    }, {
      lat: 39.227876,
      long: -120.217551
    }, {
      lat: 39.213208,
      long: -120.217543
    }, {
      lat: 39.198558,
      long: -120.217517
    }, {
      lat: 39.183976,
      long: -120.217368
    }, {
      lat: 39.183975,
      long: -120.217368
    }, {
      lat: 39.183805,
      long: -120.172043
    }, {
      lat: 39.168931,
      long: -120.171713
    }, {
      lat: 39.154654,
      long: -120.171681
    }, {
      lat: 39.154653,
      long: -120.171681
    }, {
      lat: 39.139767,
      long: -120.171765
    }, {
      lat: 39.125323,
      long: -120.171739
    }, {
      lat: 39.111128,
      long: -120.171530
    }, {
      lat: 39.096527,
      long: -120.171580
    }, {
      lat: 39.082052,
      long: -120.171833
    }, {
      lat: 39.080031,
      long: -120.170910
    }, {
      lat: 39.076672,
      long: -120.169374
    }, {
      lat: 39.072898,
      long: -120.167611
    }, {
      lat: 39.067501,
      long: -120.165205
    }, {
      lat: 39.053084,
      long: -120.164571
    }, {
      lat: 39.038447,
      long: -120.165066
    }
  ]
};

var loads = {
  westWashoe: [
    {
      elevation: 5000,
      snowload: 30
    }, {
      elevation: 5100,
      snowload: 41
    }, {
      elevation: 5200,
      snowload: 52
    }, {
      elevation: 5300,
      snowload: 64
    }, {
      elevation: 5400,
      snowload: 75
    }, {
      elevation: 5500,
      snowload: 86
    }, {
      elevation: 6000,
      snowload: 142
    }, {
      elevation: 6500,
      snowload: 171
    }, {
      elevation: 7000,
      snowload: 200
    }, {
      elevation: 7500,
      snowload: 215
    }, {
      elevation: 8000,
      snowload: 229
    }, {
      elevation: 8500,
      snowload: 243
    }, {
      elevation: 9000,
      snowload: 271
    }, {
      elevation: 9500,
      snowload: 300
    }, {
      elevation: 10000,
      snowload: 357
    }
  ],
  eastWashoe: [
    {
      elevation: 5000,
      snowload: 30
    }, {
      elevation: 5100,
      snowload: 31
    }, {
      elevation: 5200,
      snowload: 33
    }, {
      elevation: 5300,
      snowload: 34
    }, {
      elevation: 5400,
      snowload: 35
    }, {
      elevation: 5500,
      snowload: 37
    }, {
      elevation: 6000,
      snowload: 43
    }, {
      elevation: 6500,
      snowload: 43
    }, {
      elevation: 7000,
      snowload: 57
    }, {
      elevation: 7500,
      snowload: 57
    }, {
      elevation: 8000,
      snowload: 86
    }, {
      elevation: 8500,
      snowload: 86
    }, {
      elevation: 9000,
      snowload: 114
    }, {
      elevation: 9500,
      snowload: 142
    }
  ],
  basinWashoe: [
    {
      elevation: 6000,
      snowload: 220
    }, {
      elevation: 6500,
      snowload: 235
    }, {
      elevation: 7000,
      snowload: 250
    }, {
      elevation: 7500,
      snowload: 265
    }, {
      elevation: 8000,
      snowload: 280
    }, {
      elevation: 8500,
      snowload: 295
    }, {
      elevation: 9000,
      snowload: 330
    }, {
      elevation: 9500,
      snowload: 390
    }, {
      elevation: 10000,
      snowload: 420
    }
  ],
  westPlacer: [
    {
      elevation: 1000,
      snowload: 10,
      snowdensity: 20,
      snowdepth: 3.0
    }, {
      elevation: 1600,
      snowload: 20,
      snowdensity: 20,
      snowdepth: 3.0
    }, {
      elevation: 2500,
      snowload: 29,
      snowdensity: 20,
      snowdepth: 3.0
    }, {
      elevation: 3000,
      snowload: 55,
      snowdensity: 20,
      snowdepth: 3.0
    }, {
      elevation: 3500,
      snowload: 70,
      snowdensity: 20,
      snowdepth: 3.8
    }, {
      elevation: 4000,
      snowload: 100,
      snowdensity: 20,
      snowdepth: 5.0
    }, {
      elevation: 4500,
      snowload: 160,
      snowdensity: 22.7,
      snowdepth: 6.5
    }, {
      elevation: 5000,
      snowload: 200,
      snowdensity: 24.5,
      snowdepth: 8.2
    }, {
      elevation: 5500,
      snowload: 260,
      snowdensity: 26.7,
      snowdepth: 9.7
    }, {
      elevation: 6000,
      snowload: 315,
      snowdensity: 27.0,
      snowdepth: 11.7
    }, {
      elevation: 6500,
      snowload: 375,
      snowdensity: 29.6,
      snowdepth: 12.7
    }, {
      elevation: 7000,
      snowload: 430,
      snowdensity: 30.1,
      snowdepth: 14.3
    }, {
      elevation: 7500,
      snowload: 490,
      snowdensity: 30.6,
      snowdepth: 16.0
    }, {
      elevation: 7501,
      snowload: 545,
      snowdensity: 32.4,
      snowdepth: 16.8
    }
  ],
  eastPlacer: [
    {
      elevation: 5500,
      snowload: 130,
      snowdensity: 23.6,
      snowdepth: 5.5
    }, {
      elevation: 6000,
      snowload: 190,
      snowdensity: 23.8,
      snowdepth: 7.9
    }, {
      elevation: 6500,
      snowload: 245,
      snowdensity: 24.5,
      snowdepth: 10.0
    }, {
      elevation: 7000,
      snowload: 300,
      snowdensity: 25.0,
      snowdepth: 12.0
    }, {
      elevation: 7500,
      snowload: 360,
      snowdensity: 25.2,
      snowdepth: 14.3
    }, {
      elevation: 8000,
      snowload: 400,
      snowdensity: 25.5,
      snowdepth: 15.7
    }, {
      elevation: 8001,
      snowload: 445,
      snowdensity: 25.7,
      snowdepth: 17.3
    }
  ],
  westElDorado: [
    {
      elevation: 2000,
      snowload: 20
    }, {
      elevation: 2500,
      snowload: 32
    }, {
      elevation: 3000,
      snowload: 45
    }, {
      elevation: 3500,
      snowload: 56
    }, {
      elevation: 4000,
      snowload: 68
    }, {
      elevation: 4500,
      snowload: 80
    }, {
      elevation: 5000,
      snowload: 90
    }, {
      elevation: 5500,
      snowload: 100
    }, {
      elevation: 6000,
      snowload: 110
    }, {
      elevation: 6500,
      snowload: 120
    }, {
      elevation: 7000,
      snowload: 128
    }, {
      elevation: 7500,
      snowload: 135
    }
  ],
  basinElDorado: [
    {
      elevation: 6000,
      snowload: 145
    }, {
      elevation: 6500,
      snowload: 160
    }, {
      elevation: 7000,
      snowload: 170
    }, {
      elevation: 7500,
      snowload: 180
    }
  ]
};

var countyCalculations = {
  Washoe_County: function(latLng, elevation) {
    var eastInfo = getSnowInfoForRegion("eastWashoe", elevation);
    var westInfo = getSnowInfoForRegion("westWashoe", elevation);
    var basinInfo = getSnowInfoForRegion("basinWashoe", elevation);

    return {
      county: "Washoe",
      snowload: "<br/>- if east of 395: " + round(eastInfo.snowload, 2) + " psf<br/>- if west of 395: " + round(westInfo.snowload, 2) + " psf<br/>- if in Tahoe Basin: " + round(basinInfo.snowload, 2) + " psf",
      //snowdensity: "<br/>- if east of 395: " + round(eastInfo.snowdensity, 2) + " pcf<br/>- if west of 395: " + round(westInfo.snowdensity, 2) + " pcf<br/>- if in Tahoe Basin: " + round(basinInfo.snowdensity, 2) + " pcf",
      //snowdepth: "<br/>- if east of 395: " + round(eastInfo.snowdepth, 2) + " feet<br/>- if west of 395: " + round(westInfo.snowdepth, 2) + " feet<br/>- if in Tahoe Basin: " + round(basinInfo.snowdepth, 2) + " feet"
    };
  },

  Placer_County: function(latLng, elevation) {
    // get closest basin border reference points
    var eastReferencePoint = getNearestPointForRegionByLatitude("eastPlacer", latLng.lat());
    var westReferencePoint = getNearestPointForRegionByLatitude("westPlacer", latLng.lat());

    // is the longitude east of or in the basin
    var eastSnowInfo;
    if(latLng.lng() > westReferencePoint.long)
      eastSnowInfo = getSnowInfoForRegion("eastPlacer", elevation);

    // is the longitude west of or in the basin
    var westSnowInfo;
    if(latLng.lng() < eastReferencePoint.long)
      westSnowInfo = getSnowInfoForRegion("westPlacer", elevation);

    var snowload;
    var snowdensity;
    var snowdepth;

    // east AND not west snowloads calculated (longitude is east of the basin)
    if(eastSnowInfo && !westSnowInfo) {
      snowload = eastSnowInfo.snowload;
      snowdensity = eastSnowInfo.snowdensity;
      snowdepth = eastSnowInfo.snowdepth;
    }

    // west AND now east snowloads calculated (longitude is west of the basin)
    if(!eastSnowInfo && westSnowInfo) {
      snowload = westSnowInfo.snowload;
      snowdensity = westSnowInfo.snowdensity;
      snowdepth = westSnowInfo.snowdepth;
    }

    // were the east AND west snowloads calculated (longitude is in the basin)
    if(eastSnowInfo && westSnowInfo) {
      snowload = interpolate(latLng.lng(), westReferencePoint.long, eastReferencePoint.long, westSnowInfo.snowload, eastSnowInfo.snowload);
      snowdensity = interpolate(latLng.lng(), westReferencePoint.long, eastReferencePoint.long, westSnowInfo.snowdensity, eastSnowInfo.snowdensity);
      snowdepth = interpolate(latLng.lng(), westReferencePoint.long, eastReferencePoint.long, westSnowInfo.snowdepth, eastSnowInfo.snowdepth);
    }

    return {
      county: "Placer",
      snowload: round(snowload, 2) + " psf",
      snowdensity: round(snowdensity, 2) + " pcf",
      snowdepth: round(snowdepth, 2) + " feet"
    };
  },

  Nevada_County: function(latLng, elevation) {
    // Truckee uses Placer county algorithm
    var info = countyCalculations.Placer_County(latLng, elevation);
    info.county = "Nevada (Truckee only)";
    return info;
  },

  El_Dorado_County: function(latLng, elevation) {
    var westInfo = getSnowInfoForRegion("westElDorado", elevation);
    var basinInfo = getSnowInfoForRegion("basinElDorado", elevation);

    return {
      county: "El Dorado",
      snowload: "<br/>- if on West Slope: " + round(westInfo.snowload, 2) + " psf<br/>- if in Tahoe Basin: " + round(basinInfo.snowload, 2) + " psf",
      //snowdensity: "<br/>- if on West Slope: " + round(westInfo.snowdensity, 2) + " pcf<br/>- if in Tahoe Basin: " + round(basinInfo.snowdensity, 2) + " pcf",
      //snowdepth: "<br/>- if on West Slope: " + round(westInfo.snowdepth, 2) + " feet<br/>- if in Tahoe Basin: " + round(basinInfo.snowdepth, 2) + " feet"
    };
  },

  Douglas_County: function(latLng, elevation) {
    return {
      county: "Douglas",
      snowload: (elevation <= 6000 ? 30 : 150) + " psf"
    };
  }
};

calculateSnowInfo = function(input, elevationOverride, success, error) {
  var geocoderService = new google.maps.Geocoder();
  geocoderService.geocode(input, function(results, status) {
    if(status != google.maps.GeocoderStatus.OK)
      error("Failed to translate address to coordinates via Google: " + status);
    else {
      var location = (input.latLng ? input.latLng : results[0].geometry.location);
      var formattedAddress = results[0].formatted_address;
      var county;
      var city;

      var result = results[0];
      for(componentIndex in result.address_components) {
        var component = result.address_components[componentIndex];
        for(typeIndex in component.types) {
          if(component.types[typeIndex] == "locality")
            city = component.long_name;
          if(component.types[typeIndex] == "administrative_area_level_2")
            county = component.long_name;
        }
      }

      var countyCalculate;
      if(!county) {
        error("Unable to determine county from address");
        return;
      }

      const regex = /\s/gi;
      county = county.replace(regex, "_");

      if(countyCalculations[county]) {
        if(county == "Nevada" && city != "Truckee") {
          error("The address provided appears to be in Nevada county outside the limits of Truckee.  Only Truckee addresses are supported for this county.");
          return;
        }
        countyCalculate = countyCalculations[county];
      } else {
        error("The address provided appears to be in " + county + " county (only Placer, Washoe, Nevada, El Dorado, and Douglas counties are supported)");
        return;
      }

      if(elevationOverride) {
        var info = countyCalculate(location, elevationOverride);
        info.location = location;
        info.formattedAddress = formattedAddress;
        info.elevation = elevation + " feet (overriden)";
        success(info);
      } else {
        var elevationService = new google.maps.ElevationService();
        elevationService.getElevationForLocations({
          locations: [location]
        }, function(results, status) {
          if(status != google.maps.ElevationStatus.OK)
            error("Failed to get elevation data from Google: " + status);
          else {
            elevation = Math.round(results[0].elevation * 3.2808399);

            var info = countyCalculate(location, elevation);
            info.location = location;
            info.formattedAddress = formattedAddress;
            info.elevation = elevation + " feet";
            success(info);
          }
        });
      }
    }
  });
}

getNearestPointForRegionByLatitude = function(region, latitude) {
  var pointsRegion = points[region];

  var bestPoint;
  var bestDelta;

  for(pointIndex in pointsRegion) {
    point = pointsRegion[pointIndex];
    delta = Math.abs(point.lat - latitude);
    if(!bestPoint || delta < bestDelta) {
      bestDelta = delta;
      bestPoint = point;
    }
  }

  return bestPoint;
}

getSnowInfoForRegion = function(region, elevation) {
  var loadsRegion = loads[region];

  var lowerLoadInfo = loadsRegion[0];
  for(loadInfoIndex in loadsRegion) {
    loadInfo = loadsRegion[loadInfoIndex];
    if(loadInfo.elevation > elevation)
      break;
    lowerLoadInfo = loadInfo;
  }

  var upperLoadInfo = loadsRegion[loadsRegion.length - 1];
  for(loadInfoIndex in loadsRegion) {
    loadInfo = loadsRegion[loadInfoIndex];
    if(loadInfo.elevation >= elevation) {
      upperLoadInfo = loadInfo;
      break;
    }
  }

  var results = {};
  if(lowerLoadInfo.elevation == upperLoadInfo.elevation)
    return {
      snowload: lowerLoadInfo.snowload,
      snowdensity: lowerLoadInfo.snowdensity,
      snowdepth: lowerLoadInfo.snowdepth
    };
  else
    return {
      snowload: interpolate(elevation, lowerLoadInfo.elevation, upperLoadInfo.elevation, lowerLoadInfo.snowload, upperLoadInfo.snowload),
      snowdensity: interpolate(elevation, lowerLoadInfo.elevation, upperLoadInfo.elevation, lowerLoadInfo.snowdensity, upperLoadInfo.snowdensity),
      snowdepth: interpolate(elevation, lowerLoadInfo.elevation, upperLoadInfo.elevation, lowerLoadInfo.snowdepth, upperLoadInfo.snowdepth)
    };
}

interpolate = function(source, sourceLower, sourceUpper, targetLower, targetUpper) {
  return (((source - sourceLower) / (sourceUpper - sourceLower)) * (targetUpper - targetLower)) + targetLower;
}

round = function(number, places) {
  var offset = 10 * places;
  return Math.round(number * offset) / offset;
}
/*
Title:      Zachary Engineering OVER_RIDE STYLES
Author:     matt@mattabron.com // Matt Abron: visualjelly.com 
*/
.inside-page #wrapper #container .container_12 .main-content .grid_8.alpha .post_block .socshare .facebookdiv {
    float: right;
}
#map_canvas {
    float: left;
    height: 870px;
    width: 607px;
    background-color: aqua;
}
#map3d {
    float: left;
    height: 870px;
    width: 607px;
    margin-top: 15px;
    margin-left: 15px;
}
.inside-page #wrapper #container .container_12 .main-content .grid_12.alpha.omega .project #snoload_wrap_v2 #snoload_form #address, #latitude, #longitude, #county, #latitude2, #longitude2, #county2, #elevation, #snowloadResult {
    float: right;
    width: 140px;
    margin-bottom: 9px;
}
.inside-page #wrapper #container .container_12 .main-content .grid_12.alpha.omega .project #snoload_wrap_v2 #snoload_form button {
    margin-left: 10px;
    width: 200px;
}
.snoLoad_Label {
    float: left;
    padding-top: 7px;
    text-transform: uppercase;
    font-size: 12px;
}
.snoLoad_Label_consec {
    float: left;
    padding-top: 16px;
    text-transform: uppercase;
    font-size: 12px;
}
    
#snoLoadVersion {
    height: 160px;
    width: 216px;
    position: absolute;
    left: 126px;
    top: -545px;
    z-index: 50;
}
.SnoLoadCentered {
    text-align: center;
    text-transform: uppercase;
}
#wrapper #container .container_12 .main-content .grid_12.alpha.omega .project #snoload_wrap_v2 #map_canvas p {
    font-size: 10px;
}
#element.style {
    cursor: url("http://maps.gstatic.com/mapfiles/openhand_8_8.cur"), default;
    left: 0;
    position: absolute;
    top: 0;
    z-index: 1;
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="index, follow" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>ZACHARY ENGINEERING | Residential Engineering | Verion3</title>

<!-- CSS Start //-->

<link href="css/custom.css" rel="stylesheet" type="text/css">

<!-- JS Start //--> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
    
    
<script type="text/javascript">
    var $ = jQuery.noConflict();
</script> 
    
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBBiAQWE_6cpjMhaItS0N6Ew3KjHb6JOqg">
</script> 

<script type="text/javascript" src="js/snowloadCalculator.js"></script>
<!-- Custom Functions - Main Js file --> 
<script type="text/javascript">
      var map;
      var infowindow = new google.maps.InfoWindow();

      function initialize() {
        var myOptions = {
          center: new google.maps.LatLng(39.085304, -120.031185),
          zoom: 11,
          mapTypeId: google.maps.MapTypeId.HYBRID
        };
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        google.maps.event.addListener(map, 'click', function(clickEvent) {calculateByLocation(clickEvent.latLng);});
      }

      function calculateByAddress(address, elevationOverride) {
        calculateSnowInfo({address: address}, elevationOverride, successCallback, errorCallback);
      }

      function calculateByLocation(latLng, elevationOverride) {
        calculateSnowInfo({latLng: latLng}, elevationOverride, successCallback, errorCallback);
      }

      function successCallback(info) {
        var content = "Address: " + info.formattedAddress + "<br/>County: " + info.county + "<br/>Elevation: " + info.elevation + "<br/>Ground Snow Load: " + info.snowload + "<br/>";
        content += "Snow Density: " + (info.snowdensity ? info.snowdensity : "no data") + "<br/>";
        content += "Maximum Anticipated Snow Depth: " + (info.snowdensity ? info.snowdepth : "no data");
<!--Location: " + info.location + "<br/>-->
        
        infowindow.setContent(content);
        infowindow.setPosition(info.location);
        
        infowindow.open(map);

        map.setCenter(info.location);
        map.setZoom(19);
        
        $("#address").val(info.formattedAddress);
        $("#addressElevation").val(info.elevation);
        $("#latitude").val(info.location.lat());
        $("#longitude").val(info.location.lng());
        $("#locationElevation").val(info.elevation);
      }

      function errorCallback(errorMessage) {alert(errorMessage);}
</script> 
<script type="text/javascript">
/*// Redirect if mobile device
    SA.redirection_mobile ({
      noredirection_param:"noredirection",
      mobile_url : "#", // If we develop a Zachary Mobile Site, We can lite up this to redirect
      mobile_prefix : "http",
      cookie_hours : "2" 
    });*/

$(window).load(function() {
    

    // load hidden map
    initialize();
});

</script> 
<!-- JS End //--> 
</head>
<body onload="initialize()">
<body>
<div>
  <div>
    <div>
      <div>
        <div>
          <div>
            <div id="snoload_wrap_v2">
              <div id="map_canvas"></div>
              <div id="snoload_form">
                <span class="snoLoad_Label">Address</span>
                <input id="address" type="text"/>
                <!--<span class="snoLoad_Label">Elevation (optional)</span>
                <input id="addressElevation" type="text"/><br/>-->
                <button onClick="calculateByAddress($('#address').val(), $('#addressElevation').val())">Calculate</button>
                <span class="snoLoad_Label">Latitude</span>
                <input id="latitude" type="text"/>
                <span class="snoLoad_Label">Longitude</span>
                <input id="longitude" type="text"/>
                <!--<span class="snoLoad_Label_consec">Elevation (optional)</span>
                <input id="locationElevation" type="text"/><br/>-->
                <button onClick="calculateByLocation(new google.maps.LatLng($('#latitude').val(), $('#longitude').val()), $('#locationElevation').val())">Calculate</button>
                <!--<span class="snoLoad_Label">Result</span> 
                <input id="snowloadResult" type="text"/>-->               
  
              </div>
            </div>
          </div>       
        </div>
      </div>
    </div>
</body>
</html>
2
geocodezip 28 अक्टूबर 2020, 17:04