let matrix = [ ['AM095L4G1Z','Ambrogio Quad Elite Robotic Lawnmower 4G','https://chelmsfordgardenmachinery.co.uk/ambrogio-quad-elite-robotic-mower/','AM095L4G1Z.jpg','3499.17','3500'], ['AM060L0V9Z','Ambrogio L60 Elite S+ 7.5Ah Robotic Lawnmower - up to 400m2 - No Installation','https://chelmsfordgardenmachinery.co.uk/essex-robot-mowers-ambrogio-l60-elite-s/','AM060L0K9Z.jpg','915.83','400'], ['AM020D0F9Z','Ambrogio Twenty L20 Deluxe Robotic Lawnmower - up to 700m2','https://chelmsfordgardenmachinery.co.uk/essex-robotic-mower-ambrogio-twenty-deluxe/','AM020D0F9Z.jpg','915.83','700'], ['AM020R0K1Z','Ambrogio Twenty ZR Robotic Mower <1000m2 - No Perimeter Wire Required','https://chelmsfordgardenmachinery.co.uk/robotic-lawn-mower-essex-ambrogio-twenty-zr/','AM020R0K1Z.jpg','999.17','1000'], ['AM020L4F1Z','Ambrogio Twenty Elite Robotic Lawnmower - up to 1000m2 / 4G','https://chelmsfordgardenmachinery.co.uk/essex-robot-mowers-ambrogio-twenty-elite/','AM020L4F1Z.jpg','1124.17','1000'], ['AM020L4K1Z','Ambrogio Twenty Elite S+ Robotic Lawnmower - up to 1300m2 (4G)','https://chelmsfordgardenmachinery.co.uk/robot-lawn-mower-ambrogio-twenty-elite-s/','AM020L4K1Z.jpg','1249.17','1300'], ['AM025L4K1Z','Ambrogio Twenty 25 Elite Robotic Lawnmower up to 1800m2 TwentyFive','https://chelmsfordgardenmachinery.co.uk/robotic-mower-ambrogio-twenty-25-elite/','AM025L4K1Z.jpg','1582.5','1800'], ['AM029D0K1Z','Ambrogio Twenty 29 Deluxe Robotic Lawnmower - up to 2500m2 TwentyNine','https://chelmsfordgardenmachinery.co.uk/ambrogio-twenty-29-deluxe-robot-mower/','AM029D0K1Z.jpg','1832.5','2500'], ['AM029L4G1Z','Ambrogio Twenty 29 Elite Robotic Lawnmower - up to 3500m2 TwentyNine','https://chelmsfordgardenmachinery.co.uk/robotic-lawn-mower-ambrogio-twenty-29-elite/','AM029L4G1Z.jpg','2332.5','3500'], ['AM040L003Z','Ambrogio 4.0 Elite Premium Robotic Lawnmower 4G - Up to 3500 m2 ','https://chelmsfordgardenmachinery.co.uk/ambrogio-4-elite-robot-lawnmower/','AM040L401Z.jpg','2832.5','3500'], ['AM043L401Z','Ambrogio 4.36 Elite Premium Robotic Lawnmower 4G - Up to 6000m2','https://chelmsfordgardenmachinery.co.uk/ambrogio-4-36-elite-robotic-mower/','AM043L401Z.jpg','3499.17','6000'], ['AM450D4M1Z','Ambrogio L400i Deluxe Robotic Lawnmower - Up to 20000m2','https://chelmsfordgardenmachinery.co.uk/large-area-robot-mowers-ambrogio-l400-range/','AM450D4M1Z.jpg','10832.5','20000'], ['AM040L4I3Z','Ambrogio Next-Line 4.0 Elite 4WD Premium Robotic Lawnmower','https://chelmsfordgardenmachinery.co.uk/ambrogio-4-0-elite-4wd-robotic-mower/','AM040L4I3Z.jpg','3165.83','3500'], ['AM043L4I3Z','Ambrogio Next-Line 4.36 Elite 4WD Premium Robotic Lawnmower','https://chelmsfordgardenmachinery.co.uk/ambrogio-4-36-elite-4wd-robot-lawn-mower/','AM043L4I3Z.jpg','3832.5','6500'], ['BLANK', 'BLANK', 'BLANK', 'BLANK', 0, 'BLANK'] ]; var map = null; var default_lat = 55.615589; var default_lng = -4; var default_zoom = 5; var map_div = "map_canvas"; var measure; var length_mode = "area"; $(document).ready(function() { $("#btn_show_search_result").click(function() { // display code address codeAddress(); return false; }); $("input[name=mode]:radio").change(function() { length_mode = this.value; // display polygon or remove if distance display_polygon_line(); }); }); function appendBootstrap() { var script_id = "google_map_api_script"; if ($("#" + script_id).length <= 0) { var script = document.createElement("script"); script.type = "text/javascript"; script.id = script_id; script.src = "https://maps.google.com/maps/api/js?sensor=false&language=en&libraries=geometry&callback=initialize"; document.body.appendChild(script); } else { initialize(); } } function initialize() { measure = { mvcLine: new google.maps.MVCArray(), mvcPolygon: new google.maps.MVCArray(), mvcMarkers: new google.maps.MVCArray(), line: null, polygon: null }; var latlng = new google.maps.LatLng(default_lat, default_lng); var mapOptions = { scaleControl: true, zoom: default_zoom, zoomControl: true, zoomControlOptions: {style: google.maps.ZoomControlStyle.SMALL}, panControl: false, center: latlng, mapTypeId: google.maps.MapTypeId.HYBRID, draggableCursor: 'crosshair' }; map = new google.maps.Map(document.getElementById(map_div), mapOptions); map.setTilt(0); google.maps.event.addListener(map, 'click', function(event) { placeMarker(event.latLng); }); } function codeAddress() { var geocoder = new google.maps.Geocoder(); var address = document.getElementById('search_address').value; geocoder.geocode({'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); map.setZoom(17); // placeMarker(results[0].geometry.location); // } else { alert('Address not found , reason: ' + status); } }); } function placeMarker(latLng) { var image = 'a.png'; var marker = new google.maps.Marker({map: map, position: latLng, draggable: true, icon: image}); measure.mvcLine.push(latLng); measure.mvcPolygon.push(latLng); measure.mvcMarkers.push(marker); var latLngIndex = measure.mvcLine.getLength() - 1; google.maps.event.addListener(marker, "drag", function(evt) { measure.mvcLine.setAt(latLngIndex, evt.latLng); measure.mvcPolygon.setAt(latLngIndex, evt.latLng); }); google.maps.event.addListener(marker, "dragend", function() { if (measure.mvcLine.getLength() > 1) { compute_length(); } }); display_polygon_line(); } function display_polygon_line() { if (measure.mvcLine.getLength() > 1) { if (!measure.line) { measure.line = new google.maps.Polyline({ map: map, clickable: false, strokeColor: "#FF0000", strokeOpacity: 1, strokeWeight: 3, path: measure.mvcLine }); } if (measure.mvcPolygon.getLength() > 2) { if (measure.polygon != null) { measure.polygon.setMap(null); } if (length_mode != "distance") { measure.polygon = new google.maps.Polygon({ clickable: false, map: map, fillOpacity: 0.25, strokeOpacity: 0, paths: measure.mvcPolygon }); } else { measure.polygon = new google.maps.Polygon({ clickable: false, map: map, fillOpacity: 0.0, strokeOpacity: 0, paths: measure.mvcPolygon }); } } } if (measure.mvcLine.getLength() > 1) { compute_length(); } } function compute_length() { var jezaddress = document.getElementById('search_address').value; var length = 0; if (measure.mvcPolygon.getLength() > 1) { length = google.maps.geometry.spherical.computeLength(measure.line.getPath()); } var area = 0; if (measure.mvcPolygon.getLength() > 2) { area = google.maps.geometry.spherical.computeArea(measure.polygon.getPath()); } // lM = document.forms["mb"].elements["mode"][0].checked; if (length_mode === "distance") { var km = length / 1000; var feet = length * 3.2808399; var yards = length * 1.0936133; var miles = length * 0.000621371192; var unit = " meters"; var unit1 = " miles"; var unit2 = " kilometers"; var unit3 = " feet"; var unit4 = " yards"; // document.getElementById('lineLength').innerHTML = "Total distance:
" + length.toFixed(0) + unit + "
" + km.toFixed(3) + unit2 // + "
" + feet.toFixed(0) + unit3 + "
" + yards.toFixed(0) + unit4 + "
" + miles.toFixed(3) + unit1; document.getElementById('lineLength').innerHTML = "" + jezaddress + ": Total distance:
" + length.toFixed(0) + unit + "
"; document.getElementById('polyArea').innerHTML = ''; } else { var km = area / (1000 * 1000); var feet = area * 10.7639104; var yards = area * 1.19599005; var acres = area * 0.000247105381; var unit = " m²"; // square meters var unit1 = " acres"; var unit2 = " kilometers²"; var unit3 = " feet²"; var unit4 = " yards²"; // document.getElementById('polyArea').innerHTML = "Surface:
" + area.toFixed(0) + unit + "
" + km.toFixed(3) + unit2 // + "
" + feet.toFixed(0) + unit3 + "
" + yards.toFixed(0) + unit4 + "
" + acres.toFixed(3) + unit1; document.getElementById('polyArea').innerHTML = "


" + jezaddress + ": Total Surface Area: " + area.toFixed(0) + unit + ". Wire required: " +length.toFixed(0) + "m" + "
"; document.getElementById('lineLength').innerHTML = ''; document.getElementById("jez").innerHTML = "These Robotic Mowers Will Cover Your Area:
"; } jezchecker(area); } function removeLastMarker() { var test = measure.mvcLine.pop(); if (test) { measure.mvcPolygon.pop(); var marker = measure.mvcMarkers.pop(); marker.setMap(null); compute_length(); } } // // JEZ NEW FUNCTION Jez November 2023 oh yeah // function jezchecker(therange1) { document.getElementById('jez').innerHTML = "Recommended Models For This Lawn Area:
"; let jezadd = (therange1 * 2) + 300; // double the area and add 300 so we can limit the number of robots shown for (let i = 0; i < matrix.length; i++) { let jezsub = matrix[i][5] * 0.8; // reduce the range of machine by 20% so it accounts for battery deg and terrain if ((jezsub >= therange1) && (matrix[i][5] <= jezadd)) { // [0] is the bot name, [4] is the price, [5] is the range etc from the Matrix at top of page, generated by sellerdeck. . let myPrice = Number(matrix[i][4]) * 1.2; // add VAT myPrice = myPrice.toFixed(0); // tidy up no decimals document.getElementById('jez').innerHTML += '

' + matrix[i][1] + ' £' + myPrice + '

'; } } } // // // function clearMarkers() { if (measure.polygon) { measure.polygon.setMap(null); measure.polygon = null; } if (measure.line) { measure.line.setMap(null); measure.line = null } measure.mvcLine.clear(); measure.mvcPolygon.clear(); measure.mvcMarkers.forEach(function(elem, index) { elem.setMap(null); }); measure.mvcMarkers.clear(); document.getElementById('lineLength').innerHTML = ''; document.getElementById('polyArea').innerHTML = ''; document.getElementById('jez').innerHTML = ''; }