· 5 years ago · Mar 29, 2020, 10:29 PM
1
2var lyr_sample_results_polygon_overlay_temp_customer_overlay = [];
3var lyr_sample_results_im_polygon_overlay = [];
4var lyr_sample_results_zone_values_overlay = [];
5var lyr_sample_results_polygon_field_boundary_overlay = [];
6var lyr_insert_NVZ_bool = true;
7var im_nvz_polygon_overlay = [];
8var lyr_tracker_loop = true;
9var lyr_tracker_overlay = [];
10var lyr_tracker_info_overlay = [];
11var lyr_harvest_overlay = [];
12var lyr_harvest_dates = [];
13var lyr_poi_points = [];
14var lyr_poi_infoWindow = [];
15var lyr_poi_singlePointMarker;
16var lay_poi_watchId;
17var lyr_poi_localisation = false;
18var lyr_harvest_area_poygons = [];
19var lyr_true_harvest_area_poygons = [];
20
21setTimeout(function () {
22 if (getFarmId() > 0) {
23 //highlight farm
24 $(".left_panel_farm_item").each(function () {
25 if ($(this).attr("id").split('_')[1] == getFarmId()) {
26 $(this).addClass("farm_item_selected");
27 }
28 else {
29 $(this).removeClass("farm_item_selected");
30 }
31 })
32 }
33}, 2000);
34
35
36$(document).on("click", ".layer_list_item_title", function () {
37
38 chkUserAddingField();//duplicate of bottom of function encase bottom one needed for specific tabs and was cautious about knock on effects of changes
39 //only chkUserAddingField() uses gen_mode out of the bottom functions. gen_mode is changed by milayers and miorder specific tab functions below.
40 resetFieldPanel();
41 resetLayersPanel();
42
43 //make sure no fields have been highlighted
44 for (var i = 0; i < polygonsArray.length; i++) {
45 polygonsArray[i].setOptions({
46 strokeColor: '#4fde47',
47 strokeOpacity: 1,
48 strokeWeight: 2
49 });
50 }
51
52
53 if ($(this).hasClass("field_list_title")) {
54
55 if ($(this).find('span').hasClass("glyphicon-menu-down")) {
56
57 $(".layer_list_items").slideUp()
58 $(".layer_list_title span").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
59
60
61 }
62 setFieldPanelList();
63 }
64
65 if ($(this).hasClass("layer_list_title")) {
66 if (!$(this).find('span').hasClass("glyphicon-menu-up"))
67 {
68 closeAllLayerLists();
69 }
70 setLayerListPanel();
71 gen_resetGenericMode();
72 }
73
74 if ($(this).hasClass("form_list_title")) {
75 if (!$(this).find('span').hasClass("glyphicon-menu-up")) {
76 closeAllLayerLists();
77 }
78 setFormListPanel();
79 gen_resetGenericMode();
80 }
81
82 if ($(this).hasClass("farm_list_title_static")) {
83
84 if ($(".farm_list_items").is(":visible")) {
85 $(".farm_list_items").hide();
86 $(".farm_list_title_static span").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
87 }
88 else {
89 $(".farm_list_items").show();
90 $(".farm_list_title_static span").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up");
91 }
92 }
93
94 chkUserAddingField();
95 //clear cdax data
96 lyr_cdax_hideCDaxCal();
97 lyr_afbi_hideWeatherCal();
98 //clear grasshopper data
99 lyr_hideGrasshopper_plate();
100 //hide nvz
101 lyr_clear_NVZ();
102 //hide poi
103 lyr_hidePOI();
104
105 lyr_checkLockedLayer();
106});
107
108function lyr_checkLockedLayer() {
109 $(".lyr_highlight_locked_item").removeClass("lyr_highlight_locked_item");
110 $(".lyr_locked_icon").removeClass("icon-noun_Lock_747565 lyr_lock_red").addClass("icon-noun_Unlock_821902");
111 $(".lyr_lock_txt").empty().html("Lock this layer");
112 $(".lyr_lock").removeClass("locked");
113 $('.lyr_locked:visible').removeClass('lyr_locked')
114
115 $(".layerInfo ").each(function () {
116 if ($(this).hasClass("lyr_locked")) {
117 $(this).removeClass("lyr_locked")
118 }
119 });
120
121 $('.lyr_lock').hide();
122}
123
124function resetFieldPanel() {
125
126 if (fld_drawingManager != undefined) {
127 fld_drawingManager.setDrawingMode(null);
128 }
129
130 for (var i = 0; i < polygonsArray.length; i++) {
131 polygonsArray[i].setOptions({
132 editable: false,
133 });
134 }
135
136 //loop through to find open field panels
137 if ($(".field_item_selected").length > 0) {
138 //remove editable attribute
139 $(".field_item_selected").removeAttr("contenteditable");
140 $(".field_item_selected").removeClass("field_name_edit_mode");
141 var selectedFieldId = $(".field_item_selected").attr("id").split('_')[1];
142 $(".field_item_selected").addClass("field_item").removeClass("field_item_selected");
143 $(".fieldInfo").each(function () {
144 if ($(this).attr("rel") == selectedFieldId) {
145 $(this).empty().hide();
146 }
147 })
148 }
149
150 //field sample result check
151 if (gen_mode_sub == 2) {
152 removeSingleFieldSampleData();
153 $("#leftDetailsPanel").hide();
154 //hide nutrients
155 $(".fld_recent_sample_nutrients").hide();
156 }
157
158 //clear search box
159 $("#ui_fieldSearch").val('');
160 //incase any fields hav been hidden by previous search
161 $(".field_item").each(function () {
162 $(this).removeAttr("style");
163 });
164
165
166 if (gen_mode == 1) {
167 //was doing field related work.
168 if (gen_mode_sub == 3) {
169 //wo field
170 gen_mode_sub = 0;
171 gen_mode = 0;
172 google.maps.event.removeListener(fld_addFieldPoint);
173 //need to remove added marker as its not been saved.
174 if (fld_addFieldsinglePointMarker != null) {
175 fld_addFieldsinglePointMarker.setMap(null);
176 fld_addFieldsinglePointMarker = null;
177 }
178 $(".fld_newfield_wo_boundary_field_name").val('');
179 //close form
180 $("#fld_noBoundaryPt_wrapper").hide();
181 }
182 }
183
184}
185
186function chkUserAddingField() {
187
188 $('.add_new_field_item').removeClass("disabledLikeAButton");
189
190 if (fld_drawingManager != undefined) {
191 fld_drawingManager.setDrawingMode(null);
192 }
193
194 //deletes only unsaved // nested if because if null or has "" shouldnt check for strokeWeight
195 // debugger;
196 if (selectedShape != null) {
197 if (selectedShape != "") {
198 if(selectedShape.strokeWeight == 0){
199 selectedShape.setMap(null);
200 }
201 }
202 }
203
204
205 //deletes uncompleted if in specific mode
206 if ((gen_mode == 1) && (gen_mode_sub == 1 || gen_mode_sub == 2)) {
207 if (selectedShape != null) {
208 if (selectedShape != "") {
209 selectedShape.setMap(null);
210
211 }
212 }
213
214 //clear/hide legend
215 displayLeftDetailsPanel(false);
216 $('.add_new_field_item').removeClass("disabledLikeAButton");
217
218 //reset modes
219 gen_resetGenericSubMode();
220 gen_resetGenericMode();
221 }
222}
223
224function closeAllLayerLists(isFieldClick) {
225
226 //generic layers
227 lyr_generic_reset_overlay();
228 //generic layers -- end
229
230 //forms
231 if ($(".form_list_items").find('span').hasClass("glyphicon-menu-up")) {
232
233 //all forms are hidden
234 $(".form_item_wrapper").hide();
235 $(".form_item_wrapper").find('span').removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
236 $(".form_list_items").hide();
237 }
238 $(".form_item_selected").each(function () {
239 $(this).removeClass("form_item_selected");
240 });
241
242 $(".form_item_wrapper").each(function () {
243 $(this).hide();
244 })
245
246 //forms -- end
247
248 if (!isFieldClick) {
249 $(".layer_list_item_title").each(function () {
250 if (!$(this).hasClass("farm_list_title_static")) {
251 if ($(this).next().is(":visible")) {
252 $(this).next().slideUp();
253 $(this).find('span').removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
254 }
255 }
256 })
257 }
258
259
260
261
262 //clear/hide legend
263 displayLeftDetailsPanel(false);
264
265 //remove any overlays present
266 img_clearOverlay();
267
268 //close any milayer children
269 $(".layerInfo").each(function () {
270 if ($(this).is(":visible")) {
271 $(this).hide();
272 }
273 });
274 $(".layer_item_selected").removeClass("layer_item_selected");
275
276 resetFieldPanel();
277}
278
279$(document).on("click", ".left_panel_farm_item", function () {
280
281 $("#leftPanelFarmId").val($(this).attr("id").split('_')[1]);
282 //mapofag url checker
283 if ($("#authPage").length > 0) {
284
285 var authURL = window.location.href;
286 var newURL = "";
287 var urlArr = authURL.split('&');
288
289
290 if (urlArr.length == 3) {
291 bPass = true;
292 newURL = urlArr[0] + "&" + urlArr[1] + "&f=" + $("#leftPanelFarmId").val();
293
294 window.location.href = newURL;
295 }
296 //passing layer aswell.
297 if (urlArr.length == 4) {
298
299 var urlParam2 = "";
300 //find out if this is a farm param
301 var arr2 = urlArr[2].split('=');
302
303 if (arr2[0] == "f") {
304 urlParam2 = "&f=" + $("#leftPanelFarmId").val() + "&layer=migrass";
305 }
306 else {
307 urlParam2 = "&" + urlArr[2] + "&f=" + $("#leftPanelFarmId").val();
308 }
309 newURL = urlArr[0] + "&" + urlArr[1] + urlParam2;
310 authURL = authURL + "&f=" + $("#leftPanelFarmId").val();
311 window.location.href = newURL;
312 }
313
314
315 }
316 else {
317 $("#inline_farmListForm").submit();
318 }
319
320});
321
322function layer_MiSAT_Combined_Satellites_Lock_Check() {
323 debugger;
324 $(".lyr_highlight_locked_item").removeClass("lyr_highlight_locked_item");
325 $(".lyr_locked_icon").removeClass("icon-noun_Lock_747565 lyr_lock_red").addClass("icon-noun_Unlock_821902");
326 $(".lyr_lock_txt").empty().html("Lock this layer");
327 $(".lyr_lock").removeClass("locked");
328
329 $(".layerInfo ").each(function () {
330 if ($(this).hasClass("lyr_locked")) {
331 $(this).removeClass("lyr_locked")
332 }
333 });
334
335 //remove any harvest areas
336 for (var i = 0; i < lyr_harvest_area_poygons.length; i++) {
337 layer - item - tracker
338 lyr_harvest_area_poygons[i].setMap(null);
339 }
340 lyr_harvest_area_poygons = [];
341}
342
343function lyr_lockCheck() {
344 $(".layer_item").each(function () {
345 debugger;
346 if ($(this).hasClass("layer_item_selected")) {
347 if (!$(this).hasClass("imagery_layer_misat")) {
348 if (!$(this).hasClass("layer-item-tracker")) {
349 if (!$(this).hasClass("layer-item-harvest-areas")) {
350 if (!$(this).hasClass("imagery_layer_cigreen")) {
351 debugger;
352 $(".lyr_highlight_locked_item").removeClass("lyr_highlight_locked_item");
353 $(".lyr_locked_icon").removeClass("icon-noun_Lock_747565 lyr_lock_red").addClass("icon-noun_Unlock_821902");
354 $(".lyr_lock_txt").empty().html("Lock this layer");
355 $(".lyr_lock").removeClass("locked");
356
357
358 $(".layerInfo ").each(function () {
359 if ($(this).hasClass("lyr_locked")) {
360 $(this).removeClass("lyr_locked")
361 }
362 });
363
364 $('.lyr_lock').hide();
365 //remove any harvest areas
366 for (var i = 0; i < lyr_harvest_area_poygons.length; i++) {
367 layer - item - tracker
368 lyr_harvest_area_poygons[i].setMap(null);
369 }
370 lyr_harvest_area_poygons = [];
371
372 }
373 }
374 }
375 }
376
377 }
378
379 });
380}
381
382//*****************main left side code
383$(document).on("click", ".layer_item", function () {
384 debugger;
385 ////this is temp
386 //lyr_clr_droneData();
387 //lyr_clr_droneInfoLyr();
388
389 resetSubPanels(gen_mode_sub);
390 lyr_sample_results_clearOverlays();
391 //hide generic layers on map
392 lyr_generic_reset_overlay();
393 //remove any pasture/weather data on map
394 lyr_cdax_clearPastureData();
395 lyr_clearWeatherData();
396 lyr_cdax_hideCDaxCal();
397 lyr_afbi_hideWeatherCal();
398 lyr_hideGrasshopper_plate();
399 //hide generic layers on map -- end
400 //hide nvz
401 lyr_clear_NVZ();
402 //hide and stop tracker data
403 lyr_hideTrackers();
404 lyr_tracker_loop = false;
405 $(".layer-item-trackelayer-item-harvest-areasr").find(".layer_item_loader").hide();
406 //hide harvestdates
407 lyr_hideHarvestDatesLayer();
408 //hide poi
409 lyr_hidePOI();
410 //hide harvest shape areas
411 lyr_clear_HarvestAreas();
412 //hide true harvest areas
413 lyr_clear_True_HarvestAreas();
414 //clear weather station data
415 lyr_remove_weatherStations();
416 lyr_close_weatherStationInfo();
417 lyr_hide_weatherZone();
418
419 //make sure field names are showing.
420 if ($("#toggleLegends").is(':checked')) {
421
422 toggleLegends(true);
423 }
424
425 var selectedId = $(this).attr("rel");
426 gen_setGlobalSubMode($(this).attr("rel"));
427 //user is clicking on the selected layer again. Toggle this...
428 if ($(this).hasClass("layer_item_selected")) {
429 $(this).removeClass("layer_item_selected");
430
431
432 //this is a crop layer
433 if ($(this).hasClass("layer-item-cropping")) {
434 crp_clearCropPolygons()
435 crp_clear_farm_wide_crops();
436 $(".lyr_crop_key_wrapper").empty();
437 $(".layer_info_crop_wrapper").hide();
438 }
439 //this is a poi layer end.
440
441
442 //this is a poi layer
443 if ($(this).hasClass("layer-item-poi")) {
444 lyr_hidePOI();
445 }
446 //this is a poi layer end.
447
448 //this is a tracker layer
449 if ($(this).hasClass("layer-item-tracker")) {
450 lyr_tracker_loop = false;
451 $(this).find(".layer_item_loader").hide();
452 lyr_hideTrackers();
453 }
454 //this is a tracker layer - end.
455 //*** harvest dates have been selected
456 if ($(this).hasClass("layer-item-harvest-dates")) {
457 lyr_hideHarvestDatesCal();
458 $(".harvest_date_selected").empty();
459 }
460 //*** harvest dates have has been selected - end.
461
462
463 //this is an image layer
464 if ($(this).hasClass("layer-item-imagery")) {
465
466 if ($(this).hasClass("imagery_layer_nsensor")) {
467 //clear n-sensor selected date
468 $(".n-sensor_date_selected").empty();
469 }
470 if ($(this).hasClass("imagery_layer_migrass")) {
471 //clear migrass selected date
472 $(".migrass_date_selected").empty();
473 }
474 if ($(this).hasClass("imagery_layer_misat")) {
475 //clear misat selected date
476 $(".misat_date_selected").empty();
477 }
478 if ($(this).hasClass("imagery_layer_rgb")) {
479 //clear rgb selected date
480 $(".rgb_date_selected").empty();
481 }
482 if ($(this).hasClass("imagery_layer_uav")) {
483 //clear uav selected date
484 $(".uav_date_selected").empty();
485 }
486 if ($(this).hasClass("imagery_layer_sample_results")) {
487 //clear soil data
488 $(".lyr_sample_results_wrapper").remove();
489 }
490 if ($(this).hasClass("imagery_layer_cigreen")) {
491 //clear cigreen selected date
492 $(".cigreen_date_selected").empty();
493 }
494 if ($(this).hasClass("imagery_layer_variety_view")) {
495 //clear variety view
496 $("#leftPanelVarietyList").empty().hide();
497 }
498 debugger;
499
500 if ($(this).next().text().length > 0) {
501 if ($(this).next().find(".imagery_layer_wrapper").length > 0) {
502 $(this).next().find(".imagery_layer_wrapper").children().each(function () {
503 //deselect item
504 $(this).removeClass("layer_item_imagery_child_selected");
505
506 })
507 }
508 }
509 }
510 debugger;
511 //**Other DB imager layers **//
512 if ($(this).hasClass("layer_item_other_dynamic")) {
513 if ($(this).hasClass("layer_item_cdax_pasture")) {
514 lyr_cdax_clearPastureData();
515 //remove calendar
516 var layerId = $(this).attr("id");
517 $(".layerInfo").each(function () {
518 if ($(this).attr("rel") == layerId) {
519 $(this).empty();
520 }
521 });
522 }
523 if ($(this).hasClass("layer_item_cdax_pasture_img")) {
524 resetSubPanels("12");
525 var layerId = $(this).attr("id");
526 $(".layerInfo").each(function () {
527 if ($(this).attr("rel") == layerId) {
528 $(this).empty();
529 }
530 });
531 }
532
533 if ($(this).hasClass("layer_item_grasshopper_plate")) {
534 ///resetSubPanels("12");
535 var layerId = $(this).attr("id");
536 $(".layerInfo").each(function () {
537 if ($(this).attr("rel") == layerId) {
538 $(this).empty();
539 }
540 });
541 }
542
543 if ($(this).hasClass("layer_item_grasshopper_img")) {
544 ///resetSubPanels("12");
545 var layerId = $(this).attr("id");
546 $(".layerInfo").each(function () {
547 if ($(this).attr("rel") == layerId) {
548 $(this).empty();
549 }
550 });
551 }
552
553 }
554 //**Other DB imager layers ** -- end//
555
556 if ($(this).hasClass("layer_item_generic")) {
557 lyr_generic_hide_overlay($(this).attr("id"));
558 }
559
560
561 if ($(this).hasClass("layer-item-harvest-areas")) {
562 //clear harevset areas
563 lyr_clear_HarvestAreas();
564 }
565 if ($(this).hasClass("layer-item-true_harvested-areas")) {
566 //clear true harevset areas
567 lyr_clear_True_HarvestAreas();
568 }
569
570 //is this a soil sensor layer
571 if ($(this).hasClass("layer-soil-sensor")) {
572
573 //clear soil sensor points
574 lyr_close_soilSenorsInfo();
575 lyr_remove_soilSenors();
576 for (var i = 0; i < polygonsArray.length; i++) {
577 //enable click of all polygon fields as they have been disabled
578 polygonsArray[i].setOptions({
579 clickable: true
580 })
581 }
582 }
583
584 } else {
585 debugger;
586 //clear all layer item wrappers
587 $(".layer_item").each(function () {
588 if ($(this).hasClass("layer_item_selected")) {
589 $(this).removeClass("layer_item_selected");
590 var lyrId = $(this).attr("rel");
591 $(".layerInfo").each(function () {
592 if (($(this).attr("rel") == lyrId)) {
593 $(this).hide();
594 //check to see if the layer has been locked. If so then just hide.
595 if (!$(this).hasClass("lyr_locked")) {
596
597 //dont not empty placeholder wrapper if it is harvest area.
598 if (!$("#" + lyrId).hasClass("layer-item-harvest-areas")) {
599 if (lyrId != 17) {
600 //if not cigreen
601 $(this).empty();
602 }
603
604 }
605 }
606 }
607
608 });
609
610 }
611 })
612
613 $(this).addClass("layer_item_selected");
614
615 //*** imagery layer has been selected.
616 if ($(this).hasClass("layer-item-imagery")) {
617 if (!$(this).hasClass("imagery_layer_sample_results")) {
618
619 $(".layerInfo").each(function () {
620 debugger;
621 if (($(this).attr("rel") == gen_mode_sub)) {
622 if ($(this).text().length > 0) {
623 //we have data, display
624 $(this).show();
625 if ($(this).find('#leftPanelDatePickerWrapper').css('display') == 'none') {
626 $(this).find('#leftPanelDatePickerWrapper').show();
627 }
628 //reset calendar
629 debugger;
630 //$(this).children().show()
631 debugger;
632 if (gen_mode_sub == 1) {
633 // refeshBISensorCal();
634 // refeshNSensorCal();
635 // refeshNASSensorCal();
636 $(".imagery_layer_nsensor").find(".layer_item_loader").show();
637 //remove options panel if exists, this will be a user coming back to n-sensor after going to mifields.
638 if ($(".nsensor_cal_options_wrapper").length > 0) {
639 $(".nsensor_cal_options_wrapper").empty();
640 $(".imagery_layer_nsensor").find(".layer_item_loader").hide();
641 }
642 }
643 if (gen_mode_sub == 2) {
644 refreshMisatCal();
645 $(".imagery_layer_misat").find(".layer_item_loader").show();
646 //remove options panel if exists, this will be a user coming back to misat after going to mifields.
647 if ($(".misat_cal_options_wrapper").length > 0) {
648 $(".misat_cal_options_wrapper").empty();
649 $(".imagery_layer_misat").find(".layer_item_loader").hide();
650 }
651 }
652 if (gen_mode_sub == 3) {
653 refreshRTKCal();
654 }
655 if (gen_mode_sub == 4) {
656 refreshUAVCal();
657 $(".imagery_layer_uav").find(".layer_item_loader").show();
658 //remove options panel if exists, this will be a user coming back to uav after going to mifields.
659 if ($(".uav_cal_options_wrapper").length > 0) {
660 $(".uav_cal_options_wrapper").parent().show();
661 $(".imagery_layer_uav").find(".layer_item_loader").hide();
662 }
663 }
664
665 if (gen_mode_sub == 6) {
666
667 $(".imagery_layer_conductivity").find(".layer_item_loader").show();
668 // calendar no longer exists refreshCondCal();
669 //remove options panel if exists, this will be a user coming back to conductivity after going to mifields.
670 if ($(".conductivity_cal_options_Shall").length > 0) {
671 $(".cigreen_cal_options_wrapper").parent().show();
672 $(".imagery_layer_conductivity").find(".layer_item_loader").hide();
673 }
674 }
675
676 if (gen_mode_sub == 7) {
677 refreshMigrassCal();
678 $(".imagery_layer_migrass").find(".layer_item_loader").show();
679 //remove options panel if exists, this will be a user coming back to migrass after going to mifields.
680 if ($(".migrass_cal_options_wrapper").length > 0) {
681 $(".migrass_cal_options_wrapper").empty();
682 $(".imagery_layer_migrass").find(".layer_item_loader").hide();
683 }
684 }
685
686 if (gen_mode_sub == 8) {
687 refreshRGBCal();
688 $(".imagery_layer_rgb").find(".layer_item_loader").show();
689 //remove options panel if exists, this will be a user coming back to rgb after going to mifields.
690 if ($(".rgb_cal_options_wrapper").length > 0) {
691 $(".rgb_cal_options_wrapper").empty();
692 $(".imagery_layer_rgb").find(".layer_item_loader").hide();
693 }
694
695 }
696 if (gen_mode_sub == 9) {
697 refreshYieldCal();
698 $(".imagery_layer_yield").find(".layer_item_loader").show();
699 //remove options panel if exists, this will be a user coming back to yield after going to mifields.
700 if ($(".yield_cal_options_wrapper").length > 0) {
701 $(".yield_cal_options_wrapper").show();
702 $(".imagery_layer_yield").find(".layer_item_loader").hide();
703 }
704
705
706 }
707
708 //if (gen_mode_sub == 16) {
709 //}
710
711 if (gen_mode_sub == 17) {
712 refreshCIgreenCal();
713 //remove options panel if exists, this will be a user coming back to cigreen after going to mifields.
714 //if ($(".cigreen_cal_options_wrapper").length > 0) {
715 // $(".cigreen_cal_options_wrapper").empty()
716 //}
717
718 //if ($(".rgb_cal_options_wrapper").length > 0) {
719 // $(".rgb_cal_options_wrapper").empty();
720 // $('.rgb_cal').datepicker("destroy");
721 // $(".imagery_layer_rgb").find(".layer_item_loader").hide();
722 //}
723
724 //if ($(".misat_cal_options_wrapper").length > 0) {
725 // $(".misat_cal_options_wrapper").empty();
726 // $('.misat_cal').datepicker("destroy");
727 //}
728
729 //$('.satSelectIcons').removeClass('hoveredIcon selectedIcon');
730 //$('#ci_green_icon').addClass('selectedIcon');
731 //$('#satelliteTypeName').text('CI Green');
732 }
733 //loadMapLayerImgTypeDateDDL($(this).attr("rel"));
734 }
735 else {
736 //loading first time.
737 if (gen_mode_sub != 20) {
738 loadMapLayerImgTypeDateDDL($(this).attr("rel"));
739 }
740 else {
741 loadVarietyList();
742 }
743
744 $(this).prev().find(".layer_item_loader").show();
745 }
746
747 }
748 else {
749 $(this).hide();
750 }
751
752 });
753
754
755 if ($(this).hasClass("imagery_layer_nvz")) {
756
757 //load nvz
758 img_clearOverlay();
759
760 //set englad bound box
761 var overlayNVZEnglandBoundary = new google.maps.MVCArray();
762 overlayNVZEnglandBoundary.push(new google.maps.LatLng("55.772196", "2.067554"));
763 overlayNVZEnglandBoundary.push(new google.maps.LatLng("49.983927", "2.067554"));
764 overlayNVZEnglandBoundary.push(new google.maps.LatLng("49.983927", "-6.234384"));
765 overlayNVZEnglandBoundary.push(new google.maps.LatLng("55.772196", "-6.234384"));
766
767 //set englad bound box
768 var overlayNVZWalesBoundary = new google.maps.MVCArray();
769 overlayNVZWalesBoundary.push(new google.maps.LatLng("53.353388", "-2.644410"));
770 overlayNVZWalesBoundary.push(new google.maps.LatLng("51.478764", "-2.644410"));
771 overlayNVZWalesBoundary.push(new google.maps.LatLng("51.478764", "-5.113716"));
772 overlayNVZWalesBoundary.push(new google.maps.LatLng("53.353388", "-5.113716"));
773
774 //set scotland bound box
775 var overlayNVZScotlandBoundary = new google.maps.MVCArray();
776 overlayNVZScotlandBoundary.push(new google.maps.LatLng("57.732051", "-1.764346"));
777 overlayNVZScotlandBoundary.push(new google.maps.LatLng("54.814521", "-1.764346"));
778 overlayNVZScotlandBoundary.push(new google.maps.LatLng("54.814521", "-5.317961"));
779 overlayNVZScotlandBoundary.push(new google.maps.LatLng("57.732051", "-5.317961"));
780
781 var englandOptions = {
782 path: overlayNVZEnglandBoundary,
783 strokeColor: "#12F505",
784 strokeOpacity: 1,
785 strokeWeight: 0,
786 fillOpacity: 0.0,
787 zIndex: 9
788 }
789
790 var walesOptions = {
791 path: overlayNVZWalesBoundary,
792 strokeColor: "#1508E8",
793 strokeOpacity: 1,
794 strokeWeight: 0,
795 fillOpacity: 0.0,
796 zIndex: 9
797 }
798
799
800 var scotlandOptions = {
801 path: overlayNVZScotlandBoundary,
802 strokeColor: "#1508E8",
803 strokeOpacity: 1,
804 strokeWeight: 0,
805 fillOpacity: 0.0,
806 zIndex: 9
807 }
808
809 //Create polygon
810 var englandPolygon = new google.maps.Polygon(englandOptions);
811 //Show it on map
812 englandPolygon.setMap(map);
813 //Create polygon
814 var walesPolygon = new google.maps.Polygon(walesOptions);
815 //Show it on map
816 walesPolygon.setMap(map);
817 //Create polygon
818 var scotlandPolygon = new google.maps.Polygon(scotlandOptions);
819 //Show it on map
820 scotlandPolygon.setMap(map);
821
822
823 //get bounds from polygon for custom overlay
824 if (!google.maps.Polygon.prototype.getBounds)
825 google.maps.Polygon.prototype.getBounds = function () {
826 var bounds = new google.maps.LatLngBounds();
827 var paths = this.getPaths();
828 for (var i = 0; i < paths.getLength() ; i++) {
829 var path = paths.getAt(i);
830 for (var j = 0; j < path.getLength() ; j++) {
831 bounds.extend(path.getAt(j));
832 }
833 }
834 return bounds;
835 }
836
837 var englandOverlay = new google.maps.GroundOverlay("https://api.mi.farm/static/images/nvz/Coloured_NVZ_4326.png", englandPolygon.getBounds(), { clickable: false, opacity: 0.3 });
838 englandOverlay.setMap(map);
839 addPolygonMouseCoordsData(englandOverlay);
840 im_nvz_polygon_overlay.push(englandOverlay);
841 var walesOverlay = new google.maps.GroundOverlay("https://api.mi.farm/static/images/nvz/Wales_WGS84.png", walesPolygon.getBounds(), { clickable: false, opacity: 0.3 });
842 walesOverlay.setMap(map);
843 addPolygonMouseCoordsData(walesOverlay);
844 im_nvz_polygon_overlay.push(walesOverlay);
845
846 var scotlandOverlay = new google.maps.GroundOverlay("https://api.mi.farm/static/images/nvz/Scotland_WSG84.png", scotlandPolygon.getBounds(), { clickable: false, opacity: 0.3 });
847 scotlandOverlay.setMap(map);
848 addPolygonMouseCoordsData(scotlandOverlay);
849 im_nvz_polygon_overlay.push(scotlandOverlay);
850
851 }
852
853 }
854 else {
855
856 if ($(this).hasClass("imagery_layer_sample_results")) {
857
858 //sample results imagery layer********************************************************************
859 //load dates
860
861 $.ajax({
862 type: "POST",
863 url: urlPrepend + "/sampledata/" + getFarmId()
864 }).done(function (data) {
865
866 if (data.length > 0) {
867 var t = JSON.parse(data);
868 var str = "";
869 var groupSoilOrderId = 0;
870 for (var i = 0; i < t.services.length; i++) {
871
872 //making sure only one instance of an order is displayed.
873 if (groupSoilOrderId != t.services[i].soildOrderId) {
874 str += "<li><span class=\"lyr_sample_service\" id=\"" + t.services[i].pdServiceId + "|" + t.services[i].soildOrderId + "\">" + t.services[i].name + "<br/><span class=\"lyr_sample_service_sample_date\">(" + t.services[i].dateSampled.split(' ')[0] + ")</span>" + "</span><ul rel=\"" + t.services[i].soildOrderId + "\" class=\"lyr_sample_service_nutrient_wrapper\"></ul></li>"
875 }
876 groupSoilOrderId = t.services[i].soildOrderId;
877 }
878
879
880 if (str != "") {
881 gen_mode_sub == 10;
882 str = "<ul class=\"lyr_sample_results_wrapper\">" + str + "</ul>";
883
884 $(".layerInfo").each(function () {
885 if (($(this).attr("rel") == "10")) {
886 $(this).html(str);
887 $(this).show();
888 }
889 });
890 }
891 }
892 else {
893 displayErrMsg("This farm does not contain any sample results data.");
894 }
895
896 });
897 //*** END ***sample results imagery layer********************************************************************
898 }
899
900 }
901
902 }
903 //*** END *** imagery layer has been selected - end.
904
905 //*** True_ harvested areas
906
907 if ($(this).hasClass("layer-item-true_harvested-areas")) {
908 lyr_getTrue_HarvestedAreas_FieldIds();
909 loadStatus("Loading True Harvested Area Data....");
910 }
911
912
913 //*** harvest area
914
915 if ($(this).hasClass("layer-item-harvest-areas")) {
916 //has this layer been loacked?
917 if (!$(this).hasClass("lyr_highlight_locked_item")) {
918 loadStatus("Loading Harvest Area Data");
919 lyr_loadHarvestAreas();
920 }
921
922 var thisId = $(this).attr("id");
923 $(".layerInfo").each(function () {
924 if (($(this).attr("rel") == thisId)) {
925 $(this).show();
926 }
927 });
928
929 }
930 //*** harvest area - end
931
932 //*** tracker has been selected
933 if ($(this).hasClass("layer-item-tracker")) {
934 lyr_tracker_loop = true;
935 lyr_trackerClickedInfoBox = ""
936 lyr_getTrackerData();
937 loadStatus("Loading MiTracker Data");
938 $(this).find(".layer_item_loader").show();
939 }
940 //*** tracker layer has been selected - end.
941 //*** harvest dates have been selected
942 if ($(this).hasClass("layer-item-harvest-dates")) {
943 lyr_getHarvestDatesData();
944 }
945 //*** harvest dates have has been selected - end.
946
947 //*** crop layer has been selected
948 if ($(this).hasClass("layer-item-cropping")) {
949
950 img_clearOverlay();
951
952 if ($(".layer_info_crop_wrapper").length == 0) {
953 //create wrapper again as it has been deleted
954 $(".layerInfo").each(function () {
955 if (($(this).attr("rel") == 0)) {
956
957
958
959 $(this).empty().html("<div class=\"layer_info_crop_wrapper\"><div class=\"lyr_crop_key_wrapper\"></div><button id=\"crp_microppingAddToSeason\" class=\"crp_micropping_add_crops_to_season\">Add crops to season</button></div>");
960 }
961 });
962 }
963
964
965 $(".layer_info_crop_wrapper").parent().show();
966 //clear crop listing
967 $(".lyr_crop_key_wrapper").empty();
968
969 if ($("#customerSeason").find(":selected").val() != "addseason") {
970
971 //if farms has no fields hide 'add cropts to field' button
972 if (polygonsArray.length > 0) {
973 $(".layer_info_crop_wrapper").show();
974 crp_loadDefultSeasonCrops();
975 }
976 }
977 }
978 //*** crop layer has been selected - end.
979
980 //**CDAX||Weather layer||Grasshopper**//
981 if ($(this).hasClass("layer_item_other_dynamic")) {
982 displayLeftDetailsPanel(false);
983 //CDAX-Point
984 if ($(this).hasClass("layer_item_cdax_pasture")) {
985 lyr_cdax_getDate();
986 }
987
988 //CDAX-Point
989 if ($(this).hasClass("layer_item_cdax_pasture_img")) {
990 loadMapLayerImgTypeDateDDL(12);
991 $(this).prev().find(".layer_item_loader").show();
992 }
993
994
995 //Weather
996 if ($(this).hasClass("layer_item_weather")) {
997 //add some code in here
998 lyr_cdax_getWeatherDate();
999 }
1000
1001 //Grasshopper plate
1002 if ($(this).hasClass("layer_item_grasshopper_plate")) {
1003 //add some code in here
1004 lyr_grasshopper_getPlateReadings();
1005 }
1006
1007
1008 //Grasshopper image
1009 if ($(this).hasClass("layer_item_grasshopper_img")) {
1010 //add some code in here
1011 lyr_grasshopper_getGHImg();
1012 }
1013
1014
1015 }
1016 //***CDAX||Weather layer||Grasshopper layer** -- end//
1017
1018
1019
1020 //this is a generic layer
1021 if ($(this).hasClass("layer_item_generic")) {
1022 //may clearing of other layers etc
1023
1024 lyr_shp_getGenericLayer($(this).attr("id"));
1025
1026 $(this).addClass("layer_item_selected");
1027
1028 }
1029
1030 //is this a sample results layer
1031 if ($(this).hasClass("layer_item_sample_results")) {
1032
1033
1034 $(this).addClass("layer_item_selected");
1035
1036 //show nutrient panel.
1037 $(".layer_info_sample_nut_items").parent().show();
1038
1039 //check to see if nutrients have already been loaded.
1040 if ($(".sample_nut_items").length == 0) {
1041 $.ajax({
1042 type: "POST",
1043 url: urlPrepend + "/samplenutrientdata/" + getFarmId(),
1044 }).done(function (data) {
1045
1046 $(".layerInfo").each(function () {
1047 if (($(this).is(":visible")) && ($(this).attr("rel") != gen_mode_sub)) {
1048 $(this).hide();
1049 }
1050 else {
1051 $(this).show();
1052 $(".layer_info_sample_nut_items").show();
1053 }
1054 });
1055
1056 $(".layerInfo").each(function () {
1057 if (($(this).attr("rel") == gen_mode_sub)) {
1058
1059 //display nutrients
1060
1061 if (data != "") {
1062 var t = JSON.parse(data);
1063 if (t.nutrients.length > 0) {
1064 for (var i = 0; i < t.nutrients.length; i++) {
1065 if (t.nutrients[i].name != "") {
1066 $(".layer_info_sample_nut_items").append("<li class=\"sample_nut_items\" rel=\"" + t.nutrients[i].id + "\">" + t.nutrients[i].name + "</li>");
1067 }
1068 }
1069 }
1070 }
1071 }
1072 });
1073 });
1074 }
1075
1076 }
1077 //is this a POI layer
1078 if ($(this).hasClass("layer-item-poi")) {
1079 $(this).addClass("layer_item_selected");
1080 //load poi points
1081 lyr_getPOILayer();
1082 loadStatus("Loading Points Of Interest Data");
1083 }
1084 //is this a weather forcasting layer
1085
1086 if ($(this).hasClass("layer-weather-forecast")) {
1087 $(this).addClass("layer_item_selected");
1088 //load weather forcasting points
1089 lyr_getWeatherForcastingLayer();
1090 loadStatus("Loading Weather Station Data");
1091 }
1092
1093 //is this a soil sensor layer
1094 if ($(this).hasClass("layer-soil-sensor")) {
1095 $(this).addClass("layer_item_selected");
1096 //load soil sensor points
1097 lyr_getSoilSensorLayer();
1098 loadStatus("Loading Soil Sensor Data");
1099 }
1100
1101 ////afbi -drone
1102 //if ($(this).hasClass("layer-item-drone")) {
1103 // $(this).addClass("layer_item_selected");
1104 // //load soil sensor points
1105 // lyr_getDroneCalLayer($(this).attr("id"));
1106 // loadStatus("Loading Drone Imagery Data");
1107 //}
1108
1109 }
1110
1111 lyr_lockCheck();
1112 debugger;
1113});
1114
1115//*****************main left side code
1116
1117$(document).on("click", ".left_details_panel_close", function () {
1118
1119
1120 if (fld_drawingManager != undefined) {
1121 fld_drawingManager.setDrawingMode(null);
1122 }
1123
1124
1125 $("#leftDetailsPanel").hide();
1126 //if user is in mode to draw a new field then undo this.
1127
1128 if (gen_mode_sub == 1) {
1129 gen_resetGenericSubMode();
1130 fld_drawingManager.setDrawingMode(null);
1131 //remove any polygons that have been drawn
1132 if (selectedShape!=null) {
1133 selectedShape.setMap(null);
1134
1135 }
1136 //show add field link
1137 $('.add_new_field_item').removeClass("disabledLikeAButton");
1138 }
1139
1140 if (gen_mode_sub == 2 && gen_mode == 1) {
1141 removeSingleFieldSampleData();//field.js
1142 }
1143
1144})
1145
1146//deselecting a field.
1147$(document).on("click", ".field_item_selected", function () {
1148
1149 var attr = $(this).attr('contenteditable');
1150
1151 //check to see if name is still in edit mode
1152 if (typeof attr !== typeof undefined && attr !== false) {
1153 //do nothing as in edit mode and user editing field name
1154 }
1155 else {
1156 //first check if this field has been edited.
1157 if ($("#saveEditedField").is(":visible")) {
1158 //display modal to user.
1159 $("#confirm-boundary-changes").modal('show');
1160 }
1161 else {
1162 $(this).removeClass("field_item_selected").addClass("field_item");
1163 $(this).next().hide();
1164 deselectEditedField($(this).next().attr("rel"));
1165
1166 //pan back to farm view.
1167 panAllFields();
1168 }
1169 }
1170});
1171
1172
1173
1174function clearFieldSampleZones() {
1175 for (var i = 0; i < sr_fieldZonePolygons.length; i++) {
1176 ui2_sr_fieldZonePolygons[i].setMap(null);
1177 ui2_sr_fieldZonePolygonLabels[i].setMap(null);
1178 }
1179
1180 ui2_sr_arrFieldObjects = [];
1181 ui2_sr_fieldZonePolygons = [];
1182 ui2_sr_fieldZonePolygonLabels = [];
1183 ui2_sr_arrFieldObjects = [];
1184}
1185
1186
1187ui2_sr_arrFieldObjects = [];
1188ui2_sr_fieldZonePolygons = [];
1189ui2_sr_fieldZonePolygonLabels = [];
1190
1191
1192
1193function hideLayerInfo(selectedId) {
1194 $(".layerInfo").each(function () {
1195 //debugger;
1196 if ($(this).attr("rel") == selectedId) {
1197 $(this).hide();
1198 }
1199 });
1200}
1201function showLayerInfo(selectedId) {
1202 $(".layerInfo").each(function () {
1203 if ($(this).attr("rel") == selectedId) {
1204 $(this).show();
1205 }
1206 else {
1207 $(this).hide();
1208 }
1209 });
1210}
1211
1212function setLayerListItem(id, name) {
1213 debugger;
1214 switch (id) {
1215 case 1:
1216 return "<li class=\"layer_item layer-item-imagery imagery_layer_nsensor\" rel=\"1\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"1\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"nsensor_cal_options_wrapper\"></div><div class=\"left_panel_calendar n_sensor_cal\"></div></div></li>";
1217 break;
1218 case 2:
1219 // change of MiSAT to NDVI for Birds Eye only
1220 //if ($('#sessionPlatformId').val() === "5") {
1221 // name = "NDVI"
1222 //}
1223 //return "<li class=\"layer_item layer-item-imagery imagery_layer_misat\" rel=\"2\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"2\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"misat_data_loader\"></div><div class=\"misat_cal_options_wrapper\"></div><div class=\"left_panel_calendar misat_cal\"></div></div></li>";
1224 return ""
1225 break;
1226 case 3:
1227 return "<li class=\"layer_item layer-item-imagery imagery_layer_rtk\" rel=\"3\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"3\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"rtk_cal_options_wrapper\"></div><div class=\"left_panel_calendar rtk_cal\"></div></div></li>";
1228 break;
1229 case 4:
1230 return "<li class=\"layer_item layer-item-imagery imagery_layer_uav\" rel=\"4\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"4\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"uav_cal_options_wrapper\"></div><div class=\"left_panel_calendar uav_cal\"></div></div></li>";
1231 break;
1232 case 6:
1233 return "<li class=\"layer_item layer-item-imagery imagery_layer_conductivity\" rel=\"6\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"6\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"conductivity_cal_options_wrapper\"></div><div class=\"left_panel_calendar conductivity_cal\"></div></div></li>";
1234 break;
1235 case 7:
1236 return "<li class=\"layer_item layer-item-imagery imagery_layer_migrass\" rel=\"7\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"7\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"migrass_cal_options_wrapper\"></div><div class=\"left_panel_calendar migrass_cal\"></div></div></li>";
1237 break;
1238 case 8:
1239 //return "<li class=\"layer_item layer-item-imagery imagery_layer_rgb\" rel=\"8\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"8\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"rgb_cal_options_wrapper\"></div><div class=\"left_panel_calendar rgb_cal\"></div></div></li>";
1240 return ""
1241 break;
1242 case 9:
1243 return "<li class=\"layer_item layer-item-imagery imagery_layer_yield\" rel=\"9\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"9\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"yield_cal_options_wrapper\"></div><div class=\"left_panel_calendar yield_cal\"></div></div></li>";
1244 break;
1245 case 10:
1246 return "<li class=\"layer_item layer-item-imagery imagery_layer_sample_results\" rel=\"10\">Soil Sample Results<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"10\"></li>";
1247 break;
1248 case 16:
1249 return "<li class=\"layer_item layer-item-imagery imagery_layer_cvi\" rel=\"16\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"16\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"cvi_data_loader\"></div><div class=\"cvi_cal_options_wrapper\"></div><div class=\"left_panel_calendar cvi_cal\"></div></div></li>";
1250 break;
1251 case 17:
1252 name = "MiSAT";
1253
1254 return "<li class=\"layer_item layer-item-imagery imagery_layer_cigreen\" rel=\"17\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"17\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"satelliteTypesIcons\" id=\"satelliteTypes\"><i class=\"fas fa-seedling satSelectIcons\" id=\"ci_green_icon\"></i><i class=\"fab fa-typo3 satSelectIcons\" id=\"rgb_icon\"></i><i class=\"fas fa-seedling satSelectIcons\" id=\"ndvi_icon\"></i><p id=\"satelliteTypeName\"></p></div><div class=\"cigreen_data_loader\"></div><div class=\"cigreen_cal_options_wrapper\"></div><div class=\"left_panel_calendar cigreen_cal\"></div><div class=\"misat_data_loader\"></div><div class=\"misat_cal_options_wrapper\"></div><div class=\"left_panel_calendar misat_cal\"></div><div class=\"rgb_cal_options_wrapper\"></div><div class=\"left_panel_calendar rgb_cal\"></div></div></li>";
1255 break;
1256 case 20:
1257 return "<li class=\"layer_item layer-item-imagery imagery_layer_variety_view\" rel=\"20\">Variety View<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"20\"><div id=\"leftPanelVarietyList\"></div></li>";
1258 break;
1259 case 109:
1260 return "<li class=\"layer_item layer-weather-forecast\" rel=\"109\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li>";
1261 break;
1262 case 110:
1263 return "<li class=\"layer_item layer-soil-sensor\" rel=\"110\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li>";
1264 break;
1265 //case 97:
1266 // return "<li class=\"layer_item layer-item-imagery imagery_layer_sample_results\" rel=\"97\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"97\"></li>";
1267 // break;
1268 default:
1269
1270 switch (name) {
1271
1272 case "Cropping":
1273
1274 //BirsEye amendment
1275 if ($("#sessionCustomerId").val() != "218") {
1276 return "<li class=\"layer_item layer-item-cropping\" rel=\"" + id + "\" id=\"" + id + "\">Mi" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"><div class=\"layer_info_crop_wrapper\"><div class=\"lyr_crop_key_wrapper\"></div><button id=\"crp_microppingAddToSeason\" class=\"crp_micropping_add_crops_to_season\">Add crops to season</button></div></li>";
1277 }
1278 else {
1279 return "<li class=\"layer_item layer-item-cropping\" rel=\"" + id + "\" id=\"" + id + "\">Mi" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"><div class=\"layer_info_crop_wrapper\"><div class=\"lyr_crop_key_wrapper\"></div><button id=\"crp_microppingAddToSeason\" class=\"crp_micropping_add_crops_to_season\" style=\"display:none\">Add crops to season</button></div></li>";
1280 }
1281
1282 break;
1283 case "Sample Results":
1284 return "<li class=\"layer_item layer_item_sample_results\" rel=\"011\" id=\"" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"011\"><ul class=\"layer_info_sample_nut_items\"><li class=\"layer_info_nutrient_header\">Nutrients</li></ul></li>";
1285 break;
1286 case "C-Dax Pasture Meter":
1287 return "<li class=\"layer_item layer_item_other_dynamic layer_item_cdax_pasture\" rel=\"014\" id=\"" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"></li>";
1288 break;
1289 case "C-Dax Images":
1290 return "<li class=\"layer_item layer_item_other_dynamic layer_item_cdax_pasture_img\" rel=\"012\" id=\"" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"></li>";
1291 break;
1292 case "Weather (Archived)":
1293 return "<li class=\"layer_item layer_item_other_dynamic layer_item_weather\" rel=\"013\" id=\"" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"weather_cal_options_wrapper\"></div><div class=\"left_panel_calendar weather_cal\"></div></div></li>";
1294 break;
1295 case "Grasshopper Plate Meter":
1296 return "<li class=\"layer_item layer_item_other_dynamic layer_item_grasshopper_plate\" rel=\"115\" id=\"" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"></li>";
1297 break;
1298 case "Grasshopper Images":
1299 return "<li class=\"layer_item layer_item_other_dynamic layer_item_grasshopper_img\" rel=\"116\" id=\"" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"weather_cal_options_wrapper\"></div><div class=\"left_panel_calendar weather_cal\"></div></div></li>";
1300 break;
1301 case "Trackers":
1302 return "<li class=\"layer_item layer-item-tracker\" rel=\"tracker_" + id + "\" id=\"tracker_" + id + "\">Mi" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"tracker_" + id + "\"><div class=\"layer_info_tracker_wrapper\"></div></li>";
1303 break;
1304 case "Harvest Map":
1305 return "<li class=\"layer_item layer-item-harvest-dates\" rel=\"harvest-dates_" + id + "\" id=\"harvest-dates_" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"harvest-dates_" + id + "\"></li>";
1306 break;
1307 case "Harvest Areas":
1308 return "<li class=\"layer_item layer-item-harvest-areas\" rel=\"harvest-areas_" + id + "\" id=\"harvest-areas_" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"><li class=\"layerInfo\" rel=\"harvest-areas_" + id + "\"><div class=\"lyr_harvest_area_info_wrapper\"><div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div><div class=\"lyr_lock_txt\">Lock this layer</div></div></div></li>";
1309 break;
1310 case "True Harvested Areas":
1311 return "<li class=\"layer_item layer-item-true_harvested-areas\" rel=\"true_harvested-areas_" + id + "\" id=\"true_harvested-areas_" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"><li class=\"layerInfo\" rel=\"true_harvested-areas_" + id + "\"><div class=\"lyr_true_harvested_area_info_wrapper\"></div></li>";
1312 break;
1313 case "Points Of Interest":
1314 return "<li class=\"layer_item layer-item-poi\" rel=\"poi_" + id + "\" id=\"poi_" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li>";
1315 break;
1316 //case "Drone Imagery":
1317 // return "<li class=\"layer_item layer-item-drone\" rel=\"drone_" + id + "\" id=\"drone_" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"><div class=\"left_panel_drone drone_cal\"></div></li>";
1318 // break;
1319 default:
1320 return "<li class=\"layer_item layer_item_generic\" rel=\"" + id + "\" id=\"" + id + "\">" + name + "<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li><li class=\"layerInfo\" rel=\"" + id + "\"></li>";
1321 }
1322
1323
1324
1325
1326 }
1327}
1328function displayLeftDetailsPanel(show) {
1329 if (!show) {
1330 $("#leftDetailsPanel").hide();
1331 }
1332 else {
1333 $("#leftDetailsPanel").show();
1334 }
1335 $(".left_details_panel_content").empty();
1336}
1337function setFieldPanelList() {
1338
1339 $('.add_new_field_item').removeClass("disabledLikeAButton");
1340 displayLeftDetailsPanel(false);
1341 chkUserAddingField();
1342
1343 if ($(".field_list_title").find('span').hasClass("glyphicon-menu-up")) {
1344 $(".field_list_items").slideUp()
1345 $(".field_list_title span").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
1346
1347 //reset mode
1348 gen_resetGenericMode();
1349 }
1350 else {
1351 $(".field_list_items").slideDown()
1352 $(".field_list_title span").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up");
1353
1354 //set global vars
1355 gen_setGlobalMode(1);
1356
1357 for (var i = 0; i < polygonsArray.length; i++) {
1358 //enable click of all polygon fields as they might have been disabled - i.e. afbi.
1359 polygonsArray[i].setOptions({
1360 clickable: true
1361 })
1362 }
1363
1364 }
1365
1366
1367}
1368
1369function setFormListPanel() {
1370 if ($(".form_list_title").find('span').hasClass("glyphicon-menu-up")) {
1371 $(".form_list_items").slideUp()
1372 $(".form_list_title span").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
1373
1374 //reset mode
1375 gen_resetGenericMode();
1376 }
1377 else {
1378 $(".form_list_items").slideDown();
1379 $(".form_list_title span").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up");
1380 }
1381
1382}
1383
1384function setLayerListPanel() {
1385
1386 if ($(".layer_list_title").find('span').hasClass("glyphicon-menu-up")) {
1387 $(".layer_list_items").slideUp()
1388 $(".layer_list_title span").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
1389
1390
1391 //reset mode
1392 gen_resetGenericMode();
1393 }
1394 else {
1395
1396 if ($(".layer_item").length == 0 && $(".layer_list_loader").length == 0) {
1397 //we need to get data
1398 //add loader
1399 $(".layer_list_items").append("<li class=\"layer_list_loader\"><img src=\"" + urlPrepend + "/Content/images/ajax-loader.gif\" /></li>").show();
1400
1401 //reset nvz bool so it can be inserted into the Milayers list
1402 lyr_insert_NVZ_bool = true;
1403
1404 $.ajax({
1405 type: "GET",
1406 url: urlPrepend + "/layerdata/ui_data-layers_" + getTradingId() + "_" + getFarmId(),
1407 }).done(function (data) {
1408
1409 var t = JSON.parse(data);
1410 var strTemp = "";
1411 var arrHoldingDupCheckTemp = [];
1412
1413
1414 if (t.length > 0) {
1415
1416 //mapofag url checker
1417 if ($("#authPage").length > 0) {
1418 var url_ampofag = window.location.href;
1419 var url_urlCheckerArr = url_ampofag.split('&');
1420
1421 if (url_urlCheckerArr.length == 3) {
1422 var url_lyrType = url_urlCheckerArr[2].split('=')[1];
1423
1424 if (url_lyrType == "migrass") {
1425 setTimeout(function () {
1426 loadMapLayerImgTypeDateDDL(7);
1427 }, 4000);
1428 setTimeout(function () {
1429 mapOfAg_loadMigrass();//in auth page
1430 }, 6000);
1431 }
1432 }
1433
1434 }
1435
1436
1437 for (var i = 0; i < t.length; i++) {
1438 var isDup = false;
1439 for (var j = 0; j < arrHoldingDupCheckTemp.length; j++) {
1440 if (arrHoldingDupCheckTemp[j] == t[i].id) {
1441 isDup = true;
1442 }
1443 }
1444
1445 if (!isDup) {
1446 debugger;
1447 strTemp += setLayerListItem(t[i].id, t[i].name);
1448 arrHoldingDupCheckTemp.push(t[i].id);
1449 }
1450
1451 }
1452
1453 setTimeout(function () {
1454 debugger;
1455 gen_setGlobalMode(2);
1456 $(".layer_list_items").empty().append(strTemp).slideDown();
1457 $(".layer_list_title span").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up");
1458
1459 //reorder list alphabetically
1460 NVZlayer();
1461 }, 1500);
1462
1463
1464 }
1465 else {
1466 //insert nvz layer
1467 $(".layer_list_items").empty();
1468 NVZlayer();
1469 }
1470
1471
1472 });
1473 }
1474 else {
1475 $(".layer_list_items").slideDown();
1476 $(".layer_list_title span").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up");
1477 }
1478 }
1479}
1480
1481function NVZlayer() {
1482
1483 if (lyr_insert_NVZ_bool) {
1484 var nvzEle = "<li class=\"layer_item layer-item-imagery imagery_layer_nvz\" rel=\"000\">NVZ<img src=\"" + urlPrepend + "/content/images/ajax-loader-trans-green.gif\" class=\"layer_item_loader\"></li>";
1485
1486 $(".layer_list_items").children().each(function () {
1487 if ($(this).text() > "NVZ"){
1488 $(nvzEle).insertBefore($(this));
1489 lyr_insert_NVZ_bool = false;
1490 return false;
1491 }
1492 });
1493
1494 if (lyr_insert_NVZ_bool) {
1495 //nvz has still not been inserted.
1496 $(nvzEle).appendTo(".layer_list_items");
1497 }
1498
1499 lyr_insert_NVZ_bool = false;
1500 }
1501
1502}
1503
1504
1505function deselectEditedField(id) {
1506
1507 for (var i = 0; i < polygonsArray.length; i++) {
1508 if (polygonsArray[i].get("id") == id) {
1509 lyr_shp_resetPolyObj(polygonsArray[i]);
1510 }
1511 }
1512}
1513
1514
1515//clearing data functions
1516
1517function resetLayersPanel() {
1518 debugger;
1519 resetSubPanels(gen_mode_sub);
1520 //**disabled due to new header bar
1521 crp_clearCropPolygons()
1522 crp_clear_farm_wide_crops();
1523 //**disabled due to new header bar -- end
1524 //hide generic layers on map
1525 lyr_generic_reset_overlay();
1526 //hide generic layers on map -- end
1527 lyr_sample_results_clearOverlays();
1528 //hide harvest shape areas
1529 lyr_clear_HarvestAreas();
1530 //hide true harvest areas
1531 lyr_clear_True_HarvestAreas();
1532 lyr_reestMilayers();
1533}
1534
1535function lyr_reestMilayers() {
1536 debugger;
1537 $(".layerInfo").each(function () {
1538 $(this).children().hide();
1539 });
1540 $(".layer_item").each(function () {
1541 if ($(this).hasClass("layer_item_selected")) {
1542 $(this).removeClass("layer_item_selected");
1543 }
1544 });
1545}
1546
1547
1548function lyr_isLayerLocked(subMode) {
1549 debugger;
1550 var bLyrLocked = false;
1551 $(".layerInfo ").each(function () {
1552 if (($(this).hasClass("lyr_locked")) && ($(this).attr("rel") == subMode)) {
1553 bLyrLocked = true;
1554 }
1555 });
1556 debugger;
1557 return bLyrLocked;
1558}
1559
1560function resetSubPanels(sub_mode) {
1561
1562 switch (sub_mode) {
1563 case "1":
1564 ////reset n-sensor panel;
1565 //$(".imagery_layer_nsensor").removeClass("layer_item_selected");
1566 hideLayerInfo("1");
1567 img_clearOverlay();
1568 //reset legend
1569 displayLeftDetailsPanel(false);
1570 break;
1571 case "2":
1572 ////reset misat panel;
1573 // $(".imagery_layer_misat").removeClass("layer_item_selected");
1574 hideLayerInfo("2");
1575 //has this layer been locked?
1576 if (!lyr_isLayerLocked(2)) {
1577 img_clearOverlay();
1578 }
1579 //reset legend
1580 displayLeftDetailsPanel(false);
1581
1582 break;
1583 case "6":
1584 //reset conductivity panel;
1585 // $(".imagery_layer_conductivity").removeClass("layer_item_selected");
1586 hideLayerInfo("6");
1587 img_clearOverlay();
1588 //reset legend
1589 displayLeftDetailsPanel(false);
1590 break;
1591 case "7":
1592 ////reset migrass panel;
1593 //$(".imagery_layer_migrass").removeClass("layer_item_selected");
1594 hideLayerInfo("7");
1595 displayLeftDetailsPanel(false);
1596 img_clearOverlay();
1597 break;
1598 case "8":
1599 ////reset rgb panel;
1600 //$(".imagery_layer_rgb").removeClass("layer_item_selected");
1601 hideLayerInfo("8");
1602 displayLeftDetailsPanel(false);
1603 img_clearOverlay();
1604 break;
1605 case "9":
1606 ////reset yield panel;
1607 //$(".imagery_layer_yield").removeClass("layer_item_selected");
1608 hideLayerInfo("9");
1609 displayLeftDetailsPanel(false);
1610 img_clearOverlay();
1611 break;
1612 case "12":
1613 ////reset c-dex img panel;
1614 //$(".layer_item_cdax_pasture_img").removeClass("layer_item_selected");
1615 var layerId = $(".layer_item_cdax_pasture_img").attr("id");
1616 hideLayerInfo(layerId);
1617 displayLeftDetailsPanel(false);
1618 img_clearOverlay();
1619 break;
1620 case "16":
1621 ////reset cigreen panel;
1622 hideLayerInfo(16);
1623 displayLeftDetailsPanel(false);
1624 img_clearOverlay();
1625 break;
1626 case "17":
1627 ////reset cigreen panel;
1628
1629 hideLayerInfo(17);
1630 displayLeftDetailsPanel(false);
1631 debugger;
1632 //has this layer been locked?
1633 if (!lyr_isLayerLocked(17)) {
1634 debugger;
1635 $(".lyr_highlight_locked_item").removeClass("lyr_highlight_locked_item");
1636 $(".lyr_locked_icon").removeClass("icon-noun_Lock_747565 lyr_lock_red").addClass("icon-noun_Unlock_821902");
1637 $(".lyr_lock_txt").empty().html("Lock this layer");
1638 $(".lyr_lock").removeClass("locked");
1639 $('.lyr_locked:visible').removeClass('lyr_locked')
1640
1641 $(".layerInfo ").each(function () {
1642 if ($(this).hasClass("lyr_locked")) {
1643 $(this).removeClass("lyr_locked")
1644 }
1645 });
1646
1647 $('.lyr_lock').hide();
1648 img_clearOverlay();
1649 }
1650 break;
1651 case "19":
1652 ////reset cigreen field view panel;
1653
1654 hideLayerInfo(17); //<-- default farm view id = 17
1655 displayLeftDetailsPanel(false);
1656 //has this layer been locked?
1657 if (!lyr_isLayerLocked(19)) {
1658 img_clearOverlay();
1659 }
1660 break;
1661 case "20":
1662 ////reset variety view;
1663 displayLeftDetailsPanel(false);
1664 img_clearOverlay();
1665 $("#leftPanelVarietyList").empty().hide();
1666
1667 break;
1668 case "014":
1669 ////reset c-dex img panel;
1670 //$(".layer_item_cdax_pasture_img").removeClass("layer_item_selected");
1671 var layerId = $(".layer_item_cdax_pasture_img").attr("id");
1672 hideLayerInfo(layerId);
1673 displayLeftDetailsPanel(false);
1674 img_clearOverlay();
1675 break;
1676 case "015":
1677 var layerId = $(".layer_item_grasshopper_plate").attr("id");
1678 hideLayerInfo(layerId);
1679 displayLeftDetailsPanel(false);
1680 img_clearOverlay();
1681 break;
1682 default:
1683 //check to see if we need to reset cropping
1684 if ($(".layer_info_crop_wrapper").is(":visible")) {
1685
1686 crp_clearCropPolygons()
1687 crp_clear_farm_wide_crops();
1688 lyr_cdax_clearPastureData();
1689 lyr_clearWeatherData();
1690 }
1691
1692 //check to see if its generic
1693
1694 //check to see if its a tracker
1695 var miTrackerRegEx = new RegExp("tracker\_(\\d)+");
1696 var miTrackerRegExRes = miTrackerRegEx.test(sub_mode);
1697 if (miTrackerRegExRes) {
1698 //hide and stop tracker data
1699 lyr_hideTrackers();
1700 lyr_tracker_loop = false;
1701 $(".layer-item-tracker").find(".layer_item_loader").hide();
1702 }
1703
1704 //check to see if its a harvest date
1705 var miHarvestDateRegEx = new RegExp("harvest-dates\_(\\d)+");
1706 var miHarvestDateRegExRes = miHarvestDateRegEx.test(sub_mode);
1707 if (miHarvestDateRegExRes) {
1708 //hide and stop tracker data
1709 lyr_hideHarvestDatesLayer();
1710 $(".layer-item-harvest-dates").find(".layer_item_loader").hide();
1711 }
1712
1713 break;
1714 }
1715
1716}
1717
1718//***************** sample results ******************************************************
1719
1720
1721
1722$(document).on("click", ".lyr_sample_service", function () {
1723
1724 lyr_sample_results_clearOverlays();
1725 displayLeftDetailsPanel(false);
1726
1727 var orderId = $(this).attr("id").split('|')[1];
1728 var nutrientId = $(this).attr("id").split('|')[0];
1729
1730
1731 if ($('.lyr_sample_service_nutrient_wrapper').children().length > 0) {
1732 //reset and get rid nutrients
1733 $(".lyr_sample_service_nutrient").each(function () {
1734 $(this).remove();
1735 });
1736
1737 }
1738 $.ajax({
1739 type: "POST",
1740 url: urlPrepend + "/sampledata/nutrients",
1741 data: { groupid: orderId },
1742 }).done(function (data) {
1743
1744 if (data.length > 0) {
1745
1746 //clear any nutrient panels that are open
1747 $(".lyr_sample_service_nutrient_wrapper").each(function () {
1748 $(this).empty();
1749 });
1750
1751
1752 var nutStr = "";
1753 for (var i = 0; i < data.length; i++) {
1754
1755 nutStr += "<li class=\"lyr_sample_service_nutrient\" title=\"" + data[i].longName + "\" rel=\"" + data[i].nutrientId + "\">" + data[i].displayName + "</li>"
1756 }
1757
1758 $(".lyr_sample_service_nutrient_wrapper").each(function () {
1759
1760 if ($(this).attr("rel") == orderId) {
1761 $(this).empty().html(nutStr);
1762 nutStr = "";
1763 }
1764
1765 });
1766 }
1767 }).fail(function () {
1768 $(".lyr_sample_service_nutrient_wrapper").each(function () {
1769 if ($(this).attr("rel") == orderId) {
1770 $(this).empty().html("<li>No nutrients to list</li>");
1771 }
1772 nutStr = "";
1773 });
1774
1775 });;
1776
1777});
1778
1779function lyr_sample_results_clearOverlays() {
1780
1781 for (var i = 0; i < lyr_sample_results_zone_values_overlay.length; i++) {
1782 lyr_sample_results_zone_values_overlay[i].setMap(null);
1783 }
1784 lyr_sample_results_zone_values_overlay = [];
1785
1786 for (var j = 0; j < lyr_sample_results_polygon_overlay_temp_customer_overlay.length; j++) {
1787 lyr_sample_results_polygon_overlay_temp_customer_overlay[j].setMap(null);
1788 }
1789 lyr_sample_results_polygon_overlay_temp_customer_overlay = [];
1790
1791 for (var i = 0; i < lyr_sample_results_im_polygon_overlay.length; i++) {
1792
1793 lyr_sample_results_im_polygon_overlay[i].overlay.setMap(null);
1794 }
1795 lyr_sample_results_im_polygon_overlay = [];
1796
1797 for (var m = 0; m < lyr_sample_results_polygon_field_boundary_overlay.length; m++) {
1798 lyr_sample_results_polygon_field_boundary_overlay[m].setMap(null);
1799 }
1800 lyr_sample_results_polygon_field_boundary_overlay = [];
1801
1802
1803
1804
1805 var bLyrLocked = false;
1806 $(".layerInfo ").each(function () {
1807 if ($(this).hasClass("lyr_locked")) {
1808 bLyrLocked = true;
1809 }
1810 });
1811
1812
1813 if (!bLyrLocked) {
1814 //we have no locked layers, so display all field polygons
1815 //display field polys again
1816 for (var i = 0; i < polygonsArray.length; i++) {
1817 if (polygonsArray[i].getMap() == null)
1818 {
1819 polygonsArray[i].setMap(map);
1820 }
1821 }
1822 }
1823}
1824
1825
1826function lyr_formatZoneValue(result) {
1827
1828 if (result.indexOf(".") > 0) {
1829 return result
1830 }
1831 else {
1832 if (result.length == 1) {
1833 return result + ".0";
1834 }
1835 }
1836 return result;
1837}
1838
1839function lyr_sample_results_getZoneResultValues(orderId, nutrientId) {
1840
1841 $.ajax({
1842 url: urlPrepend + "/layerdata/ui_data-layers_sample_result_zones_" + orderId + "_" + nutrientId
1843 }).done(function (data) {
1844
1845 //var sampleResultsLayerMapModalBounds = new google.maps.LatLngBounds();
1846
1847 for (var i = 0; i < data.length; i++) {
1848
1849 infowindow = new google.maps.InfoWindow();
1850
1851 var label = new InfoBox({
1852 content: lyr_formatZoneValue(data[i].result),
1853 boxStyle: {
1854 border: "1px solid black",
1855 textAlign: "center",
1856 backgroundColor: "white",
1857 fontSize: "8pt",
1858 padding: "0",
1859 whiteSpace: "nowrap",
1860 width: "35px",
1861 overflow: "hidden",
1862 textOverflow: "ellipsis"
1863 },
1864 disableAutoPan: true,
1865 position: new google.maps.LatLng(data[i].lat, data[i].lng),
1866 closeBoxURL: "",
1867 enableEventPropagation: true,
1868 });
1869 label.open(map)
1870 lyr_sample_results_zone_values_overlay.push(label);
1871
1872 if (i == data.length - 1) {
1873 sr_sampleResultsOverlaysLoaded = true;
1874 }
1875
1876
1877
1878 // sampleResultsLayerMapModalBounds.extend(new google.maps.LatLng(data[i].lat, data[i].lng));
1879
1880 }
1881 // //disabled
1882 // // map.fitBounds(sampleResultsLayerMapModalBounds);
1883
1884
1885 });
1886
1887}
1888
1889
1890
1891function lyr_sample_service_zone_data(fieldId, orderId, thisImagePath, count, totalCount) {
1892
1893 $.ajax({
1894 type: "POST",
1895 url: urlPrepend + "/layerdata/ui_data-layers_sample_result_zones_coords",
1896 data: { fieldId: fieldId, grpOrderId: orderId }
1897 }).done(function (data) {
1898 if (data.length > 0) {
1899
1900 var overlayBoundary = new google.maps.MVCArray();
1901 for (var i = 0; i < data.length; i++) {
1902 overlayBoundary.push(new google.maps.LatLng(data[i].lat, data[i].lng));
1903 }
1904
1905 urlImg = "https://api.mi.farm/static/images/soil/" + thisImagePath;
1906
1907 //create new overlay
1908 var options = {
1909 path: overlayBoundary,
1910 strokeColor: "#222",
1911 strokeOpacity: 1,
1912 strokeWeight: 0,
1913 fillOpacity: 0.0,
1914 zIndex: 9,
1915 id: fieldId
1916 }
1917
1918 var polygon2 = new google.maps.Polygon(options);
1919 lyr_sample_results_polygon_overlay_temp_customer_overlay.push(polygon2);
1920 polygon2.setMap(map); //*****
1921
1922 addPolygonMouseCoordsData(polygon2);
1923
1924 //get bounds from polygon for custom overlay
1925 if (!google.maps.Polygon.prototype.getBounds)
1926 google.maps.Polygon.prototype.getBounds = function () {
1927 var bounds = new google.maps.LatLngBounds();
1928 var paths = this.getPaths();
1929 for (var i = 0; i < paths.getLength() ; i++) {
1930 var path = paths.getAt(i);
1931 for (var j = 0; j < path.getLength() ; j++) {
1932 bounds.extend(path.getAt(j));
1933 }
1934 }
1935 return bounds;
1936 }
1937
1938 var objOverlay = {};
1939
1940 var myOverlay = new google.maps.GroundOverlay(urlImg, polygon2.getBounds(), { clickable: false });
1941 objOverlay.overlay = myOverlay;
1942 //objOverlay.id = thisFieldId;
1943 //objOverlay.nutrientId = nutrientId;
1944 //objOverlay.legend = thisLegend;
1945
1946 lyr_sample_results_im_polygon_overlay.push(objOverlay);
1947
1948 myOverlay.setMap(map);
1949
1950 addPolygonMouseCoordsData(myOverlay);
1951
1952 //dislay drawn field boundary when showing results - removed - requested by craig
1953 for (var j = 0; j < polygonsArray.length; j++) {
1954 if (fieldId == polygonsArray[j].id) {
1955 polygonsArray[j].setMap(null);
1956 }
1957 }
1958
1959
1960
1961 } else {
1962
1963 //loop through field polygons to get points for overlay bounds polygon
1964 tempFieldId = data[i].fieldId;
1965 for (var j = 0; j < polygonsArray.length; j++) {
1966 if (tempFieldId == polygonsArray[j].id) {
1967 var overlayBoundary = new google.maps.MVCArray();
1968 for (var k = 0; k < polygonsArray[j].getPath().getLength() ; k++) {
1969 overlayBoundary.push(new google.maps.LatLng(polygonsArray[j].getPath().getAt(k).lat(), polygonsArray[j].getPath().getAt(k).lng()));
1970 //for map bounds
1971 var coords = polygonsArray[j].getPath().getAt(k);
1972 // latlngbounds.extend(coords);
1973 }
1974
1975 // drawOverlay(overlayBoundary, tempFieldId, objArr[i].image, type, objArr[i].legend, objArr[i].dateperformed, objArr[i].fieldName, objArr[i].crop, false);
1976
1977 urlImg = "https://api.mi.farm/static/images/soil/" + data[i].imagePath;
1978 //create new overlay
1979 var options = {
1980 path: overlayBoundary,
1981 strokeColor: "#222",
1982 strokeOpacity: 1,
1983 strokeWeight: 0,
1984 fillOpacity: 0.0,
1985 zIndex: 9,
1986 id: tempFieldId
1987 }
1988
1989
1990 var polygon = new google.maps.Polygon(options);
1991 lyr_sample_results_polygon_overlay_temp_customer_overlay.push(polygon);
1992 polygon.setMap(map); //*****
1993
1994 addPolygonMouseCoordsData(polygon);
1995
1996 //get bounds from polygon for custom overlay
1997 if (!google.maps.Polygon.prototype.getBounds)
1998 google.maps.Polygon.prototype.getBounds = function () {
1999 var bounds = new google.maps.LatLngBounds();
2000 var paths = this.getPaths();
2001 for (var i = 0; i < paths.getLength() ; i++) {
2002 var path = paths.getAt(i);
2003 for (var j = 0; j < path.getLength() ; j++) {
2004 bounds.extend(path.getAt(j));
2005 }
2006 }
2007 return bounds;
2008 }
2009
2010 var objOverlay = {};
2011 var myOverlay = new google.maps.GroundOverlay(urlImg, polygon.getBounds(), { clickable: false });
2012 objOverlay.overlay = myOverlay;
2013 objOverlay.id = data[i].fieldId;
2014 objOverlay.nutrientId = nutrientId;
2015 objOverlay.legend = data[i].legend;
2016
2017 lyr_sample_results_im_polygon_overlay.push(objOverlay);
2018
2019 myOverlay.setMap(map);
2020
2021 addPolygonMouseCoordsData(myOverlay);
2022
2023 polygonsArray[j].setMap(null);
2024
2025
2026 }
2027 }
2028
2029 }
2030 }).fail(function () {
2031
2032 //loop through field polygons to get points for overlay bounds polygon
2033 tempFieldId = data[i].fieldId;
2034 for (var j = 0; j < polygonsArray.length; j++) {
2035 if (tempFieldId == polygonsArray[j].id) {
2036 var overlayBoundary = new google.maps.MVCArray();
2037 for (var k = 0; k < polygonsArray[j].getPath().getLength() ; k++) {
2038 overlayBoundary.push(new google.maps.LatLng(polygonsArray[j].getPath().getAt(k).lat(), polygonsArray[j].getPath().getAt(k).lng()));
2039 //for map bounds
2040 var coords = polygonsArray[j].getPath().getAt(k);
2041 // latlngbounds.extend(coords);
2042 }
2043
2044 // drawOverlay(overlayBoundary, tempFieldId, objArr[i].image, type, objArr[i].legend, objArr[i].dateperformed, objArr[i].fieldName, objArr[i].crop, false);
2045
2046 urlImg = "https://api.mi.farm/static/images/soil/" + data[i].imagePath;
2047 //create new overlay
2048 var options = {
2049 path: overlayBoundary,
2050 strokeColor: "#222",
2051 strokeOpacity: 1,
2052 strokeWeight: 1,
2053 fillOpacity: 0.0,
2054 zIndex: 9,
2055 id: tempFieldId
2056 }
2057
2058
2059 var polygon = new google.maps.Polygon(options);
2060 lyr_sample_results_polygon_overlay_temp_customer_overlay.push(polygon);
2061 polygon.setMap(map); //*****
2062
2063 addPolygonMouseCoordsData(polygon);
2064
2065 //get bounds from polygon for custom overlay
2066 if (!google.maps.Polygon.prototype.getBounds)
2067 google.maps.Polygon.prototype.getBounds = function () {
2068 var bounds = new google.maps.LatLngBounds();
2069 var paths = this.getPaths();
2070 for (var i = 0; i < paths.getLength() ; i++) {
2071 var path = paths.getAt(i);
2072 for (var j = 0; j < path.getLength() ; j++) {
2073 bounds.extend(path.getAt(j));
2074 }
2075 }
2076 return bounds;
2077 }
2078
2079 var objOverlay = {};
2080 var myOverlay = new google.maps.GroundOverlay(urlImg, polygon.getBounds(), { clickable: false });
2081 objOverlay.overlay = myOverlay;
2082 objOverlay.id = data[i].fieldId;
2083 objOverlay.nutrientId = nutrientId;
2084 objOverlay.legend = data[i].legend;
2085
2086 lyr_sample_results_im_polygon_overlay.push(objOverlay);
2087
2088 myOverlay.setMap(map);
2089
2090 addPolygonMouseCoordsData(myOverlay);
2091
2092 polygonsArray[j].setMap(null);
2093
2094 }
2095 }
2096
2097 });
2098
2099 if (count == totalCount-1) {
2100 sr_sampleResultsZoneValuesLoaded = true;
2101 }
2102
2103}
2104
2105
2106var sr_sampleResultsZoneValuesLoaded = false;
2107var sr_sampleResultsOverlaysLoaded = false;
2108var sr_sampleResultsTimer;
2109function checkSampleDataHasLoaded() {
2110 clearTimeout(sr_sampleResultsTimer);
2111 if ((sr_sampleResultsZoneValuesLoaded) && (sr_sampleResultsOverlaysLoaded)) {
2112 removeStatus();
2113 sr_sampleResultsOverlaysLoaded = false;
2114 sr_sampleResultsZoneValuesLoaded = false;
2115
2116 }
2117 else {
2118 sr_sampleResultsTimer = setTimeout(function () { checkSampleDataHasLoaded(); }, 2000)
2119 }
2120}
2121
2122function sr_reset_selected_nutrients(){
2123 $(".lyr_sample_service_nutrient").each(function () {
2124 $(this).removeClass("lyr_sample_service_nutrient_selected");
2125 });
2126}
2127
2128
2129$(document).on("click", ".lyr_sample_service_nutrient", function () {
2130
2131 lyr_sample_results_clearOverlays();
2132 checkSampleDataHasLoaded();
2133 sr_reset_selected_nutrients();
2134 lyr_sample_results_im_polygon_overlay = [];
2135 var orderId = $(this).parent().attr("rel");
2136 var nutrientId = $(this).attr("rel");
2137 $(this).addClass("lyr_sample_service_nutrient_selected")
2138 loadStatus("Loading Sample Results Data");
2139
2140 $.ajax({
2141 url: urlPrepend + "/layerdata/ui_data-layers_sample_results_" + orderId + "_" + nutrientId
2142 }).done(function (data) {
2143
2144 if (data.length > 0) {
2145
2146 lyr_sample_results_getZoneResultValues(orderId, nutrientId);
2147
2148 for (var i = 0; i < data.length; i++) {
2149 if (i == 0) {
2150 displayLeftDetailsPanel(true);
2151 $(".left_details_panel_content").empty().html("<div class=\"imagery_layer_legend\"><p>" + data[i].displayName + "</p><img src=\"https://portal.precisiondecisions.co.uk/MiFarm/Content/images/nutrient-scale/" + data[i].legend + "\" /></div>");
2152 }
2153
2154 //ajax call to get lat lng for bounding box.
2155 var thisImagePath = data[i].imagePath;
2156 var thisFieldId = data[i].fieldId;
2157 var thisLegend = data[i].legend;
2158
2159 lyr_sample_service_zone_data(data[i].fieldId, orderId, thisImagePath, i, data.length)
2160 checkSampleDataHasLoaded();
2161
2162 }
2163 }
2164 else {
2165 displayErrMsg("No results were returned for this nutrient.");
2166 removeStatus();
2167 }
2168 });
2169});
2170
2171
2172//***************** sample results END ******************************************************
2173
2174
2175/*forms*/
2176$(document).on("click", ".form_item", function () {
2177
2178
2179 if ($(this).hasClass("form_item_selected")) {
2180
2181 //close the form which is open.
2182 if ($(this).hasClass("satelite_assessment_form")) {
2183 $(".form_satelite_assessment_tool").hide();
2184 resetSateliteFormPanel();
2185 }
2186
2187 if ($(this).hasClass("sample_service_order_form")) {
2188 $(".form_sample_service").hide();
2189
2190 //reset form
2191 resetServiceFormPanel();
2192
2193 //date todays date in box
2194 var now = new Date();
2195
2196 var day = ("0" + now.getDate()).slice(-2);
2197 var month = ("0" + (now.getMonth() + 1)).slice(-2);
2198 var today = (day) + "/" + (month) + "/" + now.getFullYear();
2199 $('#fvatHistoricalDatePicker').val(today);
2200 }
2201
2202 $(this).removeClass("form_item_selected")
2203 }
2204 else {
2205
2206
2207 $(".form_item").each(function () {
2208 $(this).removeClass("form_item_selected");
2209 });
2210 $(".form_item_wrapper").each(function () {
2211 $(this).hide();
2212 });
2213
2214
2215 // $(".form_sample_service").hide();
2216 // $(".form_satelite_assessment_tool").hide();
2217 $(this).addClass("form_item_selected");
2218 if ($(this).hasClass("sample_service_order_form")) {
2219 $(".form_sample_service").show();
2220
2221
2222 //reset form
2223 // resetServiceFormPanel();
2224 }
2225 if ($(this).hasClass("satelite_assessment_form")) {
2226 $(".form_satelite_assessment_tool").show();
2227 resetSateliteFormPanel();
2228 //date todays date in box
2229 var now = new Date();
2230
2231 var day = ("0" + now.getDate()).slice(-2);
2232 var month = ("0" + (now.getMonth() + 1)).slice(-2);
2233 var today = (day) + "/" + (month) + "/" + now.getFullYear();
2234 $('#fvatHistoricalDatePicker').val(today);
2235 }
2236 }
2237
2238
2239});
2240
2241function resetSateliteFormPanel() {
2242 $("#fieldVariabilityList").val("0");
2243 $("#fvatHistoricalDatePicker").val("");
2244 $(".field_var_terms_cond").prop('checked', false);
2245}
2246
2247
2248var lyr_compare_stackedOverlay1;
2249var lyr_compare_stackedOverlay2;
2250var lyr_compare_stackedOverlay3;
2251var lyr_compare_stackedOverlay4;
2252var lyr_compare_polygon2a;
2253var lyr_compare_polygon2b;
2254var lyr_compare_polygon3a;
2255var lyr_compare_polygon4a;
2256var lyr_compare_map_sliders = new google.maps.Map(document.getElementById('windowMap_5a_1'),
2257 {
2258 streetViewControl: false,
2259 draggable: false,
2260 scrollwheel: false,
2261 disableDoubleClickZoom: false,
2262 disableDefaultUI: true,
2263 zoomControl: false,
2264 mapTypeId: google.maps.MapTypeId.SATELLITE
2265 });
2266
2267
2268
2269function lyr_compare_countItems() {
2270 var arr = [];
2271
2272 $(".lyr_compare_drag_slider_wrapper").each(function () {
2273 if ($(this).is(":visible")) {
2274 arr.push($(this).attr("rel") + "|" + $(this).children(0).attr("rel"));
2275 }
2276 });
2277
2278
2279 if (arr.length == 2) {
2280
2281 lyr_compare_stackedOverlay4.setMap(null);
2282 lyr_compare_stackedOverlay3.setMap(null);
2283
2284 //unbind slide
2285 $("#slider4").slider("option", "slide", "");
2286 $("#slider3").slider("option", "slide", "");
2287
2288 for (var i = arr.length-1; i >= 0; i--) {
2289
2290 if (i == 0) {
2291 $("#slider3").attr("id", "slider4");
2292 $("#sliderTempId").attr("id", "slider3");
2293 lyr_compare_stackedOverlay3.set('url', arr[i].split('|')[1]);
2294 lyr_compare_stackedOverlay3.setMap(lyr_compare_map_sliders);
2295 lyr_compare_stackedOpacityOverlay(4, 1);
2296 }
2297 if (i == 1) {
2298 $("#slider4").attr("id", "sliderTempId");
2299 lyr_compare_stackedOverlay4.set('url', arr[i].split('|')[1]);
2300 lyr_compare_stackedOverlay4.setMap(lyr_compare_map_sliders);
2301 lyr_compare_stackedOpacityOverlay(3, 1);
2302 }
2303 }
2304
2305 lyr_comp_bind2Slider(2);
2306 }
2307
2308
2309 if (arr.length == 3) {
2310
2311 lyr_compare_stackedOverlay4.setMap(null);
2312 lyr_compare_stackedOverlay3.setMap(null);
2313 lyr_compare_stackedOverlay2.setMap(null);
2314
2315 //unbind slide
2316 $("#slider4").slider("option", "slide", "");
2317 $("#slider3").slider("option", "slide", "");
2318
2319 for (var i = arr.length - 1; i >= 0; i--) {
2320
2321 if (i == 0) {
2322 $("#slider3").attr("id", "slider4");
2323 $("#sliderTempId").attr("id", "slider3");
2324 lyr_compare_stackedOverlay3.set('url', arr[i].split('|')[1]);
2325 lyr_compare_stackedOverlay3.setMap(lyr_compare_map_sliders);
2326 }
2327 if (i == 1) {
2328 $("#slider4").attr("id", "sliderTempId");
2329 lyr_compare_stackedOverlay4.set('url', arr[i].split('|')[1]);
2330 lyr_compare_stackedOverlay4.setMap(lyr_compare_map_sliders);
2331 }
2332
2333 if (i == 2) {
2334 $("#slider4").attr("id", "sliderTempId");
2335 lyr_compare_stackedOverlay4.set('url', arr[i].split('|')[1]);
2336 lyr_compare_stackedOverlay4.setMap(lyr_compare_map_sliders);
2337 }
2338 }
2339
2340 lyr_comp_bind2Slider(3);
2341 }
2342
2343}
2344
2345$(".lyr_compare_stage2_submit").click(function () {
2346
2347
2348 lyr_compare_countItems();
2349
2350 $(".lyr_compare_drag_slider_wrapper").hide();
2351
2352
2353 var temp_selectedOption = "";
2354 $(".lyr_compare_view3_select").each(function () {
2355 if ($(this).is(':checked')) {
2356 temp_selectedOption = $(this).val();
2357
2358 }
2359 });
2360
2361 $(".lyr_compareLayrs_error_msg").empty().hide();
2362
2363 if (temp_selectedOption != "") {
2364
2365 var temp_arr = [];
2366 $(".lyr_compare_storage_item").each(function () {
2367 temp_arr.push($(this).attr("rel"));
2368 });
2369
2370 $(".lyr_compare_window_pane").hide();
2371 $(".lyr_compare_stacked").hide();
2372 $(".lyr_compare_slider").hide();
2373
2374 //get bounding box data.
2375 var lyr_comp_latlngbounds = new google.maps.LatLngBounds();
2376 var lyr_comp_fieldId = temp_arr[0].split('|')[0];
2377
2378 for (var i = 0; i < polygonsArray.length; i++) {
2379 if (polygonsArray[i].get("id") == lyr_comp_fieldId) {
2380 var lyr_comp_overlayBoundary = new google.maps.MVCArray();
2381 for (var k = 0; k < polygonsArray[i].getPath().getLength() ; k++) {
2382 lyr_comp_overlayBoundary.push(new google.maps.LatLng(polygonsArray[i].getPath().getAt(k).lat(), polygonsArray[i].getPath().getAt(k).lng()));
2383 //for map bounds
2384 var coords = polygonsArray[i].getPath().getAt(k);
2385 lyr_comp_latlngbounds.extend(coords);
2386 }
2387 }
2388 }
2389 //get bounding box data.
2390
2391
2392 $(".lyr_compare_stage2").hide();
2393 $("#compareFieldLayers").modal("hide");
2394
2395 $("#compareFieldLayersStage3").modal({ backdrop: 'static', keyboard: false });
2396
2397 switch (temp_selectedOption) {
2398 case "2a":
2399 //two paned window
2400 $(".lyr_compare_window_pane").show();
2401 $("#lyr_compare_3a_legend_1").parent().hide();
2402 $("#lyr_compare_4a_legend_1").parent().hide();
2403
2404 var lyr_compare_map = new google.maps.Map(document.getElementById('windowMap_2a_1'),
2405 {
2406 streetViewControl: false,
2407 draggable: false,
2408 scrollwheel: false,
2409 disableDoubleClickZoom: false,
2410 disableDefaultUI: true,
2411 zoomControl: false,
2412 mapTypeId: google.maps.MapTypeId.SATELLITE
2413 });
2414
2415 var lyr_compare_map_2 = new google.maps.Map(document.getElementById('windowMap_2a_2'),
2416 {
2417 streetViewControl: false,
2418 draggable: false,
2419 scrollwheel: false,
2420 disableDoubleClickZoom: false,
2421 disableDefaultUI: true,
2422 zoomControl: false,
2423 mapTypeId: google.maps.MapTypeId.SATELLITE
2424 });
2425
2426 //create new overlay
2427 var options = {
2428 path: lyr_comp_overlayBoundary,
2429 strokeColor: "#222",
2430 strokeOpacity: 1,
2431 strokeWeight: 1,
2432 fillOpacity: 0.0,
2433 id: lyr_comp_fieldId
2434 }
2435
2436 //Create polygon
2437 var polygon = new google.maps.Polygon(options);
2438 //Show it on map
2439 polygon.setMap(lyr_compare_map);
2440 lyr_compare_map.fitBounds(lyr_comp_latlngbounds);
2441
2442 polygon.setMap(lyr_compare_map_2);
2443 lyr_compare_map_2.fitBounds(lyr_comp_latlngbounds);
2444
2445
2446 var myOverlay = new google.maps.GroundOverlay(temp_arr[0].split('|')[3], polygon.getBounds(), { clickable: false });
2447 myOverlay.setMap(lyr_compare_map);
2448
2449 var myOverlay2 = new google.maps.GroundOverlay(temp_arr[1].split('|')[3], polygon.getBounds(), { clickable: false });
2450 myOverlay2.setMap(lyr_compare_map_2);
2451
2452 setTimeout(
2453 function () {
2454
2455 //get bounds for map 1
2456 var bounds = lyr_compare_map.getBounds();
2457 var ne = bounds.getNorthEast();
2458 var sw = bounds.getSouthWest();
2459 var nw = new google.maps.LatLng(ne.lat(), sw.lng());
2460 var se = new google.maps.LatLng(sw.lat(), ne.lng());
2461
2462 var outMapPolygonCoords = [sw, se, ne, nw];
2463 var ptsDirection = (google.maps.geometry.spherical.computeSignedArea(polygon.getPath()) < 0);
2464
2465 if (!ptsDirection) {
2466 outMapPolygonCoords = [sw, nw, ne, se];
2467 }
2468
2469 lyr_compare_polygon2a = new google.maps.Polygon({
2470 paths: [outMapPolygonCoords, polygon.getPath()],
2471 map: lyr_compare_map,
2472 strokeColor: '#0000ff',
2473 strokeOpacity: 0.6,
2474 strokeWeight: 1,
2475 fillColor: '#FFFFFF',
2476 fillOpacity: 1
2477 });
2478
2479 lyr_compare_polygon2b = new google.maps.Polygon({
2480 paths: [outMapPolygonCoords, polygon.getPath()],
2481 map: lyr_compare_map_2,
2482 strokeColor: '#0000ff',
2483 strokeOpacity: 0.6,
2484 strokeWeight: 1,
2485 fillColor: '#FFFFFF',
2486 fillOpacity: 1
2487 });
2488
2489
2490
2491 }, 100)
2492 $("#lyr_compare_2a_legend_1").parent().addClass("lyr_compare_2a_1_wrapper");
2493 $("#lyr_compare_2a_legend_2").parent().addClass("lyr_compare_2a_2_wrapper");
2494 $("#windowMap_2a_1").addClass("lyr_compare_window_pane_2_map");
2495 $("#windowMap_2a_2").addClass("lyr_compare_window_pane_2_map");
2496
2497
2498 if (temp_arr[0].split('|').length == 8) {
2499 //display sub type
2500 $("#windowMap_2a_1_title").empty().html(temp_arr[0].split('|')[2].split('_')[1] + " " + temp_arr[0].split('|')[7] + " (" + temp_arr[0].split('|')[6] + ") - " + temp_arr[0].split('|')[1].split(' ')[0]);
2501 }
2502 else {
2503 $("#windowMap_2a_1_title").empty().html(temp_arr[0].split('|')[2].split('_')[1] + " - " + temp_arr[0].split('|')[1].split(' ')[0] + " (" + temp_arr[0].split('|')[6] + ")");
2504
2505 }
2506
2507 if (temp_arr[1].split('|').length == 8) {
2508 $("#windowMap_2a_2_title").empty().html(temp_arr[1].split('|')[2].split('_')[1] + " " + temp_arr[1].split('|')[7] + " (" + temp_arr[1].split('|')[6] + ") - " + temp_arr[1].split('|')[1].split(' ')[0]);
2509 }
2510 else {
2511 $("#windowMap_2a_2_title").empty().html(temp_arr[1].split('|')[2].split('_')[1] + " - " + temp_arr[1].split('|')[1].split(' ')[0] + " (" + temp_arr[1].split('|')[6] + ")");
2512 }
2513
2514 $("#lyr_compare_2a_legend_1").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[0].split('|')[2].split('_')[1]) + temp_arr[0].split('|')[4] + "\"/>");
2515 $("#lyr_compare_2a_legend_2").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4] + "\"/>");
2516 //add overlay polygon
2517
2518 $('#windowMap_2a_1_slider').slider({
2519 min: 0,
2520 max: 1,
2521 step: 0.01,
2522 value: 1,
2523 orientation: "horizontal",
2524 slide: function (e, ui) { lyr_compare_polygon2a.setOptions({ fillOpacity: ui.value }); }
2525 })
2526
2527 $('#windowMap_2b_1_slider').slider({
2528 min: 0,
2529 max: 1,
2530 step: 0.01,
2531 value: 1,
2532 orientation: "horizontal",
2533 slide: function (e, ui) { lyr_compare_polygon2b.setOptions({ fillOpacity: ui.value }); }
2534 })
2535
2536 //change css classs name of slider wrapper
2537 $('#windowMap_2a_1_slider').parent().removeAttr("class").addClass("windowMap_2a_1_slider_wrapper_2_view");
2538 $('#windowMap_2b_1_slider').parent().removeAttr("class").addClass("windowMap_2a_1_slider_wrapper_2_view");
2539
2540
2541 //two paned window
2542
2543
2544
2545
2546
2547 break;
2548
2549 case "2b":
2550 //two image sliders
2551 //currently disabled
2552 //var temp_str = "<div>";
2553 //temp_str += "<div class=\"left_legend\"><p>" + temp_arr[0].split('|')[2].split('_')[1] + " (" + temp_arr[0].split('|')[1].split(' ')[0] + ")</p><br/><img src=\"" + lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4] + "\"/></div>";
2554 //temp_str += "<div class=\"wrapper\"><div class=\"con\"><img src=\"" + temp_arr[1].split('|')[3] + "\"/>";
2555 //temp_str += "<div class=\"coverImage\" style=\"background-image: url(\'" + temp_arr[0].split('|')[3] + "\');\"></div>";
2556 //temp_str += "<div class=\"handle ui-draggable ui-draggable-handle\"></div>";
2557 //temp_str += "</div></div>";
2558 //temp_str += "<div class=\"right_legend\"><p>" + temp_arr[1].split('|')[2].split('_')[1] + " (" + temp_arr[0].split('|')[1].split(' ')[0] + ")</p><br/><img src=\"" + lyr_compare_urlLegendPath(temp_arr[0].split('|')[2].split('_')[1]) + temp_arr[0].split('|')[4] + "\"/></div>";
2559 //temp_str += "<div style=\"clear:left;\"></div></div>";
2560 //$(".lyr_compare_slider").empty().html(temp_str).show();
2561 //lyr_comp_bind2TwoImgSlider();
2562
2563 break;
2564
2565 case "2c":
2566 //two image stacked
2567
2568 //reset panel
2569 lyr_compare_clearSliderModal();
2570
2571 $(".lyr_compare_stacked").show();
2572
2573 //create new overlay
2574 var options = {
2575 path: lyr_comp_overlayBoundary,
2576 strokeColor: "#222",
2577 strokeOpacity: 1,
2578 strokeWeight: 1,
2579 fillOpacity: 0.0,
2580 id: lyr_comp_fieldId
2581 }
2582
2583 //Create polygon
2584 var polygon = new google.maps.Polygon(options);
2585
2586 //Show it on map
2587 polygon.setMap(lyr_compare_map_sliders);
2588 lyr_compare_map_sliders.fitBounds(lyr_comp_latlngbounds);
2589
2590 lyr_compare_stackedOverlay4 = new google.maps.GroundOverlay(temp_arr[0].split('|')[3], polygon.getBounds(), { clickable: false });
2591 lyr_compare_stackedOverlay4.setMap(lyr_compare_map_sliders);
2592
2593 lyr_compare_stackedOverlay3 = new google.maps.GroundOverlay(temp_arr[1].split('|')[3], polygon.getBounds(), { clickable: false });
2594 lyr_compare_stackedOverlay3.setMap(lyr_compare_map_sliders);
2595
2596 setTimeout(
2597 function () {
2598
2599 //get bounds for map 1
2600 var bounds = lyr_compare_map_sliders.getBounds();
2601 var ne = bounds.getNorthEast();
2602 var sw = bounds.getSouthWest();
2603 var nw = new google.maps.LatLng(ne.lat(), sw.lng());
2604 var se = new google.maps.LatLng(sw.lat(), ne.lng());
2605
2606 var outMapPolygonCoords = [sw, se, ne, nw];
2607 var ptsDirection = (google.maps.geometry.spherical.computeSignedArea(polygon.getPath()) < 0);
2608
2609 if (!ptsDirection) {
2610 outMapPolygonCoords = [sw, nw, ne, se];
2611 }
2612
2613 polygon2a = new google.maps.Polygon({
2614 paths: [outMapPolygonCoords, polygon.getPath()],
2615 map: lyr_compare_map_sliders,
2616 strokeColor: '#0000ff',
2617 strokeOpacity: 0.6,
2618 strokeWeight: 1,
2619 fillColor: '#FFFFFF',
2620 fillOpacity: 1
2621 });
2622
2623 }, 100)
2624
2625 //legends
2626
2627 $(".lyr_comp_stacked_4_wrapper").show();
2628 $(".lyr_comp_stacked_3_wrapper").show();
2629
2630 if (temp_arr[0].split('|').length == 8) {
2631 //display sub type
2632 $(".lyr_comp_stacked_4_legend").children(0).empty().html(temp_arr[0].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[0].split('|')[7] + " (" + temp_arr[0].split('|')[6] + ")" + "<br/>" + temp_arr[0].split('|')[1].split(' ')[0]);
2633 $(".lyr_comp_stacked_layer_name_4").empty().text(temp_arr[0].split('|')[2].split('_')[1] + " - " + temp_arr[0].split('|')[6] + " (" + temp_arr[0].split('|')[1].split(' ')[0] + ")");
2634 }
2635 else {
2636 $(".lyr_comp_stacked_4_legend").children(0).empty().html(temp_arr[0].split('|')[2].split('_')[1] + " (" + temp_arr[0].split('|')[6] + ")<br/>" + temp_arr[0].split('|')[1].split(' ')[0]);
2637 $(".lyr_comp_stacked_layer_name_4").empty().text(temp_arr[0].split('|')[2].split('_')[1] + " (" + temp_arr[0].split('|')[6] + ") - " + temp_arr[0].split('|')[1].split(' ')[0]);
2638 }
2639 if (temp_arr[1].split('|').length == 8) {
2640 //display sub type
2641 $(".lyr_comp_stacked_3_legend").children(0).empty().html(temp_arr[1].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[1].split('|')[7] + " (" + temp_arr[1].split('|')[6] + ")" + "<br/>(" + temp_arr[1].split('|')[1].split(' ')[0] + ")");
2642 $(".lyr_comp_stacked_layer_name_3").empty().text(temp_arr[1].split('|')[2].split('_')[1] + " - " + temp_arr[1].split('|')[6] + " (" + temp_arr[1].split('|')[1].split(' ')[0] + ")");
2643 }
2644 else {
2645 $(".lyr_comp_stacked_3_legend").children(0).empty().html(temp_arr[1].split('|')[2].split('_')[1] + " (" + temp_arr[1].split('|')[6] + ")<br/>" + temp_arr[1].split('|')[1].split(' ')[0]);
2646 $(".lyr_comp_stacked_layer_name_3").empty().text(temp_arr[1].split('|')[2].split('_')[1] + " (" + temp_arr[1].split('|')[6] + ") - " + temp_arr[1].split('|')[1].split(' ')[0]);
2647 }
2648
2649 $(".lyr_comp_stacked_4_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[0].split('|')[2].split('_')[1]) + temp_arr[0].split('|')[4]);
2650 $(".lyr_comp_stacked_3_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4]);
2651 $(".lyr_comp_stacked_4_wrapper").attr("rel", temp_arr[0].split('|')[3]);
2652 $(".lyr_comp_stacked_4_wrapper").parent().show();
2653 $(".lyr_comp_stacked_3_wrapper").parent().show();
2654 $(".lyr_comp_stacked_3_wrapper").attr("rel", temp_arr[1].split('|')[3]);
2655
2656
2657
2658 $(".lyr_comp_stacked_4_legend").show();
2659 $(".lyr_comp_stacked_3_legend").show();
2660 $(".lyr_compare_stacked").show();
2661 lyr_comp_bind2Slider(2);
2662
2663 if (!$("#instantiated").hasClass("instantiated")) {
2664 $('#windowMap_5a_1_slider').slider({
2665 min: 0,
2666 max: 1,
2667 step: 0.01,
2668 value: 1,
2669 orientation: "horizontal",
2670 slide: function (e, ui) { polygon2a.setOptions({ fillOpacity: ui.value }); }
2671 })
2672
2673 $("#windowMap_5a_1_slider").addClass("instantiated");
2674 }
2675
2676
2677 break;
2678
2679 case "3a":
2680 //three paned window
2681 $(".lyr_compare_window_pane").show();
2682 $("#lyr_compare_3a_legend_1").parent().show();
2683 $("#lyr_compare_4a_legend_1").parent().hide();
2684 var lyr_compare_map = new google.maps.Map(document.getElementById('windowMap_2a_1'),
2685 {
2686 streetViewControl: false,
2687 draggable: false,
2688 scrollwheel: false,
2689 disableDoubleClickZoom: false,
2690 disableDefaultUI: true,
2691 zoomControl: false,
2692 mapTypeId: google.maps.MapTypeId.SATELLITE
2693 });
2694
2695 var lyr_compare_map_2 = new google.maps.Map(document.getElementById('windowMap_2a_2'),
2696 {
2697 streetViewControl: false,
2698 draggable: false,
2699 scrollwheel: false,
2700 disableDoubleClickZoom: false,
2701 disableDefaultUI: true,
2702 zoomControl: false,
2703 mapTypeId: google.maps.MapTypeId.SATELLITE
2704 });
2705
2706 var lyr_compare_map_3 = new google.maps.Map(document.getElementById('windowMap_3a_1'),
2707 {
2708 streetViewControl: false,
2709 draggable: false,
2710 scrollwheel: false,
2711 disableDoubleClickZoom: false,
2712 disableDefaultUI: true,
2713 zoomControl: false,
2714 mapTypeId: google.maps.MapTypeId.SATELLITE
2715 });
2716
2717
2718
2719 //create new overlay
2720 var options = {
2721 path: lyr_comp_overlayBoundary,
2722 strokeColor: "#222",
2723 strokeOpacity: 1,
2724 strokeWeight: 1,
2725 fillOpacity: 0.0,
2726 id: lyr_comp_fieldId
2727 }
2728
2729 //Create polygon
2730 var polygon = new google.maps.Polygon(options);
2731 //Show it on map
2732 polygon.setMap(lyr_compare_map);
2733 lyr_compare_map.fitBounds(lyr_comp_latlngbounds);
2734
2735 polygon.setMap(lyr_compare_map_2);
2736 lyr_compare_map_2.fitBounds(lyr_comp_latlngbounds);
2737
2738 polygon.setMap(lyr_compare_map_3);
2739 lyr_compare_map_3.fitBounds(lyr_comp_latlngbounds);
2740
2741 var myOverlay = new google.maps.GroundOverlay(temp_arr[0].split('|')[3], polygon.getBounds(), { clickable: false });
2742 myOverlay.setMap(lyr_compare_map);
2743
2744 var myOverlay2 = new google.maps.GroundOverlay(temp_arr[1].split('|')[3], polygon.getBounds(), { clickable: false });
2745 myOverlay2.setMap(lyr_compare_map_2);
2746
2747 var myOverlay3 = new google.maps.GroundOverlay(temp_arr[2].split('|')[3], polygon.getBounds(), { clickable: false });
2748 myOverlay3.setMap(lyr_compare_map_3);
2749 setTimeout(
2750 function () {
2751
2752 //get bounds for map 1
2753 var bounds = lyr_compare_map.getBounds();
2754 var ne = bounds.getNorthEast();
2755 var sw = bounds.getSouthWest();
2756 var nw = new google.maps.LatLng(ne.lat(), sw.lng());
2757 var se = new google.maps.LatLng(sw.lat(), ne.lng());
2758
2759 var outMapPolygonCoords = [sw, se, ne, nw];
2760 var ptsDirection = (google.maps.geometry.spherical.computeSignedArea(polygon.getPath()) < 0);
2761
2762 if (!ptsDirection) {
2763 outMapPolygonCoords = [sw, nw, ne, se];
2764 }
2765
2766 lyr_compare_polygon2a = new google.maps.Polygon({
2767 paths: [outMapPolygonCoords, polygon.getPath()],
2768 map: lyr_compare_map,
2769 strokeColor: '#0000ff',
2770 strokeOpacity: 0.6,
2771 strokeWeight: 1,
2772 fillColor: '#FFFFFF',
2773 fillOpacity: 1
2774 });
2775
2776 lyr_compare_polygon2b = new google.maps.Polygon({
2777 paths: [outMapPolygonCoords, polygon.getPath()],
2778 map: lyr_compare_map_2,
2779 strokeColor: '#0000ff',
2780 strokeOpacity: 0.6,
2781 strokeWeight: 1,
2782 fillColor: '#FFFFFF',
2783 fillOpacity: 1
2784 });
2785
2786 lyr_compare_polygon3a = new google.maps.Polygon({
2787 paths: [outMapPolygonCoords, polygon.getPath()],
2788 map: lyr_compare_map_3,
2789 strokeColor: '#0000ff',
2790 strokeOpacity: 0.6,
2791 strokeWeight: 1,
2792 fillColor: '#FFFFFF',
2793 fillOpacity: 1
2794 });
2795
2796 }, 100)
2797 $("#lyr_compare_2a_legend_1").parent().addClass("lyr_compare_2a_1_wrapper");
2798 $("#lyr_compare_2a_legend_2").parent().addClass("lyr_compare_2a_2_wrapper");
2799 $("#lyr_compare_3a_legend_1").parent().addClass("lyr_compare_3a_1_wrapper");
2800 $("#windowMap_2a_1").addClass("lyr_compare_window_pane_2_map");
2801 $("#windowMap_2a_2").addClass("lyr_compare_window_pane_2_map");
2802 $("#windowMap_3a_1").addClass("lyr_compare_window_pane_2_map");
2803
2804
2805 if (temp_arr[0].split('|').length == 8) {
2806 //display sub type
2807 $("#windowMap_2a_1_title").empty().html(temp_arr[0].split('|')[2].split('_')[1] + " " + temp_arr[0].split('|')[7] + " (" + temp_arr[0].split('|')[6] + ") - " + temp_arr[0].split('|')[1].split(' ')[0]);
2808 }
2809 else {
2810 $("#windowMap_2a_1_title").empty().html(temp_arr[0].split('|')[2].split('_')[1] + " - " + temp_arr[0].split('|')[1].split(' ')[0] + " (" + temp_arr[0].split('|')[6] + ")");
2811
2812 }
2813
2814 if (temp_arr[1].split('|').length == 8) {
2815 $("#windowMap_2a_2_title").empty().html(temp_arr[1].split('|')[2].split('_')[1] + " " + temp_arr[1].split('|')[7] + " (" + temp_arr[1].split('|')[6] + ") - " + temp_arr[1].split('|')[1].split(' ')[0]);
2816 }
2817 else {
2818 $("#windowMap_2a_2_title").empty().html(temp_arr[1].split('|')[2].split('_')[1] + " - " + temp_arr[1].split('|')[1].split(' ')[0] + " (" + temp_arr[1].split('|')[6] + ")");
2819 }
2820
2821 if (temp_arr[2].split('|').length == 8) {
2822 //display sub type
2823 $("#windowMap_3a_1_title").empty().html(temp_arr[2].split('|')[2].split('_')[1] + " " + temp_arr[2].split('|')[7] + " (" + temp_arr[2].split('|')[6] + ") - " + temp_arr[2].split('|')[1].split(' ')[0]);
2824 }
2825 else {
2826 $("#windowMap_3a_1_title").empty().html(temp_arr[2].split('|')[2].split('_')[1] + " - " + temp_arr[2].split('|')[1].split(' ')[0] + " (" + temp_arr[2].split('|')[6] + ")");
2827 }
2828
2829 $("#lyr_compare_2a_legend_1").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[0].split('|')[2].split('_')[1]) + temp_arr[0].split('|')[4] + "\"/>");
2830 $("#lyr_compare_2a_legend_2").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4] + "\"/>");
2831 $("#lyr_compare_3a_legend_1").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[2].split('|')[2].split('_')[1]) + temp_arr[2].split('|')[4] + "\"/>");
2832
2833 $('#windowMap_2a_1_slider').slider({
2834 min: 0,
2835 max: 1,
2836 step: 0.01,
2837 value: 1,
2838 orientation: "horizontal",
2839 slide: function (e, ui) { lyr_compare_polygon2a.setOptions({ fillOpacity: ui.value }); }
2840 });
2841
2842 $('#windowMap_2b_1_slider').slider({
2843 min: 0,
2844 max: 1,
2845 step: 0.01,
2846 value: 1,
2847 orientation: "horizontal",
2848 slide: function (e, ui) { lyr_compare_polygon2b.setOptions({ fillOpacity: ui.value }); }
2849 });
2850
2851 $('#windowMap_3a_1_slider').slider({
2852 min: 0,
2853 max: 1,
2854 step: 0.01,
2855 value: 1,
2856 orientation: "horizontal",
2857 slide: function (e, ui) { lyr_compare_polygon3a.setOptions({ fillOpacity: ui.value }); }
2858 });
2859
2860
2861 //change css classs name of slider wrapper
2862 $('#windowMap_2a_1_slider').parent().removeAttr("class").addClass("windowMap_2a_1_slider_wrapper_2_view");
2863 $('#windowMap_2b_1_slider').parent().removeAttr("class").addClass("windowMap_2b_1_slider_wrapper_2_view");
2864 $('#windowMap_3a_1_slider').parent().removeAttr("class").addClass("windowMap_3a_1_slider_wrapper_2_view");
2865
2866 break;
2867
2868 case "3b":
2869 ////currently disabled
2870 ////three image slider
2871 //var temp_str = "<div>";
2872 ////temp_str += "<div style=\"float:left;\">" + temp_arr[0].split('|')[2].split('_')[1] + "(" + temp_arr[0].split('|')[1].split(' ')[0] + ")<br/><img src=\"" + lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4] + "\"/></div>";
2873 //temp_str += "<div class=\"wrapper\"><div style=\"float:left;\" class=\"con_3\"><img src=\"" + temp_arr[0].split('|')[3] + "\"/>";
2874 //temp_str += "<div class=\"coverImage_1\" style=\"background-image: url(\'" + temp_arr[1].split('|')[3] + "\');\"></div>";
2875 //temp_str += "<div class=\"handle_1 ui-draggable ui-draggable-handle\"></div>";
2876 //temp_str += "<div class=\"coverImage_2\" style=\"background-image: url(\'" + temp_arr[2].split('|')[3] + "\');\"></div>";
2877 //temp_str += "<div class=\"handle_2 ui-draggable ui-draggable-handle\"></div>";
2878 //temp_str += "</div></div>";
2879 //temp_str += "<div style=\"float:left;margin-left: 27px;border: 1px solid; width:30%;\">";
2880 //temp_str += "<div style=\"float: left;margin: 4px;border: 1px solid;padding: 10px;\"><p style=\"font-size: 1.2em;font-weight: bold;text-decoration: underline;\">Left</p><p style=\"text-align: center;font-size: 1.2em;font-weight: bold;\">" + temp_arr[2].split('|')[2].split('_')[1] + "<br/>(" + temp_arr[2].split('|')[1].split(' ')[0] + ")</p><img src=\"" + lyr_compare_urlLegendPath(temp_arr[2].split('|')[2].split('_')[1]) + temp_arr[2].split('|')[4] + "\"/></div>";
2881 //temp_str += "<div style=\"float: left;margin: 4px;border: 1px solid;padding: 10px;\"><p style=\"font-size: 1.2em;font-weight: bold;text-decoration: underline;\">Middle</p><p style=\"text-align: center;font-size: 1.2em;font-weight: bold;\">" + temp_arr[1].split('|')[2].split('_')[1] + "<br/>(" + temp_arr[1].split('|')[1].split(' ')[0] + ")</p><img src=\"" + lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4] + "\"/></div>";
2882 //temp_str += "<div style=\"float: left;margin: 4px;border: 1px solid;padding: 10px;\"><p style=\"font-size: 1.2em;font-weight: bold;text-decoration: underline;\">Right</p><p style=\"text-align: center;font-size: 1.2em;font-weight: bold;\">" + temp_arr[0].split('|')[2].split('_')[1] + "<br/>(" + temp_arr[0].split('|')[1].split(' ')[0] + ")</p><img src=\"" + lyr_compare_urlLegendPath(temp_arr[0].split('|')[2].split('_')[1]) + temp_arr[0].split('|')[4] + "\"/></div>";
2883 //temp_str += "</div><div style=\"clear:left;\"></div></div>";
2884 //$(".lyr_compare_slider").empty().html(temp_str).show();
2885 //lyr_comp_bind2ThreeImgSlider();
2886
2887 break;
2888
2889 case "3c":
2890 //three image stacked
2891
2892 //reset panel
2893 lyr_compare_clearSliderModal();
2894
2895 $(".lyr_compare_stacked").show();
2896 //create new overlay
2897 var options = {
2898 path: lyr_comp_overlayBoundary,
2899 strokeColor: "#222",
2900 strokeOpacity: 1,
2901 strokeWeight: 1,
2902 fillOpacity: 0.0,
2903 id: lyr_comp_fieldId
2904 }
2905
2906 //Create polygon
2907 var polygon = new google.maps.Polygon(options);
2908
2909 //Show it on map
2910 polygon.setMap(lyr_compare_map_sliders);
2911 lyr_compare_map_sliders.fitBounds(lyr_comp_latlngbounds);
2912
2913 lyr_compare_stackedOverlay4 = new google.maps.GroundOverlay(temp_arr[0].split('|')[3], polygon.getBounds(), { clickable: false });
2914 lyr_compare_stackedOverlay4.setMap(lyr_compare_map_sliders);
2915
2916 lyr_compare_stackedOverlay3 = new google.maps.GroundOverlay(temp_arr[1].split('|')[3], polygon.getBounds(), { clickable: false });
2917 lyr_compare_stackedOverlay3.setMap(lyr_compare_map_sliders);
2918
2919 lyr_compare_stackedOverlay2 = new google.maps.GroundOverlay(temp_arr[2].split('|')[3], polygon.getBounds(), { clickable: false });
2920 lyr_compare_stackedOverlay2.setMap(lyr_compare_map_sliders);
2921
2922 setTimeout(
2923 function () {
2924
2925 //get bounds for map 1
2926 var bounds = lyr_compare_map_sliders.getBounds();
2927 var ne = bounds.getNorthEast();
2928 var sw = bounds.getSouthWest();
2929 var nw = new google.maps.LatLng(ne.lat(), sw.lng());
2930 var se = new google.maps.LatLng(sw.lat(), ne.lng());
2931
2932 var outMapPolygonCoords = [sw, se, ne, nw];
2933 var ptsDirection = (google.maps.geometry.spherical.computeSignedArea(polygon.getPath()) < 0);
2934
2935 if (!ptsDirection) {
2936 outMapPolygonCoords = [sw, nw, ne, se];
2937 }
2938
2939 polygon2a = new google.maps.Polygon({
2940 paths: [outMapPolygonCoords, polygon.getPath()],
2941 map: lyr_compare_map_sliders,
2942 strokeColor: '#0000ff',
2943 strokeOpacity: 0.6,
2944 strokeWeight: 1,
2945 fillColor: '#FFFFFF',
2946 fillOpacity: 1
2947 });
2948
2949 }, 100)
2950
2951
2952 //legends
2953 $(".lyr_comp_stacked_2_wrapper").show();
2954 $(".lyr_comp_stacked_3_wrapper").show();
2955 $(".lyr_comp_stacked_4_wrapper").show();
2956 if (temp_arr[0].split('|').length == 8) {
2957 //display sub type
2958 $(".lyr_comp_stacked_4_legend").children(0).empty().html(temp_arr[0].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[0].split('|')[7] + " (" + temp_arr[0].split('|')[6] + ")" + "<br/>" + temp_arr[0].split('|')[1].split(' ')[0]);
2959 $(".lyr_comp_stacked_layer_name_4").empty().text(temp_arr[0].split('|')[2].split('_')[1] + " - " + temp_arr[0].split('|')[6] + " (" + temp_arr[0].split('|')[1].split(' ')[0] + ")");
2960 }
2961 else {
2962 $(".lyr_comp_stacked_4_legend").children(0).empty().html(temp_arr[0].split('|')[2].split('_')[1] + " (" + temp_arr[0].split('|')[6] + ")<br/>" + temp_arr[0].split('|')[1].split(' ')[0]);
2963 $(".lyr_comp_stacked_layer_name_4").empty().text(temp_arr[0].split('|')[2].split('_')[1] + " (" + temp_arr[0].split('|')[6] + ") - " + temp_arr[0].split('|')[1].split(' ')[0]);
2964 }
2965 if (temp_arr[1].split('|').length == 8) {
2966 //display sub type
2967 $(".lyr_comp_stacked_3_legend").children(0).empty().html(temp_arr[1].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[1].split('|')[7] + " (" + temp_arr[1].split('|')[6] + ")" + "<br/>(" + temp_arr[1].split('|')[1].split(' ')[0] + ")");
2968 $(".lyr_comp_stacked_layer_name_3").empty().text(temp_arr[1].split('|')[2].split('_')[1] + " - " + temp_arr[1].split('|')[6] + " (" + temp_arr[1].split('|')[1].split(' ')[0] + ")");
2969 }
2970 else {
2971 $(".lyr_comp_stacked_3_legend").children(0).empty().html(temp_arr[1].split('|')[2].split('_')[1] + " (" + temp_arr[1].split('|')[6] + ")<br/>" + temp_arr[1].split('|')[1].split(' ')[0]);
2972 $(".lyr_comp_stacked_layer_name_3").empty().text(temp_arr[1].split('|')[2].split('_')[1] + " (" + temp_arr[1].split('|')[6] + ") - " + temp_arr[1].split('|')[1].split(' ')[0]);
2973 }
2974
2975
2976 if (temp_arr[2].split('|').length == 8) {
2977 //display sub type
2978 $(".lyr_comp_stacked_2_legend").children(0).empty().html(temp_arr[2].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[2].split('|')[7] + " (" + temp_arr[2].split('|')[6] + ")" + "<br/>(" + temp_arr[2].split('|')[1].split(' ')[0] + ")");
2979 $(".lyr_comp_stacked_layer_name_2").empty().text(temp_arr[2].split('|')[2].split('_')[1] + " - " + temp_arr[2].split('|')[6] + " (" + temp_arr[2].split('|')[1].split(' ')[0] + ")");
2980 }
2981 else {
2982 $(".lyr_comp_stacked_2_legend").children(0).empty().html(temp_arr[2].split('|')[2].split('_')[1] + " (" + temp_arr[2].split('|')[6] + ")<br/>" + temp_arr[2].split('|')[1].split(' ')[0]);
2983 $(".lyr_comp_stacked_layer_name_2").empty().text(temp_arr[2].split('|')[2].split('_')[1] + " (" + temp_arr[2].split('|')[6] + ") - " + temp_arr[2].split('|')[1].split(' ')[0]);
2984 }
2985
2986
2987 $(".lyr_comp_stacked_4_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[0].split('|')[2].split('_')[1]) + temp_arr[0].split('|')[4]);
2988 $(".lyr_comp_stacked_3_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4]);
2989 $(".lyr_comp_stacked_2_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[2].split('|')[2].split('_')[1]) + temp_arr[2].split('|')[4]);
2990
2991 $(".lyr_comp_stacked_4_wrapper").parent().show();
2992 $(".lyr_comp_stacked_3_wrapper").parent().show();
2993 $(".lyr_comp_stacked_2_wrapper").parent().show();
2994
2995 $(".lyr_comp_stacked_4_legend").show();
2996 $(".lyr_comp_stacked_3_legend").show();
2997 $(".lyr_comp_stacked_2_legend").show();
2998 $(".lyr_compare_stacked").show();
2999
3000 lyr_comp_bind2Slider(3);
3001
3002
3003 if (!$("#instantiated").hasClass("instantiated")) {
3004 $('#windowMap_5a_1_slider').slider({
3005 min: 0,
3006 max: 1,
3007 step: 0.01,
3008 value: 1,
3009 orientation: "horizontal",
3010 slide: function (e, ui) { polygon2a.setOptions({ fillOpacity: ui.value }); }
3011 })
3012
3013 $("#windowMap_5a_1_slider").addClass("instantiated");
3014 }
3015
3016
3017
3018 break;
3019
3020 case "4a":
3021 //four paned window
3022 $(".lyr_compare_window_pane").show();
3023 $("#lyr_compare_3a_legend_1").parent().show();
3024 $("#lyr_compare_4a_legend_1").parent().show();
3025
3026 var lyr_compare_map = new google.maps.Map(document.getElementById('windowMap_2a_1'),
3027 {
3028 streetViewControl: false,
3029 draggable: false,
3030 scrollwheel: false,
3031 disableDoubleClickZoom: false,
3032 disableDefaultUI: true,
3033 zoomControl: false,
3034 mapTypeId: google.maps.MapTypeId.SATELLITE
3035 });
3036
3037 var lyr_compare_map_2 = new google.maps.Map(document.getElementById('windowMap_2a_2'),
3038 {
3039 streetViewControl: false,
3040 draggable: false,
3041 scrollwheel: false,
3042 disableDoubleClickZoom: false,
3043 disableDefaultUI: true,
3044 zoomControl: false,
3045 mapTypeId: google.maps.MapTypeId.SATELLITE
3046 });
3047
3048 var lyr_compare_map_3 = new google.maps.Map(document.getElementById('windowMap_3a_1'),
3049 {
3050 streetViewControl: false,
3051 draggable: false,
3052 scrollwheel: false,
3053 disableDoubleClickZoom: false,
3054 disableDefaultUI: true,
3055 zoomControl: false,
3056 mapTypeId: google.maps.MapTypeId.SATELLITE
3057 });
3058
3059 var lyr_compare_map_4 = new google.maps.Map(document.getElementById('windowMap_4a_1'),
3060 {
3061 streetViewControl: false,
3062 draggable: false,
3063 scrollwheel: false,
3064 disableDoubleClickZoom: false,
3065 disableDefaultUI: true,
3066 zoomControl: false,
3067 mapTypeId: google.maps.MapTypeId.SATELLITE
3068 });
3069
3070 //create new overlay
3071 var options = {
3072 path: lyr_comp_overlayBoundary,
3073 strokeColor: "#222",
3074 strokeOpacity: 1,
3075 strokeWeight: 1,
3076 fillOpacity: 0.0,
3077 id: lyr_comp_fieldId
3078 }
3079
3080 //Create polygon
3081 var polygon = new google.maps.Polygon(options);
3082 //Show it on map
3083 polygon.setMap(lyr_compare_map);
3084 lyr_compare_map.fitBounds(lyr_comp_latlngbounds);
3085
3086 polygon.setMap(lyr_compare_map_2);
3087 lyr_compare_map_2.fitBounds(lyr_comp_latlngbounds);
3088
3089 polygon.setMap(lyr_compare_map_3);
3090 lyr_compare_map_3.fitBounds(lyr_comp_latlngbounds);
3091
3092 polygon.setMap(lyr_compare_map_4);
3093 lyr_compare_map_4.fitBounds(lyr_comp_latlngbounds);
3094
3095 var myOverlay = new google.maps.GroundOverlay(temp_arr[0].split('|')[3], polygon.getBounds(), { clickable: false });
3096 myOverlay.setMap(lyr_compare_map);
3097
3098 var myOverlay2 = new google.maps.GroundOverlay(temp_arr[1].split('|')[3], polygon.getBounds(), { clickable: false });
3099 myOverlay2.setMap(lyr_compare_map_2);
3100
3101 var myOverlay3 = new google.maps.GroundOverlay(temp_arr[2].split('|')[3], polygon.getBounds(), { clickable: false });
3102 myOverlay3.setMap(lyr_compare_map_3);
3103
3104 var myOverlay4 = new google.maps.GroundOverlay(temp_arr[3].split('|')[3], polygon.getBounds(), { clickable: false });
3105 myOverlay4.setMap(lyr_compare_map_4);
3106
3107
3108 setTimeout(
3109 function () {
3110
3111 //get bounds for map 1
3112 var bounds = lyr_compare_map.getBounds();
3113 var ne = bounds.getNorthEast();
3114 var sw = bounds.getSouthWest();
3115 var nw = new google.maps.LatLng(ne.lat(), sw.lng());
3116 var se = new google.maps.LatLng(sw.lat(), ne.lng());
3117
3118 var outMapPolygonCoords = [sw, se, ne, nw];
3119 var ptsDirection = (google.maps.geometry.spherical.computeSignedArea(polygon.getPath()) < 0);
3120
3121 if (!ptsDirection) {
3122 outMapPolygonCoords = [sw, nw, ne, se];
3123 }
3124
3125
3126 lyr_compare_polygon2a = new google.maps.Polygon({
3127 paths: [outMapPolygonCoords, polygon.getPath()],
3128 map: lyr_compare_map,
3129 strokeColor: '#0000ff',
3130 strokeOpacity: 0.6,
3131 strokeWeight: 1,
3132 fillColor: '#FFFFFF',
3133 fillOpacity: 1
3134 });
3135
3136 lyr_compare_polygon2b = new google.maps.Polygon({
3137 paths: [outMapPolygonCoords, polygon.getPath()],
3138 map: lyr_compare_map_2,
3139 strokeColor: '#0000ff',
3140 strokeOpacity: 0.6,
3141 strokeWeight: 1,
3142 fillColor: '#FFFFFF',
3143 fillOpacity: 1
3144 });
3145
3146 lyr_compare_polygon3a = new google.maps.Polygon({
3147 paths: [outMapPolygonCoords, polygon.getPath()],
3148 map: lyr_compare_map_3,
3149 strokeColor: '#0000ff',
3150 strokeOpacity: 0.6,
3151 strokeWeight: 1,
3152 fillColor: '#FFFFFF',
3153 fillOpacity: 1
3154 });
3155
3156 lyr_compare_polygon4a = new google.maps.Polygon({
3157 paths: [outMapPolygonCoords, polygon.getPath()],
3158 map: lyr_compare_map_4,
3159 strokeColor: '#0000ff',
3160 strokeOpacity: 0.6,
3161 strokeWeight: 1,
3162 fillColor: '#FFFFFF',
3163 fillOpacity: 1
3164 });
3165
3166 }, 100);
3167
3168 $("#lyr_compare_2a_legend_1").parent().addClass("lyr_compare_2a_1_wrapper");
3169 $("#lyr_compare_2a_legend_2").parent().addClass("lyr_compare_2a_2_wrapper");
3170 $("#lyr_compare_3a_legend_1").parent().addClass("lyr_compare_3a_1_wrapper");
3171 $("#lyr_compare_4a_legend_1").parent().addClass("lyr_compare_4a_1_wrapper");
3172 $("#windowMap_2a_1").addClass("lyr_compare_window_pane_2_map");
3173 $("#windowMap_2a_2").addClass("lyr_compare_window_pane_2_map");
3174 $("#windowMap_3a_1").addClass("lyr_compare_window_pane_2_map");
3175 $("#windowMap_4a_1").addClass("lyr_compare_window_pane_2_map");
3176
3177 if (temp_arr[0].split('|').length == 8) {
3178 //display sub type
3179 $("#windowMap_2a_1_title").empty().html(temp_arr[0].split('|')[2].split('_')[1] + " " + temp_arr[0].split('|')[7] + " (" + temp_arr[0].split('|')[6] + ") - " + temp_arr[0].split('|')[1].split(' ')[0]);
3180 }
3181 else {
3182 $("#windowMap_2a_1_title").empty().html(temp_arr[0].split('|')[2].split('_')[1] + " - " + temp_arr[0].split('|')[1].split(' ')[0] + " (" + temp_arr[0].split('|')[6] + ")");
3183
3184 }
3185
3186 if (temp_arr[1].split('|').length == 8) {
3187 $("#windowMap_2a_2_title").empty().html(temp_arr[1].split('|')[2].split('_')[1] + " " + temp_arr[1].split('|')[7] + " (" + temp_arr[1].split('|')[6] + ") - " + temp_arr[1].split('|')[1].split(' ')[0]);
3188 }
3189 else {
3190 $("#windowMap_2a_2_title").empty().html(temp_arr[1].split('|')[2].split('_')[1] + " - " + temp_arr[1].split('|')[1].split(' ')[0] + " (" + temp_arr[1].split('|')[6] + ")");
3191 }
3192
3193 if (temp_arr[2].split('|').length == 8) {
3194 //display sub type
3195 $("#windowMap_3a_1_title").empty().html(temp_arr[2].split('|')[2].split('_')[1] + " " + temp_arr[2].split('|')[7] + " (" + temp_arr[2].split('|')[6] + ") - " + temp_arr[2].split('|')[1].split(' ')[0]);
3196 }
3197 else {
3198 $("#windowMap_3a_1_title").empty().html(temp_arr[2].split('|')[2].split('_')[1] + " - " + temp_arr[2].split('|')[1].split(' ')[0] + " (" + temp_arr[2].split('|')[6] + ")");
3199 }
3200
3201 if (temp_arr[3].split('|').length == 7) {
3202 //display sub type
3203 $("#windowMap_4a_1_title").empty().html(temp_arr[3].split('|')[2].split('_')[1] + " " + temp_arr[3].split('|')[7] + " (" + temp_arr[3].split('|')[6] + ") - " + temp_arr[3].split('|')[1].split(' ')[0]);
3204 }
3205 else {
3206 $("#windowMap_4a_1_title").empty().html(temp_arr[3].split('|')[2].split('_')[1] + " - " + temp_arr[3].split('|')[1].split(' ')[0] + " (" + temp_arr[3].split('|')[6] + ")");
3207 }
3208
3209 $("#lyr_compare_2a_legend_1").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[0].split('|')[2].split('_')[1]) + temp_arr[0].split('|')[4] + "\"/>");
3210 $("#lyr_compare_2a_legend_2").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4] + "\"/>");
3211 $("#lyr_compare_3a_legend_1").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[2].split('|')[2].split('_')[1]) + temp_arr[2].split('|')[4] + "\"/>");
3212 $("#lyr_compare_4a_legend_1").html("<img src=\"" + lyr_compare_urlLegendPath(temp_arr[3].split('|')[2].split('_')[1]) + temp_arr[3].split('|')[4] + "\"/>");
3213
3214
3215 $('#windowMap_2a_1_slider').slider({
3216 min: 0,
3217 max: 1,
3218 step: 0.01,
3219 value: 1,
3220 orientation: "horizontal",
3221 slide: function (e, ui) { lyr_compare_polygon2a.setOptions({ fillOpacity: ui.value }); }
3222 });
3223
3224 $('#windowMap_2b_1_slider').slider({
3225 min: 0,
3226 max: 1,
3227 step: 0.01,
3228 value: 1,
3229 orientation: "horizontal",
3230 slide: function (e, ui) { lyr_compare_polygon2b.setOptions({ fillOpacity: ui.value }); }
3231 });
3232
3233 $('#windowMap_3a_1_slider').slider({
3234 min: 0,
3235 max: 1,
3236 step: 0.01,
3237 value: 1,
3238 orientation: "horizontal",
3239 slide: function (e, ui) { lyr_compare_polygon3a.setOptions({ fillOpacity: ui.value }); }
3240 });
3241
3242 $('#windowMap_4a_1_slider').slider({
3243 min: 0,
3244 max: 1,
3245 step: 0.01,
3246 value: 1,
3247 orientation: "horizontal",
3248 slide: function (e, ui) { lyr_compare_polygon4a.setOptions({ fillOpacity: ui.value }); }
3249 });
3250
3251
3252 //change css classs name of slider wrapper
3253 $('#windowMap_2a_1_slider').parent().removeAttr("class").addClass("windowMap_2a_1_slider_wrapper_2_view");
3254 $('#windowMap_2b_1_slider').parent().removeAttr("class").addClass("windowMap_2b_1_slider_wrapper_2_view");
3255 $('#windowMap_3a_1_slider').parent().removeAttr("class").addClass("windowMap_3a_1_slider_wrapper_2_view");
3256 $('#windowMap_4a_1_slider').parent().removeAttr("class").addClass("windowMap_4a_1_slider_wrapper_2_view");
3257 break;
3258
3259 case "4c":
3260
3261 //reset panel
3262 lyr_compare_clearSliderModal();
3263
3264 $(".lyr_compare_stacked").show();
3265
3266 //create new overlay
3267 var options = {
3268 path: lyr_comp_overlayBoundary,
3269 strokeColor: "#222",
3270 strokeOpacity: 1,
3271 strokeWeight: 1,
3272 fillOpacity: 0.0,
3273 id: lyr_comp_fieldId
3274 }
3275
3276 //Create polygon
3277 var polygon = new google.maps.Polygon(options);
3278
3279 //Show it on map
3280 polygon.setMap(lyr_compare_map_sliders);
3281 lyr_compare_map_sliders.fitBounds(lyr_comp_latlngbounds);
3282
3283 lyr_compare_stackedOverlay4 = new google.maps.GroundOverlay(temp_arr[0].split('|')[3], polygon.getBounds(), { clickable: false });
3284 lyr_compare_stackedOverlay4.setMap(lyr_compare_map_sliders);
3285
3286 lyr_compare_stackedOverlay3 = new google.maps.GroundOverlay(temp_arr[1].split('|')[3], polygon.getBounds(), { clickable: false });
3287 lyr_compare_stackedOverlay3.setMap(lyr_compare_map_sliders);
3288
3289 lyr_compare_stackedOverlay2 = new google.maps.GroundOverlay(temp_arr[2].split('|')[3], polygon.getBounds(), { clickable: false });
3290 lyr_compare_stackedOverlay2.setMap(lyr_compare_map_sliders);
3291
3292 lyr_compare_stackedOverlay1 = new google.maps.GroundOverlay(temp_arr[3].split('|')[3], polygon.getBounds(), { clickable: false });
3293 lyr_compare_stackedOverlay1.setMap(lyr_compare_map_sliders);
3294
3295 setTimeout(
3296 function () {
3297
3298 //get bounds for map 1
3299 var bounds = lyr_compare_map_sliders.getBounds();
3300 var ne = bounds.getNorthEast();
3301 var sw = bounds.getSouthWest();
3302 var nw = new google.maps.LatLng(ne.lat(), sw.lng());
3303 var se = new google.maps.LatLng(sw.lat(), ne.lng());
3304
3305 var outMapPolygonCoords = [sw, se, ne, nw];
3306 var ptsDirection = (google.maps.geometry.spherical.computeSignedArea(polygon.getPath()) < 0);
3307
3308 if (!ptsDirection) {
3309 outMapPolygonCoords = [sw, nw, ne, se];
3310 }
3311
3312 polygon2a = new google.maps.Polygon({
3313 paths: [outMapPolygonCoords, polygon.getPath()],
3314 map: lyr_compare_map_sliders,
3315 strokeColor: '#0000ff',
3316 strokeOpacity: 0.6,
3317 strokeWeight: 1,
3318 fillColor: '#FFFFFF',
3319 fillOpacity: 1
3320 });
3321
3322 }, 100)
3323
3324
3325 //legends
3326 $(".lyr_comp_stacked_1_wrapper").show();
3327 $(".lyr_comp_stacked_2_wrapper").show();
3328 $(".lyr_comp_stacked_3_wrapper").show();
3329 $(".lyr_comp_stacked_4_wrapper").show();
3330 if (temp_arr[0].split('|').length == 8) {
3331 //display sub type
3332 $(".lyr_comp_stacked_4_legend").children(0).empty().html(temp_arr[0].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[0].split('|')[7] + " (" + temp_arr[0].split('|')[6] + ")" + "<br/>" + temp_arr[0].split('|')[1].split(' ')[0]);
3333 $(".lyr_comp_stacked_layer_name_4").empty().text(temp_arr[0].split('|')[2].split('_')[1] + " - " + temp_arr[0].split('|')[6] + " (" + temp_arr[0].split('|')[1].split(' ')[0] + ")");
3334 }
3335 else {
3336 $(".lyr_comp_stacked_4_legend").children(0).empty().html(temp_arr[0].split('|')[2].split('_')[1] + " (" + temp_arr[0].split('|')[6] + ")<br/>" + temp_arr[0].split('|')[1].split(' ')[0]);
3337 $(".lyr_comp_stacked_layer_name_4").empty().text(temp_arr[0].split('|')[2].split('_')[1] + " (" + temp_arr[0].split('|')[6] + ") - " + temp_arr[0].split('|')[1].split(' ')[0]);
3338 }
3339 if (temp_arr[1].split('|').length == 8) {
3340 //display sub type
3341 $(".lyr_comp_stacked_3_legend").children(0).empty().html(temp_arr[1].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[1].split('|')[7] + " (" + temp_arr[1].split('|')[6] + ")" + "<br/>(" + temp_arr[1].split('|')[1].split(' ')[0] + ")");
3342 $(".lyr_comp_stacked_layer_name_3").empty().text(temp_arr[1].split('|')[2].split('_')[1] + " - " + temp_arr[1].split('|')[6] + " (" + temp_arr[1].split('|')[1].split(' ')[0] + ")");
3343 }
3344 else {
3345 $(".lyr_comp_stacked_3_legend").children(0).empty().html(temp_arr[1].split('|')[2].split('_')[1] + " (" + temp_arr[1].split('|')[6] + ")<br/>" + temp_arr[1].split('|')[1].split(' ')[0]);
3346 $(".lyr_comp_stacked_layer_name_3").empty().text(temp_arr[1].split('|')[2].split('_')[1] + " (" + temp_arr[1].split('|')[6] + ") - " + temp_arr[1].split('|')[1].split(' ')[0]);
3347 }
3348 if (temp_arr[2].split('|').length == 8) {
3349 //display sub type
3350 $(".lyr_comp_stacked_2_legend").children(0).empty().html(temp_arr[2].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[2].split('|')[7] + " (" + temp_arr[2].split('|')[6] + ")" + "<br/>(" + temp_arr[2].split('|')[1].split(' ')[0] + ")");
3351 $(".lyr_comp_stacked_layer_name_2").empty().text(temp_arr[2].split('|')[2].split('_')[1] + " - " + temp_arr[2].split('|')[6] + " (" + temp_arr[2].split('|')[1].split(' ')[0] + ")");
3352 }
3353 else {
3354 $(".lyr_comp_stacked_2_legend").children(0).empty().html(temp_arr[2].split('|')[2].split('_')[1] + " (" + temp_arr[2].split('|')[6] + ")<br/>" + temp_arr[2].split('|')[1].split(' ')[0]);
3355 $(".lyr_comp_stacked_layer_name_2").empty().text(temp_arr[2].split('|')[2].split('_')[1] + " (" + temp_arr[2].split('|')[6] + ") - " + temp_arr[2].split('|')[1].split(' ')[0]);
3356 }
3357 if (temp_arr[3].split('|').length == 8) {
3358 //display sub type
3359 $(".lyr_comp_stacked_1_legend").children(0).empty().html(temp_arr[3].split('|')[2].split('_')[1] + "<br/>" + " " + temp_arr[3].split('|')[7] + " (" + temp_arr[3].split('|')[6] + ")" + "<br/>(" + temp_arr[3].split('|')[1].split(' ')[0] + ")");
3360 $(".lyr_comp_stacked_layer_name_1").empty().text(temp_arr[3].split('|')[2].split('_')[1] + " - " + temp_arr[3].split('|')[6] + " (" + temp_arr[3].split('|')[1].split(' ')[0] + ")");
3361 }
3362 else {
3363 $(".lyr_comp_stacked_1_legend").children(0).empty().html(temp_arr[3].split('|')[2].split('_')[1] + " (" + temp_arr[3].split('|')[6] + ")<br/>" + temp_arr[3].split('|')[1].split(' ')[0]);
3364 $(".lyr_comp_stacked_layer_name_1").empty().text(temp_arr[3].split('|')[2].split('_')[1] + " (" + temp_arr[3].split('|')[6] + ") - " + temp_arr[3].split('|')[1].split(' ')[0]);
3365 }
3366
3367
3368 $(".lyr_comp_stacked_4_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[0].split('|')[2].split('_')[1]) + temp_arr[0].split('|')[4]);
3369 $(".lyr_comp_stacked_3_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[1].split('|')[2].split('_')[1]) + temp_arr[1].split('|')[4]);
3370 $(".lyr_comp_stacked_2_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[2].split('|')[2].split('_')[1]) + temp_arr[2].split('|')[4]);
3371 $(".lyr_comp_stacked_1_legend").children(1).attr("src", lyr_compare_urlLegendPath(temp_arr[3].split('|')[2].split('_')[1]) + temp_arr[3].split('|')[4]);
3372
3373 $(".lyr_comp_stacked_4_wrapper").parent().show();
3374 $(".lyr_comp_stacked_3_wrapper").parent().show();
3375 $(".lyr_comp_stacked_2_wrapper").parent().show();
3376 $(".lyr_comp_stacked_1_wrapper").parent().show();
3377
3378 $(".lyr_comp_stacked_4_legend").show();
3379 $(".lyr_comp_stacked_3_legend").show();
3380 $(".lyr_comp_stacked_2_legend").show();
3381 $(".lyr_comp_stacked_1_legend").show();
3382 $(".lyr_compare_stacked").show();
3383
3384 if (!$("#instantiated").hasClass("instantiated")) {
3385 $('#windowMap_5a_1_slider').slider({
3386 min: 0,
3387 max: 1,
3388 step: 0.01,
3389 value: 1,
3390 orientation: "horizontal",
3391 slide: function (e, ui) { polygon2a.setOptions({ fillOpacity: ui.value }); }
3392 })
3393
3394 $("#windowMap_5a_1_slider").addClass("instantiated");
3395 }
3396
3397 $('#windowMap_5a_1_slider').parent().removeAttr("class").addClass("windowMap_4a_1_slider_wrapper_3_view");
3398
3399 lyr_comp_bind2Slider(4);
3400 break;
3401 }
3402
3403
3404
3405 }
3406 else {
3407 $(".lyr_compareLayrs_error_msg").empty().text(txtLyrComp6).show();
3408 }
3409});
3410
3411
3412
3413
3414function drawEdgesPoly(poly) {
3415 // shape is the original, parent polygon
3416 var map = new google.maps.Map(document.getElementById('windowMap_2a_1'));
3417 var shape = poly;
3418 // set padding constant to 1 (i.e. 1m distance all around)
3419 padding = 100;
3420
3421 var vertices = shape.getPath();
3422 var polybounds = new google.maps.LatLngBounds();
3423 for (var i = 0; i < vertices.getLength() ; i++) {
3424 polybounds.extend(vertices.getAt(i));
3425 }
3426 var center = polybounds.getCenter();
3427 var centerMarker = new google.maps.Marker({
3428 position: center,
3429 map: map,
3430 icon: {
3431 url: "https://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle.png",
3432 size: new google.maps.Size(7, 7),
3433 anchor: new google.maps.Point(4, 4)
3434 }
3435 });
3436 var polylines = [];
3437 var newPath = [];
3438 for (var i = 0; i < vertices.getLength() ; i++) {
3439 polylines.push(new google.maps.Polyline({
3440 path: [center, vertices.getAt(i)],
3441 map: map,
3442 strokeWidth: 2,
3443 strokeColor: 'red'
3444 }));
3445 newPath[i] = google.maps.geometry.spherical.computeOffset(center,
3446 padding + google.maps.geometry.spherical.computeDistanceBetween(center, vertices.getAt(i)),
3447 google.maps.geometry.spherical.computeHeading(center, vertices.getAt(i)));
3448 }
3449 // render outer shape
3450 var outer = new google.maps.Polygon({
3451 strokeColor: 'white',
3452 strokeOpacity: 0.8,
3453 strokeWeight: 1,
3454 fillColor: 'black',
3455 fillOpacity: 0.35,
3456 map: map,
3457 editable: false,
3458 path: newPath
3459 });
3460};
3461
3462
3463$(document).on("click", ".lyr_compare_modal_back", function () {
3464 $("#compareFieldLayersStage3").modal("hide");
3465 $("#compareFieldLayers").modal("show");
3466 $(".lyr_compare_stage2").show();
3467 $(".lyr_compare_stage1").hide();
3468});
3469
3470function lyr_comp_bind2ThreeImgSlider() {
3471 $(".handle_2").draggable({
3472 axis: "x",
3473 containment: "parent",
3474 drag: function () {
3475
3476 var position = $(this).position();
3477 var positionExtra = position.left -22;
3478
3479 if (positionExtra >= ($(".handle_1").position().left - 42)) {
3480 if ($(".handle_1").position().left < 1030) {
3481 $(".handle_1").attr("style", "left:" + (positionExtra + 42) + "px");
3482 //sort out focus on drag icon
3483 $(".handle_2").addClass("handle_index");
3484 $(".handle_1").removeClass("handle_index");
3485 $(".coverImage_1").width((positionExtra - 42) + "px");
3486 }
3487
3488 }
3489
3490 $(".coverImage_2").width(positionExtra + "px");
3491 }
3492 });
3493
3494 $(".handle_1").draggable({
3495 axis: "x",
3496 containment: "parent",
3497 drag: function () {
3498
3499 var position = $(this).position();
3500 var positionExtra = position.left;
3501
3502
3503 if (positionExtra <= ($(".handle_2").position().left)) {
3504 $(".handle_2").attr("style", "left:" + (positionExtra - 22) + "px");
3505 //sort out focus on drag icon
3506 $(".handle_1").addClass("handle_index");
3507 $(".handle_2").removeClass("handle_index");
3508 $(".coverImage_2").width((positionExtra - 42) + "px");
3509 }
3510
3511 $(".coverImage_1").width((positionExtra - 22) + "px");
3512
3513 }
3514 });
3515}
3516
3517function lyr_comp_bind2TwoImgSlider() {
3518 $(".handle").draggable({
3519 axis: "x",
3520 containment: "parent",
3521 drag: function () {
3522 var position = $(this).position();
3523 var positionExtra = position.left;
3524 $(".coverImage").width(positionExtra + "px");
3525 }
3526 });
3527}
3528
3529function lyr_compare_stackedOpacityOverlay(slideItem, val) {
3530
3531 switch (slideItem) {
3532 case 1:
3533 lyr_compare_stackedOverlay1.setOpacity(val);
3534 break;
3535 case 2:
3536 lyr_compare_stackedOverlay2.setOpacity(val);
3537 break;
3538 case 3:
3539 lyr_compare_stackedOverlay3.setOpacity(val);
3540 break;
3541 case 4:
3542 lyr_compare_stackedOverlay4.setOpacity(val);
3543 break;
3544 }
3545
3546}
3547
3548function lyr_comp_bind2Slider(imgCount) {
3549
3550
3551 $('#slider4').slider({
3552 min: 0,
3553 max: 1,
3554 step: 0.01,
3555 value: 1,
3556 orientation: "horizontal",
3557 slide: function (e, ui) { lyr_compare_stackedOpacityOverlay(4, ui.value) }
3558 })
3559
3560 $('#slider3').slider({
3561 min: 0,
3562 max: 1,
3563 step: 0.01,
3564 value: 1,
3565 orientation: "horizontal",
3566 slide: function (e, ui) { lyr_compare_stackedOpacityOverlay(3, ui.value) }
3567 })
3568
3569 if (imgCount == 3) {
3570
3571 $('#slider2').slider({
3572 min: 0,
3573 max: 1,
3574 step: 0.01,
3575 value: 1,
3576 orientation: "horizontal",
3577 slide: function (e, ui) { lyr_compare_stackedOpacityOverlay(2, ui.value) }
3578 })
3579 }
3580 if (imgCount == 4) {
3581
3582 $('#slider2').slider({
3583 min: 0,
3584 max: 1,
3585 step: 0.01,
3586 value: 1,
3587 orientation: "horizontal",
3588 slide: function (e, ui) { lyr_compare_stackedOpacityOverlay(2, ui.value) }
3589 })
3590
3591 $('#slider1').slider({
3592 min: 0,
3593 max: 1,
3594 step: 0.01,
3595 value: 1,
3596 orientation: "horizontal",
3597 slide: function (e, ui) { lyr_compare_stackedOpacityOverlay(1, ui.value) }
3598 })
3599 }
3600};
3601
3602function lyr_compare_clearSliderModal() {
3603 $(".lyr_comp_stacked_1_legend p").empty();
3604 $(".lyr_comp_stacked_1_legend img").attr("src", "");
3605
3606 $(".lyr_comp_stacked_2_legend p").empty();
3607 $(".lyr_comp_stacked_2_legend img").attr("src", "");
3608
3609 $(".lyr_comp_stacked_3_legend p").empty();
3610 $(".lyr_comp_stacked_3_legend img").attr("src", "");
3611
3612 $(".lyr_comp_stacked_4_legend p").empty();
3613 $(".lyr_comp_stacked_4_legend img").attr("src", "");
3614
3615 $(".lyr_comp_stacked_1_wrapper").hide();
3616 $(".lyr_comp_stacked_2_wrapper").hide();
3617 $(".lyr_comp_stacked_3_wrapper").hide();
3618 $(".lyr_comp_stacked_4_wrapper").hide();
3619}
3620
3621function lyr_compare_urlLegendPath(type) {
3622
3623 switch (type) {
3624 case "N-Sensor":
3625 return "https://api.mi.farm/static/images/nsensor/";
3626 break;
3627 case "MiSat Field View":
3628 case "MiSat Farm View":
3629 case "MiSat Variety View":
3630 return "https://api.mi.farm/static/images/ndvi_v2/";
3631 break;
3632 case "RTK":
3633 return "https://api.mi.farm/static/images/rtk/";
3634 break;
3635 case "UAV":
3636 return "https://api.mi.farm/static/images/uav/";
3637 break;
3638 case "Conductivity":
3639 return "https://api.mi.farm/static/images/conductivity/";
3640 break;
3641 case "MiGrass":
3642 return "https://api.mi.farm/static/images/migrass_v2/";
3643 break;
3644 case "RGB":
3645 return "https://api.mi.farm/static/images/rgb_v2/";
3646 break;
3647 case "Yield":
3648 return "https://api.mi.farm/static/images/yield/";
3649 break;
3650 case "CVI Farm View":
3651 case "CVI Field View":
3652 return "https://api.mi.farm/static/images/cvi/";
3653 break;
3654 case "CIgreen Farm View":
3655 case "CIgreen Field View":
3656 case "CIgreen Variety View":
3657 return "https://api.mi.farm/static/images/cigreen_v2/";
3658 break;
3659 }
3660}
3661
3662$(".lyr_compare_stage1_submit").click(function () {
3663 //get field id for next stage.
3664 $("#lyr_compare_fieldId").val($(".lyr_compare_stage1_field_dll").find(":selected").val());
3665 $(".lyr_compare_stage1").hide();
3666
3667 $(".lyr_compare_viewtype").hide();
3668 //got to stage 2
3669
3670 $(".lyr_compare_stage2").show();
3671
3672 switch (gen_lyr_compare_count) {
3673 case 2:
3674 $("#lyr_compare_viewType2").show();
3675 break;
3676 case 3:
3677 $("#lyr_compare_viewType3").show();
3678 break;
3679 case 4:
3680 $("#lyr_compare_viewType4").show();
3681 break;
3682
3683 }
3684 //$.ajax({
3685 // url: urlPrepend + "/layerdata/lyr_comparison_layers_" + $("#lyr_compare_fieldId").val()
3686 //}).done(function (data) {
3687
3688 //});
3689
3690})
3691
3692$("#lyr_compareLayrs_closeModal").click(function () {
3693 $("#compareFieldLayers").modal("hide");
3694});
3695
3696
3697$("#lyr_compareLayrs_closeModalStage3").click(function () {
3698 $("#compareFieldLayersStage3").modal("hide");
3699});
3700
3701$("#lyr_compareLayrs_closeModalStage3_Top").click(function () {
3702 $("#compareFieldLayersStage3").modal("hide");
3703
3704 //check to see how many layers have been selected then unbind sliders
3705 var lyr_compare_count = $(".lyr_compare_storage_item").length;
3706
3707 if (lyr_compare_count < 3){
3708 $("#slider4").slider("option", "slide", "");
3709 $("#slider3").slider("option", "slide", "");
3710 }
3711 if (lyr_compare_count < 4) {
3712 $("#slider2").slider("option", "slide", "");
3713 }
3714 if (lyr_compare_count < 5) {
3715 $("#slider1").slider("option", "slide", "");
3716 }
3717
3718});
3719
3720function lyr_compCheck(str) {
3721
3722 var tempReturnVal = false;
3723
3724 $(".lyr_compare_wrapper_storage").children().each(function () {
3725 if ($(this).attr("rel") == str) {
3726 tempReturnVal = true;
3727 }
3728 });
3729
3730 return tempReturnVal;
3731}
3732
3733
3734$(document).on("click", ".lyr_compare_delete_lyr_item", function () {
3735
3736 var selectedVal = $(this).attr("rel");
3737 $(this).parent().remove();
3738 if (gen_lyr_compare_count < 5) {
3739
3740 $(".lyr_compare_storage_item").each(function () {
3741 if ($(this).attr("rel") == selectedVal) {
3742 //remove item
3743 $(this).remove();
3744 gen_lyr_compare_count--;
3745 }
3746 })
3747 }
3748
3749 if (gen_lyr_compare_count == 1) {
3750 $(".lyr_compare_overview_wrapper").empty().append("<p class=\"lyr_compare_message\">" + txtLyrComp3 + "</p>");
3751 $(".lyr_compare_stage1_submit").prop('disabled', true);
3752 $(".lyr_compareLayrs_error_msg").empty().hide();
3753 }
3754 else {
3755
3756 //we need to check field names again,
3757
3758
3759 var temp_firstFieldName = "";
3760 var temp_bMatchingFields = true;
3761
3762 $(".lyr_compare_storage_item").each(function () {
3763 var tempString = $(this).attr("rel").split('|');
3764
3765 if (temp_firstFieldName == "") {
3766 //not assigned yet.
3767 temp_firstFieldName = tempString[5];
3768 }
3769
3770 if (temp_firstFieldName != tempString[5]) {
3771 //alert - fields dont match,
3772 temp_bMatchingFields = false;
3773 }
3774
3775
3776
3777 });
3778
3779
3780 $(".lyr_compare_stage1_submit").prop('disabled', false);
3781 $(".lyr_compareLayrs_error_msg").empty().hide();
3782
3783
3784 if (temp_bMatchingFields) {
3785 //we have data for one field
3786 $(".lyr_compare_stage1_submit").prop('disabled', false);
3787 }
3788 else {
3789 //we have data for different fields
3790 $(".lyr_compare_fieldName").empty();
3791 $(".lyr_compare_stage1_submit").prop('disabled', true);
3792 $(".lyr_compareLayrs_error_msg").empty().show().text(txtLyrComp4);
3793 }
3794 }
3795});
3796
3797
3798$(document).on("click", ".lyr_compare_modal_lnk", function () {
3799
3800 $("#compareFieldLayers").modal({ backdrop: 'static', keyboard: false });
3801 $("#compareFieldLayers .modal-dialog").attr("style", "width:90%;");
3802
3803 //close left panel
3804 $("#leftDetailsPanel").hide();
3805
3806 //open modal stage 1
3807 $("#compareFieldLayers").modal("show");
3808 $(".lyr_compare_stage2").hide();
3809 $(".lyr_compare_stage1").show();
3810 //need to add a check to see if all layers selected are for one field. Display error message if not.
3811
3812 //get selected items
3813 if (gen_lyr_compare_count > 0) {
3814 if (gen_lyr_compare_count > 1) {
3815 var temp_contentString = "";
3816 var temp_firstFieldName = "";
3817 var temp_bMatchingFields = true;
3818
3819 $(".lyr_compare_storage_item").each(function () {
3820
3821 var tempString = $(this).attr("rel").split('|');
3822
3823 if (temp_firstFieldName == "") {
3824 //not assigned yet.
3825 temp_firstFieldName = tempString[5];
3826 }
3827
3828 if (temp_firstFieldName != tempString[5]) {
3829 //alert - fields dont match,
3830 temp_bMatchingFields = false;
3831 }
3832
3833
3834 $(".lyr_compare_fieldName").empty().text("for " + tempString[5]);
3835 if (tempString[7] != null) {
3836 temp_contentString += "<p><span class=\"glyphicon glyphicon-remove lyr_compare_delete_lyr_item\" rel=\"" + $(this).attr("rel") + "\"></span>" + tempString[2].split('_')[1] + " " + tempString[7] + " - " + tempString[1].split(' ')[0] + " (" + tempString[5] + ")</p>";
3837
3838 }
3839 else {
3840 temp_contentString += "<p><span class=\"glyphicon glyphicon-remove lyr_compare_delete_lyr_item\" rel=\"" + $(this).attr("rel") + "\"></span>" + tempString[2].split('_')[1] + " - " + tempString[1].split(' ')[0] + " (" + tempString[5] + ")</p>";
3841
3842 }
3843 });
3844
3845
3846 if (temp_contentString != "") {
3847 $(".lyr_compare_overview_wrapper").empty().append(temp_contentString);
3848 $(".lyr_compare_stage1_submit").prop('disabled', false);
3849
3850
3851 if (temp_bMatchingFields) {
3852 //we have data for one field
3853 $(".lyr_compare_stage1_submit").prop('disabled', false);
3854 }
3855 else {
3856 //we have data for different fields
3857 $(".lyr_compare_fieldName").empty();
3858 $(".lyr_compare_stage1_submit").prop('disabled', true);
3859 $(".lyr_compareLayrs_error_msg").empty().show().text(txtLyrComp4);
3860 }
3861 }
3862
3863 }
3864 else {
3865
3866 $(".lyr_compare_overview_wrapper").empty().append("<p class=\"lyr_compare_message\">" + txtLyrComp3 + "</p>");
3867 $(".lyr_compare_stage1_submit").prop('disabled', true);
3868 }
3869
3870 }
3871 else {
3872 //no items
3873 $(".lyr_compare_overview_wrapper").empty().append("<p class=\"lyr_compare_message\">" + txtLyrComp2 + "</p>");
3874 $(".lyr_compare_stage1_submit").prop('disabled', true);
3875
3876 }
3877});
3878
3879function lyr_clear_NVZ() {
3880 for (var i = 0; i < im_nvz_polygon_overlay.length; i++) {
3881 im_nvz_polygon_overlay[i].setMap(null);
3882 }
3883 im_nvz_polygon_overlay = [];
3884}
3885
3886
3887
3888
3889function lyr_getHarvestDatesData() {
3890
3891 lyr_hideHarvestDatesLayer();
3892 $(".layer-item-harvest-dates").find(".layer_item_loader").show();
3893 loadStatus("Loading Harvest Dates");
3894 $.ajax({
3895 type: "POST",
3896 url: urlPrepend + "/layerdata/harvest-dates",
3897 data: { tradingId: getTradingId(), farmId: getFarmId() }
3898 }).done(function (data) {
3899
3900 if (data.length > 0) {
3901 var t = JSON.parse(data);
3902
3903 for (var i = 0; i < t.length; i++) {
3904 if (t[i].dates != null) {
3905 var temp_harvest_obj = {}
3906 var temp_dates = [];
3907 for (var j = 0; j < t[i].dates.length; j++) {
3908 temp_dates.push(t[i].dates[j].toString().split(' ')[0].replace(new RegExp("\\/", "g"), "-"))
3909 }
3910 temp_harvest_obj.date = temp_dates;
3911 temp_harvest_obj.fieldId = t[i].fieldId;
3912 lyr_harvest_dates.push(temp_harvest_obj);
3913 temp_dates = [];
3914 }
3915 }
3916 lyr_sortHarvestData();
3917 }
3918 });
3919}
3920
3921
3922function lyr_sortHarvestData() {
3923
3924 var temp_dates = [];
3925 var temp_reverse_harvest_dates_arr = [];
3926
3927 if (lyr_harvest_dates.length > 0){
3928 for (var i = 0; i < lyr_harvest_dates.length; i++) {
3929 //get date first
3930 for (var j = 0; j < lyr_harvest_dates[i].date.length; j++) {
3931 temp_dates.push(lyr_harvest_dates[i].date[j]);
3932 }
3933 }
3934 }
3935
3936 if (temp_dates.length > 0) {
3937 //remove duplicates
3938 var uniqueItems = [];
3939 //strip out dups
3940 $.each(temp_dates, function (i, el) {
3941 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
3942 });
3943
3944 //now lets build the final datasets
3945 for (var k = 0; k < uniqueItems.length; k++) {
3946 var temp_reverse_harvest_obj = {}
3947 var temp_fields = [];
3948 ////build list of fields for dates
3949 for (var m = 0; m < lyr_harvest_dates.length; m++) {
3950
3951 for (var n = 0; n < lyr_harvest_dates[m].date.length; n++) {
3952 if (lyr_harvest_dates[m].date[n] == uniqueItems[k]) {
3953 //we have a match
3954 //get field id for this match
3955 temp_fields.push(lyr_harvest_dates[m].fieldId);
3956 }
3957 }
3958 }
3959 temp_reverse_harvest_obj.date = uniqueItems[k];
3960 temp_reverse_harvest_obj.fields = temp_fields;
3961 temp_reverse_harvest_dates_arr.push(temp_reverse_harvest_obj);
3962 temp_fields = [];
3963 }
3964
3965 }
3966
3967 lyr_setHravestDateCal(temp_reverse_harvest_dates_arr);
3968}
3969
3970function lyr_hideHarvestDatesCal() {
3971 var layerId = $(".layer-item-harvest-dates").attr("id");
3972 $(".layerInfo").each(function () {
3973
3974 if ($(this).attr("rel") == layerId) {
3975 $(this).empty().hide();
3976 }
3977 });
3978}
3979
3980function lyr_setHravestDateCal(harvestArr) {
3981 var layerId = $(".layer-item-harvest-dates").attr("id");
3982 $(".layer-item-harvest-dates").find(".layer_item_loader").hide();
3983 removeLoader();
3984 $(".layerInfo").each(function () {
3985
3986 if ($(this).attr("rel") == layerId) {
3987 $(this).show();
3988 if ($(this).children().length == 0) {
3989 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><p class=\"harvest_date_selected\"></p><div class=\"left_panel_calendar harvest_date_cal\"></div></div>");
3990 }
3991 $(this).children().show();
3992 }
3993 });
3994
3995 //set date array for calendar
3996 lyr_arr_harvest_dates = [];
3997
3998 for (var i = 0; i < harvestArr.length; i++) {
3999
4000 var splitDate = harvestArr[i].date.split('-');
4001 var d = splitDate[0];
4002 var m = splitDate[1];
4003 var y = splitDate[2];
4004
4005 lyr_arr_harvest_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
4006 }
4007
4008
4009 var sortedDates = lyr_arr_harvest_dates.sort(function (date1, date2) { return new Date(date1).getTime() - new Date(date2).getTime() });
4010
4011 //display calendar
4012 $(".harvest_date_cal").datepicker({
4013 beforeShowDay: function (date) {
4014 return (lyr_arr_harvest_dates.indexOf(date.toISOString()) > -1) ? [true, "harvest_calendar_date"] : [false, ""];
4015 },
4016 dateFormat: "dd-mm-yy",
4017 defaultDate: new Date(lyr_arr_harvest_dates[0]),
4018 minDate: new Date(lyr_arr_harvest_dates[0]),
4019 maxDate: new Date(lyr_arr_harvest_dates[lyr_arr_harvest_dates.length - 1]),
4020 onSelect: function (data) {
4021 lyr_hideHarvestDatesLayer();
4022 lyr_displayHarvestDateOverlay(data, harvestArr);
4023 }
4024 });
4025}
4026
4027function lyr_displayHarvestDateOverlay(date, harvestArr) {
4028
4029
4030 $(".harvest_date_selected").text("Date selected " + date);
4031
4032 for (var i = 0; i < harvestArr.length; i++) {
4033 if (harvestArr[i].date == date) {
4034 //we have a match. get fieldids
4035 if (harvestArr[i].fields.length > 0) {
4036 for (var j = 0; j < harvestArr[i].fields.length; j++) {
4037 for (var n = 0; n < polygonsArray.length; n++) {
4038 if ((polygonsArray[n].id) == harvestArr[i].fields[j]) {
4039
4040 var fieldboundary = new google.maps.MVCArray();
4041 for (var p = 0; p < polygonsArray[n].getPath().getLength() ; p++) {
4042 fieldboundary.push(new google.maps.LatLng(polygonsArray[n].getPath().getAt(p).lat(), polygonsArray[n].getPath().getAt(p).lng()));
4043 }
4044
4045 var polygon = new google.maps.Polygon({
4046 paths: fieldboundary,
4047 map: map,
4048 strokeColor: '#000000',
4049 strokeOpacity: 1,
4050 strokeWeight: 1,
4051 fillColor: "#FFFF00",
4052 fillOpacity: 1,
4053 zIndex: 2,
4054 id: harvestArr[i].fields[j]
4055 });
4056
4057 lyr_harvest_overlay.push(polygon);
4058 }
4059 }
4060 }
4061 }
4062 }
4063 }
4064}
4065
4066function lyr_hideHarvestDatesLayer() {
4067 for (var i = 0; i < lyr_harvest_overlay.length; i++) {
4068 lyr_harvest_overlay[i].setMap(null);
4069 }
4070 lyr_harvest_overlay = [];
4071}
4072
4073var lyr_trackerClickedInfoBox = "";
4074
4075
4076function lyr_removeTrackerVariable() {
4077 lyr_trackerClickedInfoBox = "";
4078}
4079
4080
4081function lyr_trimHarvest(str) {
4082
4083 var temp = calcNameLength(str);
4084
4085 if (temp > 160) {
4086 temp = parseInt(temp) - 80;
4087 }
4088 return temp;
4089}
4090
4091function lyr_getTrackerData() {
4092
4093 //remove all bounding elements if not needed when going live,
4094 // var lyr_tracker_bounds = new google.maps.LatLngBounds();
4095
4096 $.ajax({
4097 type: "POST",
4098 url: urlPrepend + "/layerdata/trackers",
4099 data: { tradingId: getTradingId() }
4100 }).done(function (data) {
4101
4102 if (lyr_tracker_loop) {
4103 var t = JSON.parse(data);
4104 if (t.length > 0) {
4105
4106
4107 lyr_hideTrackers();
4108
4109 for (var i = 0; i < t.length; i++) {
4110
4111 //place icons on map
4112 var marker = new google.maps.Marker({
4113 position: new google.maps.LatLng(t[i].lat, t[i].lng),
4114 map: map,
4115 icon: "https://portal.precisiondecisions.co.uk/images/icons/trackers/" + t[i].icon,
4116 title: t[i].vehicle,
4117 id:i
4118 })
4119
4120 //set infobox
4121 lyr_tracker_info_overlay.push(new InfoBox({
4122 content: "<div style=\"padding:2px 1px 2px\">" + t[i].vehicle + " (" + t[i].reg + ")</div>",
4123 disableAutoPan: true,
4124 pixelOffset: new google.maps.Size(-5, 0),
4125 zIndex: null,
4126 boxStyle: {
4127 background: "white",
4128 opacity: 0.8,
4129 width: lyr_trimHarvest(t[i].vehicle + " (" + t[i].reg + ")") + "px"
4130 },
4131 closeBoxMargin: "2px 4px 2px 2px",
4132 closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
4133 infoBoxClearance: new google.maps.Size(1, 1),
4134 boxClass: t[i].id,
4135 position: new google.maps.LatLng(t[i].lat, t[i].lng)
4136 }));
4137
4138 marker.addListener('click', function (event) {
4139
4140
4141 //hide other infoboxes
4142 lyr_hideInfoTracker();
4143
4144 lyr_tracker_info_overlay[this.id].setPosition(event.latLng);
4145 lyr_tracker_info_overlay[this.id].open(map);
4146
4147 lyr_trackerClickedInfoBox = lyr_tracker_info_overlay[this.id].boxClass_;
4148
4149 });
4150
4151
4152 lyr_tracker_overlay.push(marker);
4153
4154 removeStatus();
4155
4156 // lyr_tracker_bounds.extend(new google.maps.LatLng(t[i].lat, t[i].lng));
4157 }
4158
4159
4160 for (var i = 0; i < lyr_tracker_info_overlay.length; i++) {
4161 if (lyr_trackerClickedInfoBox == lyr_tracker_info_overlay[i].boxClass_) {
4162 lyr_tracker_info_overlay[i].setMap(map);
4163 }
4164 }
4165
4166
4167 //////centre map
4168 ////map.panTo(bounds.getCenter());
4169 //////zoom into map, still showing all markers
4170 ////map.fitBounds(bounds);
4171
4172 setTimeout(function () {
4173 lyr_getTrackerData();
4174 }, 2500)
4175 }
4176 else {
4177 //no tracker data returned
4178 removeStatus();
4179 displayErrMsg(txtLyrTracker1);
4180 $(".layer-item-tracker").removeClass("layer_item_selected");
4181 $(".layer-item-tracker").find(".layer_item_loader").hide();
4182 }
4183 }
4184 else {
4185 //hide all of the tracker icons
4186 lyr_tracker_loop = false;
4187 }
4188 });
4189}
4190
4191function lyr_hideInfoTracker() {
4192 for (var i = 0; i < lyr_tracker_info_overlay.length; i++) {
4193 lyr_tracker_info_overlay[i].close();
4194 }
4195}
4196
4197function lyr_hideTrackers() {
4198
4199 for (var i = 0; i < lyr_tracker_overlay.length; i++) {
4200 lyr_tracker_overlay[i].setMap(null);
4201 lyr_tracker_info_overlay[i].close();
4202 lyr_tracker_info_overlay[i].setMap(null);
4203 }
4204
4205 lyr_tracker_info_overlay = [];
4206 lyr_tracker_overlay = [];
4207}
4208
4209
4210function lyr_poi_setMarkers(data, count) {
4211 var lyr_poi_marker = new google.maps.Marker({
4212 position: new google.maps.LatLng(data.latitude, data.longitude),
4213 map: map,
4214 title: data.info,
4215 icon: new google.maps.MarkerImage(fld_poi_marker_old),
4216 id: count
4217 });
4218
4219 var txt = data.info;
4220 google.maps.event.addListener(lyr_poi_marker, 'click', function (txt) {
4221 infowindow.close(); // Close previously opened infowindow
4222 infowindow.setContent("<div class='lyr_poi_info_window'>" + data.info + "</div>");
4223 infowindow.open(map, lyr_poi_marker);
4224 lyr_poi_infoWindow.push(infowindow);
4225 });
4226
4227 lyr_poi_points.push(lyr_poi_marker);
4228}
4229
4230var lyr_poi_geoSuccess = function (position) {
4231 //$(".testinglocationlat").text(position.coords.latitude + " " + t++);
4232 //$(".testinglocationlng").text(position.coords.longitude);
4233
4234
4235 if (lyr_poi_singlePointMarker != null) {
4236 lyr_poi_singlePointMarker.setMap(null);
4237 lyr_poi_singlePointMarker = null;
4238 }
4239
4240 //zoom into this location.
4241 map.setCenter(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
4242 map.setZoom(20);
4243 fld_localisation = true;
4244
4245 //drop draggable pin for current location and display text box and save button
4246 lyr_poi_singlePointMarker = new google.maps.Marker({
4247 position: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
4248 map: map,
4249 draggable: false,
4250 icon: new google.maps.MarkerImage(fld_poi_marker)
4251 });
4252
4253};
4254
4255var lyr_poi_geoError = function (error) {
4256 //console.log('Error occurred. Error code: ' + error.code);
4257 // error.code can be:
4258 // 0: unknown error
4259 // 1: permission denied
4260 // 2: position unavailable (error response from location provider)
4261 // 3: timed out
4262 if (error.code >= 0) {
4263 lyr_poi_localisation = false;
4264 //clear watch incase its on.
4265 navigator.geolocation.clearWatch(fld_poi_watchId);
4266 }
4267};
4268
4269
4270function lyr_getPOILayer() {
4271
4272 //add current location
4273 // check for Geolocation support
4274 if (navigator.geolocation) {
4275
4276 //we need to find the users location and see if its inside the field. If so then zoom into the field further
4277 if (navigator.geolocation) {
4278 lyr_poi_localisation = true;
4279 lay_poi_watchId = navigator.geolocation.watchPosition(lyr_poi_geoSuccess, lyr_poi_geoError, fld_poi_geoOptions);
4280 }
4281 else {
4282 lyr_poi_localisation = false;
4283 //clear watch incase its on.
4284 navigator.geolocation.clearWatch(lay_poi_watchId);
4285 }
4286 }
4287
4288
4289 //get saved points
4290 $.ajax({
4291 type: "POST",
4292 url: urlPrepend + "/layerdata/farm-poi",
4293 data: {farmId: getFarmId() }
4294 }).done(function (data) {
4295 for (var i = 0; i < data.length; i++) {
4296 lyr_poi_setMarkers(data[i], i);
4297 }
4298 setTimeout(function () {
4299 removeStatus();
4300 }, 2000)
4301
4302 });
4303}
4304
4305function lyr_poi_closeInfoBoxes() {
4306 for (var i = 0; i < lyr_poi_infoWindow.length; i++) {
4307 lyr_poi_infoWindow[i].setMap(null);
4308 }
4309}
4310
4311function lyr_hidePOI() {
4312
4313 if (lyr_poi_localisation) {
4314 lyr_poi_localisation = false;
4315 //clear watch incase its on.
4316 navigator.geolocation.clearWatch(lay_poi_watchId);
4317 //remove live location point
4318 if (lyr_poi_singlePointMarker != null) {
4319 lyr_poi_singlePointMarker.setMap(null);
4320 lyr_poi_singlePointMarker = null;
4321 }
4322
4323 }
4324
4325 for (var i = 0; i < lyr_poi_infoWindow.length; i++) {
4326 lyr_poi_infoWindow[i].setMap(null);
4327 }
4328
4329 for (var j = 0; j < lyr_poi_points.length; j++) {
4330 lyr_poi_points[j].setMap(null);
4331 }
4332 lyr_poi_points = [];
4333 lyr_poi_infoWindow = [];
4334}
4335
4336//****** harvest area *******
4337
4338
4339
4340function lyr_loadHarvestAreas() {
4341
4342 //display lock info
4343 $(".lyr_harvest_area_info_wrapper").show();
4344
4345 $.ajax({
4346 type: "POST",
4347 url: urlPrepend + "/layerdata/ui_data-layers_harvest_area",
4348 data: { farmId: getFarmId() }
4349 }).done(function (data) {
4350
4351 var t = JSON.parse(data);
4352 if (t.length > 0) {
4353 var fieldboundary = new google.maps.MVCArray();
4354 lyr_hideTrackers();
4355
4356 var grp = 0;
4357 for (var i = 0; i < t.length; i++) {
4358
4359 if (grp != t[i].grp) {
4360
4361 if (fieldboundary.length > 0) {
4362 lyr_drawHarvestAreaPolygon(fieldboundary);
4363 fieldboundary = [];
4364 }
4365 grp = t[i].grp;
4366 }
4367 fieldboundary.push(new google.maps.LatLng(t[i].lat, t[i].lng));
4368 }
4369 if (fieldboundary.length > 0) {
4370 lyr_drawHarvestAreaPolygon(fieldboundary);
4371 fieldboundary = [];
4372 }
4373
4374 }
4375 removeLoader();
4376
4377 });
4378}
4379
4380function lyr_drawHarvestAreaPolygon(arr) {
4381 debugger;
4382 var polygon = new google.maps.Polygon({
4383 paths: arr,
4384 map: map,
4385 strokeColor: '#d9ff00',
4386 strokeOpacity: 0.8,
4387 strokeWeight: 2,
4388 fillColor: '#0d47a3',
4389 fillOpacity: 0.35
4390 });
4391
4392 lyr_harvest_area_poygons.push(polygon);
4393
4394}
4395
4396function lyr_clear_HarvestAreas() {
4397 debugger;
4398 //only clear if this layer is not locked!
4399 if (!$(".layer-item-harvest-areas").hasClass("lyr_highlight_locked_item")) {
4400 for (var i = 0; i < lyr_harvest_area_poygons.length; i++) {
4401 lyr_harvest_area_poygons[i].setMap(null);
4402 }
4403 lyr_harvest_area_poygons = [];
4404 }
4405}
4406
4407function lyr_clear_True_HarvestAreas() {
4408
4409 for (var i = 0; i < lyr_true_harvest_area_poygons.length; i++) {
4410 lyr_true_harvest_area_poygons[i].setMap(null);
4411 }
4412 lyr_true_harvest_area_poygons = [];
4413
4414}
4415
4416function lyr_getTrue_HarvestedAreas() {
4417 if (lyr_true_harvested_areas_array.length > 0) {
4418 //load polygons
4419 $.ajax({
4420 type: "GET",
4421 url: urlPrepend + "/layerdata/ui_data-layers_harvested_zones_" + lyr_true_harvested_areas_array[0],
4422 }).done(function (data) {
4423
4424 //remove field id from array
4425 lyr_true_harvested_areas_array.shift();
4426
4427 if (data.length > 4) {
4428 var t = JSON.parse(data);
4429
4430 var polygonboundary = new google.maps.MVCArray();
4431 var polygonzoneboundary = new google.maps.MVCArray();
4432 var outerPolygon = true;
4433 var firstZonepoint = true;
4434 var polygonzoneboundaryarr = [];
4435
4436 if (t.hasOwnProperty("polygon")) {
4437 //single polygon
4438 for (var i = 0; i < t.polygon.length; i++) {
4439 if (i == 0) {
4440 //first point in outer polygon
4441 polygon1stPt = new google.maps.LatLng(t.polygon[i].lat, t.polygon[i].lng);
4442 polygonboundary.push(new google.maps.LatLng(t.polygon[i].lat, t.polygon[i].lng));
4443 }
4444 else {
4445 if (outerPolygon) {
4446 polygonboundary.push(new google.maps.LatLng(t.polygon[i].lat, t.polygon[i].lng));
4447 if (polygon1stPt.equals(new google.maps.LatLng(t.polygon[i].lat, t.polygon[i].lng))) {
4448 //end of outer polygon
4449 outerPolygon = false;
4450 }
4451 }
4452 else {
4453
4454 polygonzoneboundary.push(new google.maps.LatLng(t.polygon[i].lat, t.polygon[i].lng));
4455
4456 if (firstZonepoint) {
4457 polygon1stPt = new google.maps.LatLng(t.polygon[i].lat, t.polygon[i].lng);
4458 firstZonepoint = false;
4459
4460 }
4461 else {
4462 if (polygon1stPt.equals(new google.maps.LatLng(t.polygon[i].lat, t.polygon[i].lng))) {
4463 //end of internal polygon
4464 polygonzoneboundaryarr.push(polygonzoneboundary);
4465 polygonzoneboundary = [];
4466 firstZonepoint = true;
4467 }
4468 }
4469
4470 }
4471 }
4472 }
4473
4474
4475 }
4476 else {
4477
4478 if (t.hasOwnProperty("multipolygon")) {
4479 for (var i = 0; i < t.multipolygon.length; i++) {
4480
4481 if (i == 0) {
4482 //first point in outer polygon
4483 polygon1stPt = new google.maps.LatLng(t.multipolygon[i].lat, t.multipolygon[i].lng);
4484 polygonboundary.push(new google.maps.LatLng(t.multipolygon[i].lat, t.multipolygon[i].lng));
4485 }
4486 else {
4487 if (outerPolygon) {
4488 polygonboundary.push(new google.maps.LatLng(t.multipolygon[i].lat, t.multipolygon[i].lng));
4489 if (polygon1stPt.equals(new google.maps.LatLng(t.multipolygon[i].lat, t.multipolygon[i].lng))) {
4490 //end of outer polygon
4491 outerPolygon = false;
4492 }
4493 }
4494 else {
4495
4496 polygonzoneboundary.push(new google.maps.LatLng(t.multipolygon[i].lat, t.multipolygon[i].lng));
4497
4498 if (firstZonepoint) {
4499 polygon1stPt = new google.maps.LatLng(t.multipolygon[i].lat, t.multipolygon[i].lng);
4500 firstZonepoint = false;
4501
4502 }
4503 else {
4504 if (polygon1stPt.equals(new google.maps.LatLng(t.multipolygon[i].lat, t.multipolygon[i].lng))) {
4505 //end of internal polygon
4506 polygonzoneboundaryarr.push(polygonzoneboundary);
4507 polygonzoneboundary = [];
4508 firstZonepoint = true;
4509 }
4510 }
4511
4512 }
4513 }
4514
4515 }
4516 }
4517
4518 }
4519
4520
4521 var polypath = [];
4522 polypath.push(polygonboundary);
4523 for (var i = 0; i < polygonzoneboundaryarr.length; i++) {
4524 polypath.push(polygonzoneboundaryarr[i]);
4525 }
4526
4527 //draw polygon
4528 var polygon = new google.maps.Polygon({
4529 paths: polypath,
4530 map: map,
4531 strokeColor: '#4B0052',
4532 strokeOpacity: 0.8,
4533 strokeWeight: 3,
4534 fillColor: '#FAFA00',
4535 fillOpacity: 0.9
4536 });
4537
4538 lyr_true_harvest_area_poygons.push(polygon);
4539 polygonboundary = [];
4540
4541 }
4542
4543
4544 setTimeout(function () {
4545 lyr_getTrue_HarvestedAreas();
4546 }, 500);
4547
4548 if (lyr_true_harvested_areas_array.length == 0) {
4549
4550 removeLoader();
4551 }
4552
4553
4554
4555 });
4556 }
4557}
4558
4559//H2 Harvested Areas
4560var lyr_true_harvested_areas_array = [];
4561function lyr_getTrue_HarvestedAreas_FieldIds() {
4562
4563
4564 //need to loop through and get all field ids/ use field list to get all ids of fields.
4565 $(".fieldInfo").each(function () {
4566 lyr_true_harvested_areas_array.push($(this).attr("rel"));
4567 });
4568
4569 if (lyr_true_harvested_areas_array.length > 0) {
4570 lyr_getTrue_HarvestedAreas();
4571 }
4572}
4573
4574//Soil Sensor //
4575var lyr_soil_sensor_labels = [];
4576var lyr_soil_sensor = [];
4577
4578function tempConversion(t) {
4579 var f = t;
4580
4581 if (f > 40){
4582 f = ((parseFloat(f) - 32) * 5 / 9).toFixed(2);
4583 }
4584 return f;
4585
4586}
4587
4588
4589function lyr_getSoilSensorLayer() {
4590 $.ajax({
4591 type: "GET",
4592 url: urlPrepend + "/layerdata/lyr_soil_sensors_" + getTradingId(),
4593 }).done(function (data) {
4594 var t = JSON.parse(data);
4595 var lyr_soilSensors_latlngbounds = new google.maps.LatLngBounds();
4596 for (var i = 0; i < t.length; i++) {
4597 //add markers to map
4598
4599 lyr_soilSensors_latlngbounds.extend(new google.maps.LatLng(t[i].lat, t[i].lng));
4600
4601 var marker = new google.maps.Marker({
4602 position: new google.maps.LatLng(t[i].lat, t[i].lng),
4603 map: map,
4604 icon: "http://maps.google.com/mapfiles/ms/icons/yellow-dot.png",
4605 id: t[i].id
4606 });
4607
4608
4609 var text = "";
4610 if (t[i].recordedon != "") {
4611
4612 var thisHum = t[i].humidity.split(',')[0];
4613 if (t[i].humidity.split(',')[0] == "") {
4614 thisHum = t[i].humidity.split(',')[1];
4615 }
4616 var thisTemp = t[i].temp.split(',')[0];
4617 if (t[i].temp.split(',')[0] == "") {
4618 thisTemp = t[i].temp.split(',')[1];
4619 }
4620 if (t[i].temp.split(',')[0] == "0") {
4621 thisTemp = t[i].temp.split(',')[1];
4622 }
4623
4624 text = "<p>Temperature : " + tempConversion(thisTemp) + " ℃</p>";
4625 text += "<p>Moisture : " + thisHum + "</p>";
4626 text += "<p>Recorded On : " + t[i].recordedon.split(':')[0] + ":" + t[i].recordedon.split(':')[1] + "</p>";
4627 }
4628 else {
4629 text = "<p>We currently have no recent data for this sensor.</p>";
4630 }
4631
4632
4633 var infowindow = new google.maps.InfoWindow({
4634 content: text,
4635 id: t[i].id,
4636 pixelOffset: new google.maps.Size(0, -20),
4637 position: new google.maps.LatLng(t[i].lat, t[i].lng)
4638 });
4639
4640 lyr_soil_sensor_labels.push(infowindow);
4641 lyr_soil_sensor.push(marker);
4642
4643 marker.addListener('click', function (event) {
4644
4645 var thisId = this.id;
4646 for (var i = 0; i < lyr_soil_sensor_labels.length; i++) {
4647 if (lyr_soil_sensor_labels[i].id == thisId) {
4648
4649 lyr_soil_sensor_labels[i].setPosition(event.latLng);
4650 lyr_soil_sensor_labels[i].open(map);
4651 }
4652 else {
4653 lyr_soil_sensor_labels[i].close();
4654 }
4655 }
4656 });
4657 };
4658
4659
4660 for (var i = 0; i < polygonsArray.length; i++) {
4661 polygonsArray[i].setOptions({
4662 clickable: false
4663 })
4664 }
4665 removeLoader();
4666 });
4667}
4668
4669function lyr_remove_soilSenors() {
4670 for (var i = 0; i < lyr_soil_sensor.length; i++) {
4671 lyr_soil_sensor[i].setMap(null);
4672 }
4673 lyr_soil_sensor = [];
4674}
4675
4676function lyr_close_soilSenorsInfo() {
4677
4678 for (var i = 0; i < lyr_soil_sensor_labels.length; i++) {
4679 lyr_soil_sensor_labels[i].setMap(null);
4680 }
4681 lyr_soil_sensor_labels = [];
4682}
4683
4684//Weather Forecasting //
4685
4686var lyr_weather_stations = [];
4687var lyr_weather_stations_info = [];
4688var lyr_weather_stations_zone = [];
4689
4690function lyr_getWeatherForcastingLayer() {
4691
4692 $.ajax({
4693 type: "GET",
4694 url: urlPrepend + "/layerdata/lyr_weather_stations_" + getTradingId(),
4695 }).done(function (data) {
4696
4697 var lyr_weatherStation_latlngbounds = new google.maps.LatLngBounds();
4698
4699 for (var i = 0; i < data.length; i++) {
4700 //add markers to map
4701 lyr_weatherStation_latlngbounds.extend(new google.maps.LatLng(data[i].latitude, data[i].longitude));
4702 var marker = new google.maps.Marker({
4703 position: new google.maps.LatLng(data[i].latitude, data[i].longitude),
4704 map: map,
4705 icon: {
4706 url: urlPrepend + "/content/images/weather-station.png"
4707 },
4708 id: data[i].id
4709 });
4710
4711 marker.addListener('click', function (event) {
4712 //load forcast for this weather station.
4713 lyr_getWeatherStaionCurrentPrediction(this.id, event.latLng);
4714
4715 });
4716 //add circle zone
4717 var weatherZone = new google.maps.Circle({
4718 strokeColor: '#1703EA',
4719 strokeOpacity: 0.8,
4720 strokeWeight: 1,
4721 fillColor: '#FFC103',
4722 fillOpacity: 0.25,
4723 map: map,
4724 center: new google.maps.LatLng(data[i].latitude, data[i].longitude),
4725 radius: 1000
4726 })
4727
4728 lyr_weather_stations.push(marker);
4729 lyr_weather_stations_zone.push(weatherZone);
4730
4731 //automatically open infobox
4732 lyr_getWeatherStaionCurrentPrediction(data[i].id, new google.maps.LatLng(data[i].latitude, data[i].longitude))
4733 }
4734
4735
4736
4737 map.fitBounds(lyr_weatherStation_latlngbounds);
4738 removeLoader();
4739 });
4740}
4741
4742function lyr_remove_weatherStations() {
4743 for (var i = 0; i < lyr_weather_stations.length; i++) {
4744 lyr_weather_stations[i].setMap(null);
4745 }
4746 lyr_weather_stations = [];
4747}
4748
4749function lyr_close_weatherStationInfo() {
4750
4751 for (var i = 0; i < lyr_weather_stations_info.length; i++) {
4752 lyr_weather_stations_info[i].setMap(null);
4753 }
4754 lyr_weather_stations_info = [];
4755}
4756
4757function lyr_hide_weatherZone() {
4758
4759 for (var i = 0; i < lyr_weather_stations_zone.length; i++) {
4760 lyr_weather_stations_zone[i].setMap(null);
4761 }
4762 lyr_weather_stations_zone = [];
4763}
4764
4765function lyr_weather_dataFormat(str) {
4766
4767 var temp_return_val = "--";
4768
4769 if (str != "") {
4770 if (str != "-1") {
4771 temp_return_val = parseFloat(str).toFixed(1);
4772 }
4773
4774 if (temp_return_val == "0.0" || temp_return_val == "-0.0"){
4775 temp_return_val = "--";
4776 }
4777 }
4778
4779 return temp_return_val;
4780
4781}
4782
4783
4784
4785function lyr_getWeatherStaionCurrentPrediction(id, pos) {
4786 lyr_close_weatherStationInfo();
4787
4788 $.ajax({
4789 type: "GET",
4790 url: urlPrepend + "/layerdata/lyr_weather_forecast_stations_" + id,
4791 }).done(function (data) {
4792
4793 var t = JSON.parse(data);
4794
4795 //how many columns do we need?
4796 //int
4797 var tble_col_count = 2;
4798 if (t[0].hasOwnProperty("prediction1hr")) {
4799 if (t[0].prediction1hr.hasdata != "0") {
4800 tble_col_count = 3;
4801 }
4802 }
4803 if (t[0].hasOwnProperty("prediction2hr")) {
4804 if (t[0].prediction2hr.hasdata != "0") {
4805 tble_col_count = 4;
4806 }
4807 }
4808 if (t[0].hasOwnProperty("prediction3hr")) {
4809 if (t[0].prediction3hr.hasdata != "0") {
4810 tble_col_count = 5;
4811 }
4812 }
4813 if (t[0].hasOwnProperty("prediction6hr")) {
4814 if (t[0].prediction6hr.hasdata != "0") {
4815 tble_col_count = 6;
4816 }
4817 }
4818 if (t[0].hasOwnProperty("prediction12hr")) {
4819 if (t[0].prediction12hr.hasdata != "0") {
4820 tble_col_count = 7;
4821 }
4822 }
4823
4824 var content = "<table class=\"lyr_weather_station_prediction_tbl\"><tr><th colspan=\"" + tble_col_count + "\"><b>" + t[0].current.station + "</b></th></tr>";
4825 switch (tble_col_count) {
4826 case 3:
4827 content += lyr_weatherBalloonPredictionData_1(t);
4828 break;
4829 case 4:
4830 content += lyr_weatherBalloonPredictionData_2(t);
4831 break;
4832 case 5:
4833 content += lyr_weatherBalloonPredictionData_3(t);
4834 break;
4835 case 6:
4836 content += lyr_weatherBalloonPredictionData_6(t);
4837 break;
4838 case 7:
4839 content += lyr_weatherBalloonPredictionData_12(t);
4840 break;
4841 }
4842
4843 content +="<tr><td colspan=\"" + tble_col_count + "\"><small>The user assumes the entire risk related to use of weather information in MiFarm. Precision Decisions provides weather information \"as is\", and disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties for a particular purpose. In no event will Precision Decisions be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of this data.</small></td></tr>"
4844
4845 content += "</table>";
4846
4847 var lyr_weather_infowindow = new google.maps.InfoWindow({
4848 content: content,
4849 pixelOffset: new google.maps.Size(0, -20),
4850 position: pos,
4851 zIndex: 2,
4852 id: 1
4853 });
4854
4855
4856
4857
4858 lyr_weather_infowindow.open(map);
4859 lyr_weather_stations_info.push(lyr_weather_infowindow);
4860
4861 });
4862
4863
4864}
4865
4866function lyr_weatherBalloonPredictionData_1(t) {
4867
4868 var content = "<tr><th class=\"lyr_weather_station_prediction_th1\"></th><th class=\"lyr_weather_station_prediction_th\"><u>Current</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 1hr</u></th></tr>";
4869 content += "<tr><td style=\"lyr_weather_station_prediction_td_title\">Temp</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.temp).toFixed(1) + "℃</td>";
4870 //row 1, col 2
4871 if (t[0].prediction1hr.hasdata != "0") {
4872 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.temp).toFixed(1) + "℃</td>";
4873 content += "</tr>";
4874 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
4875 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.humidity).toFixed(1) + "%</td>";
4876 content += "</tr>";
4877 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
4878 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction1hr.windspeed) * 100)) / 100 + "</td>";
4879 content += "</tr>";
4880 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.winddirection + "</td>";
4881 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.winddirection).toFixed(1) + " °</td>";
4882 content += "</tr>";
4883 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
4884 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.dewpoint).toFixed(1) + "℃</td>";
4885 content += "</tr>";
4886 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
4887 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rain) + "</td>";
4888 content += "</tr>";
4889 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
4890 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rainrate) + "</td>";
4891 content += "</tr>";
4892 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
4893 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
4894 content += "</tr>";
4895 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
4896 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction1hr.added_on.substring(0, t[0].prediction1hr.added_on.length - 3) + "</td>";
4897 content += "</tr>";
4898 }
4899 else {
4900 content += "<td></td>";
4901 content += "<td></td>";
4902 content += "</tr>";
4903 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
4904 content += "<td></td>";
4905 content += "</tr>";
4906 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
4907 content += "<td></td>";
4908 content += "</tr>";
4909 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.winddirection).toFixed(1) + " °</td>";
4910 content += "<td></td>";
4911 content += "</tr>";
4912 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
4913 content += "<td></td>";
4914 content += "</tr>";
4915 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
4916 content += "<td></td>";
4917 content += "</tr>";
4918 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
4919 content += "<td></td>";
4920 content += "</tr>";
4921 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
4922 content += "<td></td>";
4923 content += "</tr>";
4924 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
4925 content += "<td></td>";
4926 content += "</tr>";
4927 }
4928
4929 return content;
4930}
4931
4932function lyr_weatherBalloonPredictionData_2(t) {
4933
4934 var content = "<tr><th></th><th class=\"lyr_weather_station_prediction_th\"><u>Current</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 1hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 2hr</u></th></tr>";
4935 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Temp</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.temp).toFixed(1) + "℃</td>";
4936 //row 1, col 2
4937 if (t[0].prediction2hr.hasdata != "0") {
4938 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.temp).toFixed(1) + "℃</td>";
4939 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.temp).toFixed(1) + "℃</td>";
4940 content += "</tr>";
4941 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
4942 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.humidity).toFixed(1) + "%</td>";
4943 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.humidity).toFixed(1) + "%</td>";
4944 content += "</tr>";
4945 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
4946 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction1hr.windspeed) * 100)) / 100 + "</td>";
4947 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction2hr.windspeed) * 100)) / 100 + "</td>";
4948 content += "</tr>";
4949 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.winddirection + "</td>";
4950 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.winddirection).toFixed(1) + " °</td>";
4951 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.winddirection).toFixed(1) + " °</td>";
4952 content += "</tr>";
4953 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
4954 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.dewpoint).toFixed(1) + "℃</td>";
4955 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.dewpoint).toFixed(1) + "℃</td>";
4956 content += "</tr>";
4957 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
4958 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rain) + "</td>";
4959 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction2hr.rain) + "</td>";
4960 content += "</tr>";
4961 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
4962 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rainrate) + "</td>";
4963 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction2hr.rainrate) + "</td>";
4964 content += "</tr>";
4965 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
4966 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
4967 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
4968 content += "</tr>";
4969 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
4970 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction1hr.added_on.substring(0, t[0].prediction1hr.added_on.length - 3) + "</td>";
4971 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction2hr.added_on.substring(0, t[0].prediction2hr.added_on.length - 3) + "</td>";
4972 content += "</tr>";
4973 }
4974 else {
4975 content += "<td></td>";
4976 content += "<td></td>";
4977 content += "</tr>";
4978 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
4979 content += "<td></td>";
4980 content += "<td></td>";
4981 content += "</tr>";
4982 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
4983 content += "<td></td>";
4984 content += "<td></td>";
4985 content += "</tr>";
4986 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.winddirection).toFixed(1) + " °</td>";
4987 content += "<td></td>";
4988 content += "<td></td>";
4989 content += "</tr>";
4990 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
4991 content += "<td></td>";
4992 content += "<td></td>";
4993 content += "</tr>";
4994 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
4995 content += "<td></td>";
4996 content += "<td></td>";
4997 content += "</tr>";
4998 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
4999 content += "<td></td>";
5000 content += "<td></td>";
5001 content += "</tr>";
5002 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
5003 content += "<td></td>";
5004 content += "<td></td>";
5005 content += "</tr>";
5006 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
5007 content += "<td></td>";
5008 content += "<td></td>";
5009 content += "</tr>";
5010 }
5011
5012
5013 return content;
5014}
5015
5016function lyr_weatherBalloonPredictionData_3(t) {
5017
5018 var content = "<tr><th></th><th class=\"lyr_weather_station_prediction_th\"><u>Current</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 1hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 2hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 3hr</u></th></tr>";
5019 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Temp</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.temp).toFixed(1) + "℃</td>";
5020 if (t[0].prediction3hr.hasdata != "0") {
5021 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.temp).toFixed(1) + "℃</td>";
5022 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.temp).toFixed(1) + "℃</td>";
5023 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.temp).toFixed(1) + "℃</td>";
5024 content += "</tr>";
5025 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
5026 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.humidity).toFixed(1) + "%</td>";
5027 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.humidity).toFixed(1) + "%</td>";
5028 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.humidity).toFixed(1) + "%</td>";
5029 content += "</tr>";
5030 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
5031 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction1hr.windspeed) * 100)) / 100 + "</td>";
5032 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction2hr.windspeed) * 100)) / 100 + "</td>";
5033 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction3hr.windspeed) * 100)) / 100 + "</td>";
5034 content += "</tr>";
5035 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.winddirection + "</td>";
5036 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.winddirection).toFixed(1) + " °</td>";
5037 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.winddirection).toFixed(1) + " °</td>";
5038 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.winddirection).toFixed(1) + " °</td>";
5039 content += "</tr>";
5040 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
5041 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.dewpoint).toFixed(1) + "℃</td>";
5042 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.dewpoint).toFixed(1) + "℃</td>";
5043 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.dewpoint).toFixed(1) + "℃</td>";
5044 content += "</tr>";
5045 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
5046 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rain) + "</td>";
5047 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction2hr.rain) + "</td>";
5048 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction3hr.rain) + "</td>";
5049 content += "</tr>";
5050 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
5051 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rainrate) + "</td>";
5052 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction2hr.rainrate) + "</td>";
5053 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction3hr.rainrate) + "</td>";
5054 content += "</tr>";
5055 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
5056 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5057 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5058 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5059 content += "</tr>";
5060 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
5061 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction1hr.added_on.substring(0, t[0].prediction1hr.added_on.length - 3) + "</td>";
5062 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction2hr.added_on.substring(0, t[0].prediction2hr.added_on.length - 3) + "</td>";
5063 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction3hr.added_on.substring(0, t[0].prediction3hr.added_on.length - 3) + "</td>";
5064 content += "</tr>";
5065 }
5066 else {
5067 content += "<td></td>";
5068 content += "<td></td>";
5069 content += "</tr>";
5070 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
5071 content += "<td></td>";
5072 content += "<td></td>";
5073 content += "<td></td>";
5074 content += "</tr>";
5075 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
5076 content += "<td></td>";
5077 content += "<td></td>";
5078 content += "<td></td>";
5079 content += "</tr>";
5080 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.winddirection).toFixed(1) + " °</td>";
5081 content += "<td></td>";
5082 content += "<td></td>";
5083 content += "<td></td>";
5084 content += "</tr>";
5085 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
5086 content += "<td></td>";
5087 content += "<td></td>";
5088 content += "<td></td>";
5089 content += "</tr>";
5090 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
5091 content += "<td></td>";
5092 content += "<td></td>";
5093 content += "<td></td>";
5094 content += "</tr>";
5095 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
5096 content += "<td></td>";
5097 content += "<td></td>";
5098 content += "<td></td>";
5099 content += "</tr>";
5100 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
5101 content += "<td></td>";
5102 content += "<td></td>";
5103 content += "<td></td>";
5104 content += "</tr>";
5105 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
5106 content += "<td></td>";
5107 content += "<td></td>";
5108 content += "<td></td>";
5109 content += "</tr>";
5110 }
5111
5112 return content;
5113}
5114
5115function lyr_weatherBalloonPredictionData_6(t) {
5116
5117 var content = "<tr><th></th><th class=\"lyr_weather_station_prediction_th\"><u>Current</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 1hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 2hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 3hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 6hr</u></th></tr>";
5118 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Temp</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.temp).toFixed(1) + "℃</td>";
5119 //row 1, col 2
5120 if (t[0].prediction6hr.hasdata != "0") {
5121 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.temp).toFixed(1) + "℃</td>";
5122 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.temp).toFixed(1) + "℃</td>";
5123 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.temp).toFixed(1) + "℃</td>";
5124 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction6hr.temp).toFixed(1) + "℃</td>";
5125 content += "</tr>";
5126 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
5127 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.humidity).toFixed(1) + "%</td>";
5128 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.humidity).toFixed(1) + "%</td>";
5129 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.humidity).toFixed(1) + "%</td>";
5130 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction6hr.humidity).toFixed(1) + "%</td>";
5131 content += "</tr>";
5132 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
5133 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction1hr.windspeed) * 100)) / 100 + "</td>";
5134 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction2hr.windspeed) * 100)) / 100 + "</td>";
5135 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction3hr.windspeed) * 100)) / 100 + "</td>";
5136 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction6hr.windspeed) * 100)) / 100 + "</td>";
5137 content += "</tr>";
5138 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.winddirection + "</td>";
5139 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.winddirection).toFixed(1) + " °</td>";
5140 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.winddirection).toFixed(1) + " °</td>";
5141 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.winddirection).toFixed(1) + " °</td>";
5142 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction6hr.winddirection).toFixed(1) + " °</td>";
5143 content += "</tr>";
5144 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
5145 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.dewpoint).toFixed(1) + "℃</td>";
5146 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.dewpoint).toFixed(1) + "℃</td>";
5147 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.dewpoint).toFixed(1) + "℃</td>";
5148 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction6hr.dewpoint).toFixed(1) + "℃</td>";
5149 content += "</tr>";
5150 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
5151 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rain) + "</td>";
5152 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction2hr.rain) + "</td>";
5153 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction3hr.rain) + "</td>";
5154 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction6hr.rain) + "</td>";
5155 content += "</tr>";
5156 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
5157 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rainrate) + "</td>";
5158 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction2hr.rainrate) + "</td>";
5159 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction3hr.rainrate) + "</td>";
5160 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction6hr.rainrate) + "</td>";
5161 content += "</tr>";
5162 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
5163 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5164 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5165 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5166 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5167 content += "</tr>";
5168 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
5169 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction1hr.added_on.substring(0, t[0].prediction1hr.added_on.length - 3) + "</td>";
5170 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction2hr.added_on.substring(0, t[0].prediction2hr.added_on.length - 3) + "</td>";
5171 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction3hr.added_on.substring(0, t[0].prediction3hr.added_on.length - 3) + "</td>";
5172 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction6hr.added_on.substring(0, t[0].prediction6hr.added_on.length - 3) + "</td>";
5173 content += "</tr>";
5174 }
5175 else {
5176 content += "<td></td>";
5177 content += "<td></td>";
5178 content += "<td></td>";
5179 content += "<td></td>";
5180 content += "</tr>";
5181 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
5182 content += "<td></td>";
5183 content += "<td></td>";
5184 content += "<td></td>";
5185 content += "<td></td>";
5186 content += "</tr>";
5187 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
5188 content += "<td></td>";
5189 content += "<td></td>";
5190 content += "<td></td>";
5191 content += "<td></td>";
5192 content += "</tr>";
5193 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.winddirection).toFixed(1) + " °</td>";
5194 content += "<td></td>";
5195 content += "<td></td>";
5196 content += "<td></td>";
5197 content += "<td></td>";
5198 content += "</tr>";
5199 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
5200 content += "<td></td>";
5201 content += "<td></td>";
5202 content += "<td></td>";
5203 content += "<td></td>";
5204 content += "</tr>";
5205 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
5206 content += "<td></td>";
5207 content += "<td></td>";
5208 content += "<td></td>";
5209 content += "<td></td>";
5210 content += "</tr>";
5211 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
5212 content += "<td></td>";
5213 content += "<td></td>";
5214 content += "<td></td>";
5215 content += "<td></td>";
5216 content += "</tr>";
5217 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
5218 content += "<td></td>";
5219 content += "<td></td>";
5220 content += "<td></td>";
5221 content += "<td></td>";
5222 content += "</tr>";
5223 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
5224 content += "<td></td>";
5225 content += "<td></td>";
5226 content += "<td></td>";
5227 content += "<td></td>";
5228 content += "</tr>";
5229 }
5230
5231
5232 return content;
5233}
5234
5235function lyr_weatherBalloonPredictionData_12(t) {
5236
5237 var content = "<tr><th></th><th class=\"lyr_weather_station_prediction_th\"><u>Current</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 1hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 2hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 3hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 6hr</u></th><th class=\"lyr_weather_station_prediction_th\"><u>Predicted 12hr</u></th></tr>";
5238 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Temp</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.temp).toFixed(1) + "℃</td>";
5239 //row 1, col 2
5240 if (t[0].prediction12hr.hasdata != "0") {
5241 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.temp).toFixed(1) + "℃</td>";
5242 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.temp).toFixed(1) + "℃</td>";
5243 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.temp).toFixed(1) + "℃</td>";
5244 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction6hr.temp).toFixed(1) + "℃</td>";
5245 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction12hr.temp).toFixed(1) + "℃</td>";
5246 content += "</tr>";
5247 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
5248 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.humidity).toFixed(1) + "%</td>";
5249 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.humidity).toFixed(1) + "%</td>";
5250 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.humidity).toFixed(1) + "%</td>";
5251 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction6hr.humidity).toFixed(1) + "%</td>";
5252 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction12hr.humidity).toFixed(1) + "%</td>";
5253 content += "</tr>";
5254 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
5255 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction1hr.windspeed) * 100)) / 100 + "</td>";
5256 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction2hr.windspeed) * 100)) / 100 + "</td>";
5257 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction3hr.windspeed) * 100)) / 100 + "</td>";
5258 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction6hr.windspeed) * 100)) / 100 + "</td>";
5259 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].prediction12hr.windspeed) * 100)) / 100 + "</td>";
5260 content += "</tr>";
5261 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.winddirection + "</td>";
5262 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.winddirection).toFixed(1) + " °</td>";
5263 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.winddirection).toFixed(1) + " °</td>";
5264 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.winddirection).toFixed(1) + " °</td>";
5265 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction6hr.winddirection).toFixed(1) + " °</td>";
5266 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction12hr.winddirection).toFixed(1) + " °</td>";
5267 content += "</tr>";
5268 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
5269 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction1hr.dewpoint).toFixed(1) + "℃</td>";
5270 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction2hr.dewpoint).toFixed(1) + "℃</td>";
5271 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction3hr.dewpoint).toFixed(1) + "℃</td>";
5272 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction6hr.dewpoint).toFixed(1) + "℃</td>";
5273 content += "<td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].prediction12hr.dewpoint).toFixed(1) + "℃</td>";
5274 content += "</tr>";
5275 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
5276 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rain) + "</td>";
5277 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction2hr.rain) + "</td>";
5278 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction3hr.rain) + "</td>";
5279 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction6hr.rain) + "</td>";
5280 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction12hr.rain) + "</td>";
5281 content += "</tr>";
5282 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
5283 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction1hr.rainrate) + "</td>";
5284 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction2hr.rainrate) + "</td>";
5285 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction3hr.rainrate) + "</td>";
5286 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction6hr.rainrate) + "</td>";
5287 content += "<td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].prediction12hr.rainrate) + "</td>";
5288 content += "</tr>";
5289 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
5290 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5291 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5292 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5293 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5294 content += "<td class=\"lyr_weather_station_prediction_td\"></td>";
5295 content += "</tr>";
5296 content += "<tr><td class=\"lyr_weather_station_prediction_td_title\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
5297 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction1hr.added_on.substring(0, t[0].prediction1hr.added_on.length - 3) + "</td>";
5298 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction2hr.added_on.substring(0, t[0].prediction2hr.added_on.length - 3) + "</td>";
5299 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction3hr.added_on.substring(0, t[0].prediction3hr.added_on.length - 3) + "</td>";
5300 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction6hr.added_on.substring(0, t[0].prediction6hr.added_on.length - 3) + "</td>";
5301 content += "<td class=\"lyr_weather_station_prediction_td\">" + t[0].prediction12hr.added_on.substring(0, t[0].prediction12hr.added_on.length - 3) + "</td>";
5302 content += "</tr>";
5303 }
5304 else {
5305 content += "<td></td>";
5306 content += "<td></td>";
5307 content += "<td></td>";
5308 content += "<td></td>";
5309 content += "<td></td>";
5310 content += "</tr>";
5311 content += "<tr><td class=\"lyr_weather_station_prediction_td\">Humidity</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.humidity).toFixed(1) + "%</td>";
5312 content += "<td></td>";
5313 content += "<td></td>";
5314 content += "<td></td>";
5315 content += "<td></td>";
5316 content += "<td></td>";
5317 content += "</tr>";
5318 content += "<tr><td class=\"lyr_weather_station_prediction_td\">Wind Speed (mph)</td><td class=\"lyr_weather_station_prediction_td\">" + parseInt('' + (parseFloat(t[0].current.windspeed) * 100)) / 100 + "</td>";
5319 content += "<td></td>";
5320 content += "<td></td>";
5321 content += "<td></td>";
5322 content += "<td></td>";
5323 content += "<td></td>";
5324 content += "</tr>";
5325 content += "<tr><td class=\"lyr_weather_station_prediction_td\">Wind Direction</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.winddirection).toFixed(1) + " °</td>";
5326 content += "<td></td>";
5327 content += "<td></td>";
5328 content += "<td></td>";
5329 content += "<td></td>";
5330 content += "<td></td>";
5331 content += "</tr>";
5332 content += "<tr><td class=\"lyr_weather_station_prediction_td\">Dewpoint</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.dewpoint).toFixed(1) + "℃</td>";
5333 content += "<td></td>";
5334 content += "<td></td>";
5335 content += "<td></td>";
5336 content += "<td></td>";
5337 content += "<td></td>";
5338 content += "</tr>";
5339 content += "<tr><td class=\"lyr_weather_station_prediction_td\">Rain (mm)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rain) + "</td>";
5340 content += "<td></td>";
5341 content += "<td></td>";
5342 content += "<td></td>";
5343 content += "<td></td>";
5344 content += "<td></td>";
5345 content += "</tr>";
5346 content += "<tr><td class=\"lyr_weather_station_prediction_td\">Rain rate (mm/hr)</td><td class=\"lyr_weather_station_prediction_td\">" + lyr_weather_dataFormat(t[0].current.rainrate) + "</td>";
5347 content += "<td></td>";
5348 content += "<td></td>";
5349 content += "<td></td>";
5350 content += "<td></td>";
5351 content += "<td></td>";
5352 content += "</tr>";
5353 content += "<tr><td class=\"lyr_weather_station_prediction_td\">Pressure (inHg)</td><td class=\"lyr_weather_station_prediction_td\">" + parseFloat(t[0].current.pressure).toFixed(1) + "</td>";
5354 content += "<td></td>";
5355 content += "<td></td>";
5356 content += "<td></td>";
5357 content += "<td></td>";
5358 content += "<td></td>";
5359 content += "</tr>";
5360 content += "<tr><td class=\"lyr_weather_station_prediction_td\">Time</td><td class=\"lyr_weather_station_prediction_td\">" + t[0].current.added_on.substring(0, t[0].current.added_on.length - 3) + "</td class=\"lyr_weather_station_prediction_td\">";
5361 content += "<td></td>";
5362 content += "<td></td>";
5363 content += "<td></td>";
5364 content += "<td></td>";
5365 content += "<td></td>";
5366 content += "</tr>";
5367 }
5368 return content;
5369}
5370
5371//var lyr_drone_overlay = [];
5372
5373//function lyr_clr_droneData() {
5374// if (lyr_drone_overlay.length > 0) {
5375// lyr_drone_overlay[0].setMap(null);
5376// lyr_drone_overlay = [];
5377// }
5378//}
5379
5380//function lyr_clr_droneInfoLyr() {
5381// var id = $(".layer-item-drone").attr("id");
5382
5383//}
5384
5385//function lyr_getDroneCalLayer(layerId) {
5386
5387// //temp work and needs to be refactored in 2020 when it will be dynamic.
5388// var thislayerId = layerId.split('_')[1];
5389// $(".layerInfo").each(function () {
5390// if ($(this).attr("rel") == thislayerId) {
5391// $(this).show();
5392
5393// var tempArrDronedate = [];
5394// var tempArrDroneimg = [];
5395
5396// tempArrDronedate.push((new Date('06/01/2019')).toISOString());
5397// tempArrDronedate.push((new Date('06/08/2019')).toISOString());
5398// tempArrDronedate.push((new Date('06/15/2019')).toISOString());
5399// tempArrDronedate.push((new Date('06/22/2019')).toISOString());
5400// tempArrDronedate.push((new Date('06/29/2019')).toISOString());
5401// tempArrDronedate.push((new Date('07/06/2019')).toISOString());
5402
5403
5404// //display calendar
5405// $(".drone_cal").datepicker({
5406// beforeShowDay: function (date) {
5407// return (tempArrDronedate.indexOf(date.toISOString()) > -1) ? [true, "conductivity_calendar_date_Diff"] : [false, ""];
5408// },
5409// defaultDate: new Date(tempArrDronedate[0]),
5410// minDate: new Date(tempArrDronedate[0]),
5411// onSelect: function (data) {
5412
5413// lyr_clr_droneData();
5414
5415// //work out which image to use.
5416// var droneImgOverlay = "";
5417
5418// switch (data) {
5419// case "01-06-2019":
5420// droneImgOverlay = "https://api.mi.farm/static/images/drone/Upper_Barn_WK4_transparent.png";
5421// break;
5422// case "08-06-2019":
5423// droneImgOverlay = "https://api.mi.farm/static/images/drone/Upper_Barn_WK5_transparent.png";
5424// break;
5425// case "15-06-2019":
5426// droneImgOverlay = "https://api.mi.farm/static/images/drone/Upper_Barn_WK6_transparent.png";
5427// break;
5428// case "22-06-2019":
5429// droneImgOverlay = "https://api.mi.farm/static/images/drone/Upper_Barn_WK7_transparent.png";
5430// break;
5431// case "29-06-2019":
5432// droneImgOverlay = "https://api.mi.farm/static/images/drone/Upper_Barn_WK8_transparent.png";
5433// break;
5434// case "06-07-2019":
5435// droneImgOverlay = "https://api.mi.farm/static/images/drone/Upper_Barn_WK9_transparent.png";
5436// break;
5437// }
5438
5439
5440// //display drone image on map.
5441// var overlayBoundary = new google.maps.MVCArray();
5442// for (var k = 0; k < polygonsArray[0].getPath().getLength() ; k++) {
5443// overlayBoundary.push(new google.maps.LatLng(polygonsArray[0].getPath().getAt(k).lat(), polygonsArray[0].getPath().getAt(k).lng()));
5444// //for map bounds
5445// var coords = polygonsArray[0].getPath().getAt(k);
5446// }
5447
5448// //get bounds from polygon for custom overlay
5449// if (!google.maps.Polygon.prototype.getBounds)
5450// google.maps.Polygon.prototype.getBounds = function () {
5451// var bounds = new google.maps.LatLngBounds();
5452// var paths = this.getPaths();
5453// for (var i = 0; i < paths.getLength() ; i++) {
5454// var path = paths.getAt(i);
5455// for (var j = 0; j < path.getLength() ; j++) {
5456// bounds.extend(path.getAt(j));
5457// }
5458// }
5459// return bounds;
5460// }
5461
5462// var rectangle = new google.maps.Rectangle({
5463// strokeColor: '#FF0000',
5464// strokeOpacity: 0.8,
5465// strokeWeight: 1,
5466// fillOpacity: 0,
5467// bounds: polygonsArray[0].getBounds()
5468// });
5469
5470// polygonsArray[0].setMap(null);
5471// var myOverlay = new google.maps.GroundOverlay(droneImgOverlay, rectangle.getBounds(), { clickable: false });
5472// myOverlay.setMap(map);
5473// lyr_drone_overlay.push(myOverlay);
5474
5475// },
5476// dateFormat: "dd-mm-yy",
5477// maxDate: '0'
5478// });
5479
5480
5481// }
5482// });
5483
5484//}