Map A Cober Tura
Map A Cober Tura
Map A Cober Tura
Mapa_Area_CoberturaModel
@using Aniel.Connect.Models.T5
@using Resources
@{
ViewBag.Title = "Aniel Geograph";
Layout = "~/Views/Shared/_LayoutLimpo.cshtml";
}
@section styles{
<style>
/*Collapse*/
.collapse {
visibility: hidden;
}
.collapse.show {
visibility: visible;
display: block;
}
.collapsing {
position: relative;
height: 0;
overflow: hidden;
-webkit-transition-property: height, visibility;
transition-property: height, visibility;
-webkit-transition-duration: 0.35s;
transition-duration: 0.35s;
-webkit-transition-timing-function: ease;
transition-timing-function: ease;
}
.collapsing.width {
-webkit-transition-property: width, visibility;
transition-property: width, visibility;
width: 0;
height: auto;
}
</style>
}
</div>
<!--./main-->
</div>
</div>
</div>
</div>
</div>
<!--Mapa-->
@*<input id="pac-input"
class="controls"
type="text"
placeholder="Search Box" />*@
<!--GoogleMaps Config-->
<script>
const cor = "@Html.Raw(Model.Cor)";
// This example adds a search box to a map, using the Google Place Autocomplete
// feature. People can enter geographical searches. The search box will return
a
// pick list containing a mix of places and predicted search terms.
// This example requires the Places library. Include the libraries=places
// parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?
key=YOUR_API_KEY&libraries=places">
function initDrawing(map) {
const image =
"https://developers.google.com/maps/documentation/javascript/examples/full/images/b
eachflag.png";
// drawingModes: [
// google.maps.drawing.OverlayType.MARKER,
// google.maps.drawing.OverlayType.CIRCLE,
// google.maps.drawing.OverlayType.POLYGON,
// google.maps.drawing.OverlayType.POLYLINE,
// google.maps.drawing.OverlayType.RECTANGLE,
},
markerOptions: {
icon: image,
visible: false,
},
rectangleOptions: {
strokeColor: cor,
fillColor: cor,
fillOpacity: "0.15",
editable: false,
bounds: map.getBounds(),
},
},
polylineOptions: {
strokeColor: cor,
editable: false,
/* autocomplete: true*/
},
circleOptions: {
strokeColor: cor,
fillColor: cor,
fillOpacity: "0.15",
strokeWeight: 3,
editable: false,
}
});
//google.maps.event.addlistener(drawingmanager, 'rectanglecomplete',
(rectangle) => {
// console.log(rectangle.getbounds())
// rectangle.seteditable(true);
// /*var area =
google.maps.geometry.spherical.computearea(polygon.getpath());*/
// var tamanhoarea =
google.maps.geometry.spherical.computearea(rectangle.getbounds());
// coordinates = (rectangle.getbounds().getarray());
// console.log(coordinates);
// console.log(lat, lng);
// }
//});
google.maps.event.addListener(drawingManager, 'rectanglecomplete',
(rectangle) => {
console.log(rectangle)
rectangle.setEditable(true);
});
google.maps.event.addListener(drawingManager, 'polylinecomplete',
(polyline) => {
coordinates = (polyline.getPath().getArray());
console.log(coordinates);
var TamanhoArea =
google.maps.geometry.spherical.computeArea(polygon.getPath());
});
console.log(polygon.strokeColor, polygon.fillColor,
polygon.strokeWeight, polygon.fillOpacity, polygon.Status);
console.log(polygon.editable);
polygon.setEditable(true);
/*var area =
google.maps.geometry.spherical.computeArea(polygon.getPath());*/
var TamanhoArea =
google.maps.geometry.spherical.computeArea(polygon.getPath());
coordinates = (polygon.getPath().getArray());
console.log(coordinates);
//const encodeString =
google.maps.geometry.encoding.encodePath(polygon.getPath());
//console.log(encodeString);
//const decodeString =
google.maps.geometry.encoding.decodePath(encodeString);
//console.log(decodeString);
var j = 0;
var latlng = [];
}
latlng.push(latlng[0]);
/* latlng = latlng.toString();*/
console.log(latlng);
console.log(TamanhoArea);
//}
// new google.maps.Polyline({
// map: map,
// path: LatLngString,
// geodesic: true,
// strokeColor: "#000000",
// strokeOpacity: 1.3,
/*});*/
});
//google.maps.event.addListener(polygon.getPath(), "insert_at", getPath);
//google.maps.event.addListener(polygon.getPath(), "remove_at", getPath);
//google.maps.event.addListener(polygon.getPath(), "set_at", getPath);
};
function initAutocomplete(map) {
if (places.length == 0) {
return;
}
// Clear out the old markers.
markers.forEach((marker) => {
marker.setMap(null);
});
markers = [];
// For each place, get the icon, name and location.
const bounds = new google.maps.LatLngBounds();
places.forEach((place) => {
if (!place.geometry || !place.geometry.location) {
console.log("Returned place contains no geometry");
return;
}
const icon = {
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(25, 25),
};
// Create a marker for each place.
markers.push(
new google.maps.Marker({
map,
icon,
title: place.name,
position: place.geometry.location,
})
);
if (place.geometry.viewport) {
// Only geocodes have viewport.
bounds.union(place.geometry.viewport);
} else {
bounds.extend(place.geometry.location);
}
});
map.fitBounds(bounds);
//data.objeto.id
//data.objeto.tipo
data.objeto.coodenadasDouble
}
else {
Notificar("@RsBase.ATENCAO_", data.mensagem, "warning");
}
});
});
};
//}
initDrawing(map)
initAutocomplete(map)
}
</script>