PageSourceSearch

https://giassociates.com/wp-content/themes/gi-associates/js/maps.js?ver=20200107

js giassociates.com collected 2026-10-06 00:18:30 UTC 4,158 bytes, 140 lines download raw bytes

1// This file provides google map functionality // second version
2const geocodingUrl = "https://maps.googleapis.com/maps/api/geocode/json?";
3
4const map = function () { };
5
6// Init the google map
7map.prototype.init = function () {
8    this.mapContainer = document.querySelector(".js-map .map");
9
10    if (!this.mapContainer || this.mapContainer.length < 1) {
11        // End early because the map doesn't exist here
12        return;
13    }
14
15    this.map = new google.maps.Map(this.mapContainer, {
16        zoom: 13,
17        center: new google.maps.LatLng(43.061773, -88.12382)
18    });
19
20    this.markers = [];
21
22    this.refresh(locationData);
23};
24
25// Update the data here
26map.prototype.refresh = function (newData) {
27    if (this.isRefreshing) {
28        // Try again later
29        setTimeout(function () {
30            window.map.refresh(newData);
31        }, 2000);
32        return;
33    }
34    // Set the refresh state
35    window.map.isRefreshing = true;
36
37    // Maintain reference to this object throughout method
38    const map = this; // proxy
39    // Set location data to the new Data
40    map.locationData = newData;
41
42    // Delete all location markers
43    map.markers.forEach(function (marker) {
44        marker.setMap(null);
45    });
46
47    // Clear original markers
48    map.markers = [];
49
50    // Iterate through the location data and create markers
51    map.locationData.map(function (location) {
52        return map.getMarker(location, map);
53    });
54    // Done Refreshing 
55    this.isRefreshing = false;
56};
57
58/**
59 * This function gets the marker from the cache or geocodes a new one
60 * @returns a marker
61 */
62map.prototype.getMarker = function (location, mapObject) {
63    // return new Promise(function (resolve, reject) {
64    // we need to create a new marker
65    // const isValidLocation = getLocation(location, mapObject, mapObject.updateMarker);
66    const map = mapObject.map;
67    const isValidLocation = mapObject.updateMarker(mapObject, location);
68
69    if (!isValidLocation) {
70        console.log("Invalid location inside getMarker");
71        return;
72    }
73    const markers = mapObject.markers;
74    const bounds = new google.maps.LatLngBounds();
75
76    markers.forEach(function (marker) {
77        const currLat = marker.getPosition().lat();
78        const currLong = marker.getPosition().lng();
79        const latLng = new google.maps.LatLng(currLat, currLong);
80
81        if (!map.getCenter()) {
82            map.setCenter(latLng);
83        }
84
85        bounds.extend(marker.position);
86    });
87
88    // mapObject.map.setCenter(bounds.getCenter());
89    mapObject.map.fitBounds(bounds);
90};
91
92/**
93 * Callback function for updating the list of markers and adding the marker to the cached list if it doesn't exist there
94 * @param mapObject the instance of the map object prototype
95 * @param locationObject the location object with an id, title, permalink, lat, and lng
96 */
97map.prototype.updateMarker = function (mapObject, locationObject) {
98    const coords = locationObject.location;
99
100    if (!coords.lat || !coords.lng) {
101        // Don't try to display empty coords
102        return false;
103
104    } else {
105        // Convert from strings to numbers
106        const lat = parseFloat(coords.lat);
107        const lng = parseFloat(coords.lng);
108
109        const numCoords = { lat: lat, lng: lng };
110
111        let marker;
112
113        marker = new google.maps.Marker({
114            id: locationObject.id,
115            icon:
116                "http://uat.gi-associates.seventysevencreative.io/wp-content/themes/gi-associates/images/gi-map-marker.png",
117            position: numCoords,
118            title: locationObject.title,
119            url: locationObject.permalink
120        });
121
122        // Reset the map bounds to include the current marker
123        marker.setMap(mapObject.map);
124
125        google.maps.event.addListener(marker, "click", function () {
126            window.open(marker.url);
127        });
128
129        mapObject.markers.push(marker);
130        return true;
131    }
132};
133
134// Only show the map when the page is set up for it
135window.addEventListener("DOMContentLoaded", function (event) {
136    if (typeof locationData !== "undefined") {
137        window.map = new map();
138        window.map.init();
139    }
140});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.