| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- var markerGroups = [];
- $(function() {
- $("a[data-customer-id]").click(function(event) {
- let customerId = $(this).data("customer-id");
- let key = "customer-" + customerId;
- if(typeof markerGroups[key] !== "undefined") {
- for(let i in markerGroups[key]) {
- let m = markerGroups[key][i];
- m.setMap(null);
- }
- }
- let selected = $(this).data("selected");
- if(selected) {
- $(this).data("selected", false);
- $(this).find(".badge").removeClass("badge-success").text("");
- }
- else {
- loadCustomerLocations(customerId);
- }
- return false;
- });
- $("a[data-project-id]").click(function(event) {
- let projectId = $(this).data("project-id");
- let key = "project-" + projectId;
- if(typeof markerGroups[key] !== "undefined") {
- for(let i in markerGroups[key]) {
- let m = markerGroups[key][i];
- m.setMap(null);
- }
- }
- let selected = $(this).data("selected");
- if(selected) {
- $(this).data("selected", false);
- $(this).find(".badge").removeClass("badge-success").text("");
- }
- else {
- loadProjectLocations(projectId);
- }
- return false;
- });
- });
- function loadCustomerLocations(customerId) {
- $.get("/account/map-overview/get-customer-locations", {
- customer_id: customerId,
- submit: $("#submit").val()
- }, function(response) {
- if(!response.success) return false;
- let map = maps["map"];
- let key = "customer-" + customerId;
- markerGroups[key] = [];
- for(let i in response.locations) {
- let l = response.locations[i];
- let position = {
- lat: l.latitude,
- lng: l.longitude
- };
- var options = {
- position: position,
- title: l.name,
- map: map
- };
- if(l.icon) options.icon = l.icon;
- let marker = new google.maps.Marker(options);
- markerGroups[key].push(marker);
- }
- $("a[data-customer-id=" + customerId + "]").data("selected", true);
- $("a[data-customer-id=" + customerId + "]").find(".badge").addClass("badge-danger").text(response.locations.length);
- });
- }
- function loadProjectLocations(projectId) {
- $.get("/account/map-overview/get-project-locations", {
- project_id: projectId,
- submit: $("#submit").val()
- }, function(response) {
- if(!response.success) return false;
- let map = maps["map"];
- let key = "project-" + projectId;
- markerGroups[key] = [];
- for(let i in response.locations) {
- let l = response.locations[i];
- let position = {
- lat: l.latitude,
- lng: l.longitude
- };
- var options = {
- position: position,
- title: l.name,
- map: map
- };
- if(l.icon) options.icon = l.icon;
- let marker = new google.maps.Marker(options);
- markerGroups[key].push(marker);
- }
- $("a[data-project-id=" + projectId + "]").data("selected", true);
- $("a[data-project-id=" + projectId + "]").find(".badge").addClass("badge-danger").text(response.locations.length);
- });
- }
|