148 lines
4.1 KiB
JavaScript
148 lines
4.1 KiB
JavaScript
//REGION GEORUTAS
|
|
var markersRutas = [];
|
|
var polylinesGeoRutas = [];
|
|
var polybounds = [];
|
|
|
|
function initGeoRutas() {
|
|
//NuevaConsultaGeoRutas();
|
|
var upRutasDiv = document.createElement('div');
|
|
var upRutas = new ControlGeoRutas(upRutasDiv, map);
|
|
|
|
map.controls[google.maps.ControlPosition.TOP_LEFT].push(upRutasDiv);
|
|
}
|
|
|
|
function creaPolylineRuta(coords, color, GeoCerca) {
|
|
var polyline = new google.maps.Polyline({
|
|
path: coords,
|
|
strokeColor: color,
|
|
strokeOpacity: 0.8,
|
|
strokeWeight: 2,
|
|
fillOpacity: 0.35
|
|
});
|
|
|
|
polyline.setMap(map);
|
|
polylinesGeoRutas.push(polyline);
|
|
polybounds.push(coords[0]);
|
|
polybounds.push(coords[coords.length - 1]);
|
|
CreaMarcadorPoligonoRuta(coords, GeoCerca);
|
|
}
|
|
|
|
function CreaMarcadorPoligonoRuta(coords, GeoCerca) {
|
|
var bounds = new google.maps.LatLngBounds();
|
|
for (i = 0; i < coords.length; i++) {
|
|
bounds.extend(coords[i]);
|
|
}
|
|
|
|
var marker = new google.maps.Marker({
|
|
position: bounds.getCenter(),
|
|
title: GeoCerca,
|
|
map: map
|
|
});
|
|
|
|
var infowindow = new google.maps.InfoWindow({
|
|
content: '<h4><b>' + GeoCerca + '</b></h4>'
|
|
});
|
|
|
|
marker.addListener('click', function () {
|
|
closeLastOpenedInfoWindow();
|
|
infowindow.open(map, marker);
|
|
lastOpenedInfoWindow = infowindow;
|
|
});
|
|
|
|
markersRutas.push(marker);
|
|
}
|
|
|
|
function NuevaConsultaGeoRutas() {
|
|
|
|
for (var i = 0; i < polylinesGeoRutas.length; i++) {
|
|
polylinesGeoRutas[i].setMap(null);
|
|
}
|
|
|
|
for (var i = 0; i < markersRutas.length; i++) {
|
|
markersRutas[i].setMap(null);
|
|
}
|
|
|
|
polylinesGeoRutas = [];
|
|
polybounds = [];
|
|
markersRutas = [];
|
|
|
|
$("#LnkMostarGeoRutas").css("display", "block");
|
|
}
|
|
|
|
function ControlGeoRutas(controlDiv, map) {
|
|
|
|
// Set CSS for the control border.
|
|
var controlUI = document.createElement('div');
|
|
controlUI.style.marginLeft = '10px';
|
|
controlUI.style.zIndex = '0';
|
|
controlUI.style.cursor = 'pointer';
|
|
// controlUI.style.position = 'absolute';
|
|
controlUI.style.left = "0px";
|
|
controlUI.style.width = "150px";
|
|
controlUI.style.marginTop = "10px"
|
|
controlUI.style.top = "0px";
|
|
controlUI.className = 'gmnoprint';
|
|
|
|
controlDiv.appendChild(controlUI);
|
|
|
|
var ControlSub1 = document.createElement('div')
|
|
ControlSub1.style.float = 'left';
|
|
ControlSub1.className = 'gm-style-mtc'
|
|
controlUI.appendChild(ControlSub1)
|
|
|
|
var ControlSub2 = document.createElement('div')
|
|
ControlSub2.style.direction = 'ltr';
|
|
ControlSub2.style.overflow = 'hidden';
|
|
ControlSub2.id = "LnkMostarGeoRutas"
|
|
ControlSub2.style.textAlign = 'center';
|
|
ControlSub2.style.position = 'relative';
|
|
ControlSub2.style.color = 'rgb(0,0,0)';
|
|
ControlSub2.style.fontFamily = ' "Open Sans", sans-serif; ';
|
|
ControlSub2.style.msUserSelect = 'none;';
|
|
ControlSub2.style.fontSize = '11px'
|
|
ControlSub2.style.display = 'none'
|
|
ControlSub2.style.backgroundColor = 'rgb(255,255,255)'
|
|
ControlSub2.style.padding = '11px'
|
|
ControlSub2.style.backgroundClip = 'padding-box'
|
|
ControlSub2.style.minWidth = '28px'
|
|
ControlSub2.style.fontWeight = '500'
|
|
ControlSub2.style.boxShadow = '0 1px 4px -1px rgba(0,0,0,.3)';
|
|
ControlSub2.innerHTML = 'Mostrar GeoRutas'
|
|
ControlSub1.appendChild(ControlSub2)
|
|
|
|
ControlSub1.addEventListener('click', function () {
|
|
VerGeoRutas();
|
|
});
|
|
|
|
}
|
|
|
|
var IsRutasVisibles = false;
|
|
|
|
function VerGeoRutas() {
|
|
if (IsRutasVisibles) {
|
|
HideGeoRutas();
|
|
IsRutasVisibles = false;
|
|
} else {
|
|
CargaGeoRutas();
|
|
IsRutasVisibles = true;
|
|
}
|
|
}
|
|
|
|
function HideGeoRutas() {
|
|
for (var i = 0; i < polylinesGeoRutas.length; i++) {
|
|
polylinesGeoRutas[i].setMap(null);
|
|
}
|
|
for (var j = 0; j < markersRutas.length; j++) {
|
|
markersRutas[j].setMap(null);
|
|
}
|
|
}
|
|
|
|
function CargaGeoRutas() {
|
|
for (var i = 0; i < polylinesGeoRutas.length; i++) {
|
|
polylinesGeoRutas[i].setMap(map);
|
|
}
|
|
for (var j = 0; j < markersRutas.length; j++) {
|
|
markersRutas[j].setMap(map);
|
|
}
|
|
}
|