git-svn-id: https://msi/svn/firstRepo/WebClient/branches/Manut_3.0.1@80 0f545695-f87b-41b6-9a03-7f16563b5454

This commit is contained in:
2016-04-04 16:01:28 +00:00
parent 78f63f0cf1
commit 728b139ca3
5 changed files with 1380 additions and 35 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,7 +1,7 @@
var myManifest = {
Debug: (window.location.port !== ""),
Name: "Il Lievitario",
Version: "3.0.4.3",
Version: "3.0.5.2",
Author: "Denis Ironi",
Settings: {
ShowStartMessage: true,
+73 -32
View File
@@ -5,6 +5,8 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/maps/mapsViewTemplate.
map: null,
markers: [],
openedInfoWindows: [],
markerClicked: false,
//initialize template
template: _.template(mapsViewTemplate),
infoWindowtemplate: _.template(infoWindowTemplate),
@@ -76,12 +78,16 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/maps/mapsViewTemplate.
mapTypeControl: false,
zoomControlOptions: {
position: google.maps.ControlPosition.RIGHT_CENTER
},
}
        };
self.$el.find("#map-canvas").width(document.documentElement.clientWidth - 32/*Padding content*/);
self.$el.find("#map-canvas").height(document.documentElement.clientHeight - 151 - self.$el.find('#searchPanel').height());
self.map = new google.maps.Map(self.$el.find("#map-canvas")[0], myOptions);
self.map.addListener("dragend", function(){
self.markerClicked = true;
});
// Create the search box and link it to the UI element.
var input = $('<input id="pac-input" data-role="none" class="controls" type="text" placeholder="Ricerca località..." style="display:none;">')[0];
self.$el.find('div[data-role="content"]')[0].appendChild(input);
@@ -140,32 +146,47 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/maps/mapsViewTemplate.
self.map.addListener('bounds_changed', function() {
var bound = self.map.getBounds();
searchBox.setBounds(bound);
var latLngFrom = bound.getNorthEast();
var latLngTo = bound.getSouthWest();
$.ajax({
url: myManifest.Settings.DefaultURL + "/api/spacciatori/bound/" + latLngFrom.lat() + "/"+ latLngFrom.lng() + "/" + latLngTo.lat() + "/"+ latLngTo.lng(),
//dataType: "json",
//async: false,
type: 'GET',
success: function (resp) {
resp.forEach(function(ele, index){
var key = "|" + ele.Latitudine+ "|" + ele.Longitudine+ "|";
if(!self.markers[key])
{
self._makeMarker(ele, key);
}
else if(!self.markers[key][ele.ID])
{
ele.Latitudine = parseFloat(ele.Latitudine) + (Math.random() / 500);
ele.Longitudine = parseFloat(ele.Longitudine) + (Math.random() / 500);
self._makeMarker(ele, key);
}
});
}
});
searchBox.setBounds(bound);
});
$("#pac-input").show();
var markersArray = [];
var latLngFrom = new google.maps.LatLng(85, -180);
var latLngTo = new google.maps.LatLng(-85, 180);
$.ajax({
url: myManifest.Settings.DefaultURL + "/api/spacciatori/bound/" + latLngFrom.lat() + "/"+ latLngFrom.lng() + "/" + latLngTo.lat() + "/"+ latLngTo.lng(),
//dataType: "json",
//async: false,
type: 'GET',
success: function (resp) {
resp.forEach(function(ele, index){
var key = "|" + ele.Latitudine+ "|" + ele.Longitudine+ "|";
if(!self.markers[key])
{
markersArray.push(self._makeMarker(ele, key));
}
else if(!self.markers[key][ele.ID])
{
ele.Latitudine = parseFloat(ele.Latitudine) + (Math.random() / 500);
ele.Longitudine = parseFloat(ele.Longitudine) + (Math.random() / 500);
markersArray.push(self._makeMarker(ele, key));
}
});
markerClusterer = new MarkerClusterer(self.map, markersArray, {
maxZoom: 15
// ,styles: {
// url: '../images/pin.png',
// height: 48,
// width: 30,
// anchor: [-18, 0],
// textColor: '#ffffff',
// textSize: 10,
// iconAnchor: [15, 48]
// }
});
}
});
},
_makeMarker: function(ele,key){
var self = this;
@@ -174,7 +195,7 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/maps/mapsViewTemplate.
icon: ele.TipoPM == "4"?self.iconPMGF:self.iconPM,
//label: ele.Name,
title: $("<div/>").html(unescape(ele.Name)).text(),
map: self.map
//map: self.map
});
if(!self.markers[key])
@@ -183,26 +204,34 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/maps/mapsViewTemplate.
self.markers[key][ele.ID] = marker;
var infowindow = new google.maps.InfoWindow({
content: self.infoWindowtemplate({item: ele})
content: self.infoWindowtemplate({item: ele}),
closeclick: function(){
var index = openedInfoWindows.indexOf(this);
if (index > -1) {
self.openedInfoWindows.splice(index, 1);
}
}
});
marker.addListener('click', function() {
self.markerClicked = true;
self.openedInfoWindows.push(infowindow);
infowindow.open(self.map, marker);
});
return marker;
},
onShowed: function(){
if(this.map)
return;
return;
var self = this;
$( window ).resize( function(){
$("#map-canvas").width(document.documentElement.clientWidth - 32/*Padding content*/);
$("#map-canvas").height(document.documentElement.clientHeight - 151 - self.$el.find('#searchPanel').height());
});
},
onShowing: function(){
var self = this;
});
if ( navigator.geolocation ) {
        function success(pos) {
            // Location found, show map with these coordinates
@@ -216,6 +245,18 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/maps/mapsViewTemplate.
    } else {
self._drawMap(self.defaultLatLng);  // No geolocation support, show default map
    }
$("#map-canvas").click(function(){
if(self.markerClicked){
self.markerClicked = false;
return;
}
self.openedInfoWindows.forEach(function(item, index){
item.close();
});
self.openedInfoWindows = [];
});
},
onClosing: function(){
var self = this;