");
entAround.append(line);
}
}
this.geolocalizables.each(function(aGeolocalizable) {
if (!aGeolocalizable.get("markerCheckbox")) {
var checkbox = $('
');
aGeolocalizable.set("markerCheckbox", checkbox);
checkbox.on("click", function() {
if ($(this).is(':checked')) {
aGeolocalizable.get("marker").setMap(that.GMap);
} else {
aGeolocalizable.get("marker").setMap(null);
}
//google.maps.event.trigger(aGeolocalizable.get("marker"), 'click');
});
var line = $("
");
line.append('
');
line.append('
');
line.append('
');
line.append("
");
line.append(checkbox);
line.append("
");
entAround.append(line);
}
});
}
};
Map.GoogleMaps.prototype.centerOnMarker = function(aMarker) {
this.GMap.panTo(aMarker.getPosition());
this.GMap.setZoom(this.defaultzoom);
};
Map.GoogleMaps.prototype.createControls = function() {
if (this.options.itinerary || this.options.enterprisesAround || this.options.legend) {
this.GMap.controls[google.maps.ControlPosition.TOP_LEFT].push(this.createOptionsControl());
}
this.GMap.controls[google.maps.ControlPosition.TOP_LEFT].push(this.createCenterControl());
};
Map.GoogleMaps.prototype.createOptionsControl = function() {
var optionsDiv = this.createControl("Options");
$(optionsDiv).attr("id", "optionsControl");
google.maps.event.addDomListener(optionsDiv, 'click', function() {
openToolbar();
});
return optionsDiv;
};
Map.GoogleMaps.prototype.createCenterControl = function() {
var optionsDiv = this.createControl(edApplication().labels.RECENTER, "maps/InitialPoint_small.png");
$(optionsDiv).attr("id", "centerControl");
var that = this;
google.maps.event.addDomListener(optionsDiv, 'click', function() {
that.GMap.panTo(that.referenceGeolocalizable.point);
that.GMap.setZoom(that.defaultzoom);
google.maps.event.trigger(that.referenceGeolocalizable.marker, 'click');
});
return optionsDiv;
};
/**
* The HomeControl adds a control to the map that simply
* returns the user to Chicago. This constructor takes
* the control DIV as an argument.
* @constructor
*/
Map.GoogleMaps.prototype.createControl = function(label, icon) {
// Set CSS styles for the DIV containing the control
// Setting padding to 5 px will offset the control
// from the edge of the map
var controlDiv = document.createElement('div');
controlDiv.style.padding = '5px';
// Set CSS for the control border
var controlUI = document.createElement('div');
controlUI.style.backgroundColor = 'white';
controlUI.style.border = '1px solid rgb(113, 123, 135)';
controlUI.style.borderRadius = '3px';
controlUI.style.boxShadow = 'rgba(0, 0, 0, 0.4) 0px 2px 4px';
controlUI.style.cursor = 'pointer';
controlUI.style.textAlign = 'center';
controlDiv.appendChild(controlUI);
if (icon) {
var controlIcon = document.createElement("img");
controlIcon.src = edApplication().getImagePath() + icon;
controlIcon.alt = label;
controlIcon.title = label;
controlUI.style.padding = '3px 2px 3px 2px';
controlUI.appendChild(controlIcon);
} else {
// Set CSS for the control interior
var controlText = document.createElement('div');
controlText.style.padding = '1px 6px';
controlText.innerHTML = label;
controlUI.appendChild(controlText);
}
return controlDiv;
};
Map.GoogleMaps.prototype.bindEvents = function() {
var that = this;
if (this.options.enterprisesAround) {
google.maps.event.addListener(this.GMap, "dragend", function(){
that.getGeoLocalizableListArround(this.getBounds());
});
google.maps.event.addListener(this.GMap, "zoomend", function(){
that.getGeoLocalizableListArround(this.getBounds());
});
google.maps.event.addListener(this.GMap, 'idle', function() {
that.getGeoLocalizableListArround(this.getBounds());
});
}
};
Map.GoogleMaps.prototype.createGeoLocalizableMarker = function(aGeoLocalizableObject) {
var icon;
if (aGeoLocalizableObject.isReference) {
var icon = new google.maps.MarkerImage(edApplication().getImagePath() + "maps/InitialPoint.png",
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(16, 32)
);
} else {
if (aGeoLocalizableObject.type == "Enterprise") {
var icon = new google.maps.MarkerImage(edApplication().getImagePath() + "maps/EnterprisePoint.png",
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(16, 32)
);
}
if (aGeoLocalizableObject.type == "Person") {
var icon = new google.maps.MarkerImage(edApplication().getImagePath() + "maps/PersonPoint.png",
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(16, 32)
);
}
if (aGeoLocalizableObject.type == "Location") {
var icon = new google.maps.MarkerImage(edApplication().getImagePath() + "maps/LocationPoint.png",
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(16, 32)
);
}
}
var point = new google.maps.LatLng(aGeoLocalizableObject.latitude, aGeoLocalizableObject.longitude);
var marker = new google.maps.Marker({
position: point,
//map: this.GMap,
icon: icon
});
this.markerCluster.addMarker(marker);
//var marker = new GMarker(point, {zIndexProcess:this._importanceOrder, icon:realIcon});
marker.importance = 1;
marker.address = aGeoLocalizableObject.gMapFormattedAddress;
marker.geoLocalizableObject = aGeoLocalizableObject;
//on click : show the htmlToolTip
if (aGeoLocalizableObject.htmlToolTip != "") {
aGeoLocalizableObject.htmlToolTip = aGeoLocalizableObject.htmlToolTip + '
';
aGeoLocalizableObject.htmlToolTip = aGeoLocalizableObject.htmlToolTip + '';
aGeoLocalizableObject.htmlToolTip = aGeoLocalizableObject.htmlToolTip + '';
aGeoLocalizableObject.htmlToolTip = aGeoLocalizableObject.htmlToolTip + '';
aGeoLocalizableObject.htmlToolTip = aGeoLocalizableObject.htmlToolTip + '
';
marker.infoWindow = new google.maps.InfoWindow({
content: aGeoLocalizableObject.htmlToolTip
});
var that = this;
google.maps.event.addListener(marker, 'click', function() {
this.infoWindow.open(that.GMap, this);
});
}
return marker;
};
Map.GoogleMaps.prototype.createActorMarkers = function() {
var that = this;
if (this.actor.address != "") {
edApplication().geocoder.geocode({'address': this.actor.address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var icon = new google.maps.MarkerImage(edApplication().getImagePath() + "maps/ActorPoint.png",
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(16, 32)
);
var point = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
var marker = new google.maps.Marker({
position: point,
map: that.GMap,
icon: icon
});
var tooltip = '
';
tooltip = tooltip + '
';
tooltip = tooltip + '';
tooltip = tooltip + '';
tooltip = tooltip + '';
tooltip = tooltip + '
';
tooltip = tooltip + edApplication().labels.YOURPERSONALADDRESS + "
" + that.actor.address;
marker.infoWindow = new google.maps.InfoWindow({
content: tooltip
});
google.maps.event.addListener(marker, 'click', function() {
this.infoWindow.open(that.GMap, this);
});
marker.address = that.actor.address;
that.actor.addressMarker = marker;
//now geolocalize site address
if (that.actor.siteAddress != "") {
edApplication().geocoder.geocode({'address': that.actor.siteAddress}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var icon = new google.maps.MarkerImage(edApplication().getImagePath() + "maps/ActorSitePoint.png",
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(16, 32)
);
var point = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
var marker = new google.maps.Marker({
position: point,
map: that.GMap,
icon: icon
});
var tooltip = '
';
tooltip = tooltip + '
';
tooltip = tooltip + '';
tooltip = tooltip + '';
tooltip = tooltip + '';
tooltip = tooltip + '
';
tooltip = tooltip + edApplication().labels.YOURPROFESSIONALADDRESS + "
" + that.actor.siteAddress;
marker.infoWindow = new google.maps.InfoWindow({
content: tooltip
});
google.maps.event.addListener(marker, 'click', function() {
this.infoWindow.open(that.GMap, this);
});
marker.address = that.actor.siteAddress;
that.actor.siteAddressMarker = marker;
that.itinerarySteps.add({marker: that.actor.siteAddressMarker});
//trigger
$(document).trigger("actorGeolocalized");
} else {
that.itinerarySteps.add({marker: that.actor.addressMarker});
$(document).trigger("actorGeolocalized");
}
});
} else {
$(document).trigger("actorGeolocalized");
}
}
});
}
};
Map.GoogleMaps.prototype.getGeoLocalizableListArround = function(bounds){
var entLaMin = bounds.getSouthWest().lat();
var entLoMin = bounds.getSouthWest().lng();
var entLaMax = bounds.getNorthEast().lat();
var entLoMax = bounds.getNorthEast().lng();
var actionToCall = "";
//actionToCall = GeoLocalizableBeans.GeoLocalizeBean.TYPES[this.initialGeoLocalizableBean.type];
actionToCall = this.referenceGeolocalizable.onMapBoundsChangeAction;
if (actionToCall != '') {
var url = actionToCall + ".fl";
var data = { id:this.referenceGeolocalizable.id,
EntLaMin: parseFloat(entLaMin),
EntLoMin: parseFloat(entLoMin),
EntLaMax: parseFloat(entLaMax),
EntLoMax: parseFloat(entLoMax),
la: this.referenceGeolocalizable.latitude,
lo: this.referenceGeolocalizable.longitude
};
var that = this;
$.ajax({
url: url ,
data: data,
dataType:"json",
context: this,
//timeout: 5000,
success: function(data, textStatus, jqXHR) {
var displayResult = true;
if (typeof data.markers != 'undefined'){
$.each(data.markers, function(index, object){
if (!that.geolocalizables.get(object.id)) {
var aGeoLocalizableObject = new GeoLocalizableBeans.GeoLocalizeBean(object.id);
aGeoLocalizableObject.init(object.type,
object.latitude,
object.longitude,
object.label,
object.address1,
object.address2,
object.address3,
object.zipCode,
object.city,
object.country,
object.htmlToolTip);
var marker = that.createGeoLocalizableMarker(aGeoLocalizableObject);
aGeoLocalizableObject.marker = marker;
that.geolocalizables.add(aGeoLocalizableObject);
}
});
}
//if (window.oMapDisplayer.poly) window.oMapDisplayer.GMap.addOverlay(window.oMapDisplayer.poly);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("error :");
console.log("jqXHR :");
console.log(jqXHR);
console.log("textStatus :");
console.log(textStatus);
console.log("errorThrown :");
console.log(errorThrown);
}
});
}
};