PageSourceSearch

https://stonemaiergames.com/wp-content/plugins/wp-google-maps/js/v…?ver=10.1.09%2Bpro-10.1.05

js stonemaiergames.com collected 2026-09-24 15:30:25 UTC 3,377 bytes, 114 lines download raw bytes

1/**
2 * @namespace WPGMZA
3 * @module NominatimAutocomplete
4 * @requires WPGMZA.Autocomplete
5 */
6jQuery(function($) {
7	
8	var Parent = WPGMZA.Autocomplete;
9
10	WPGMZA.NominatimAutocomplete = function(element, options) {
11		Parent.call(this, element, options);
12	}
13
14	WPGMZA.NominatimAutocomplete.prototype = Object.create(Parent.prototype);
15	WPGMZA.NominatimAutocomplete.prototype.constructor = WPGMZA.NominatimAutocomplete;
16	
17	WPGMZA.NominatimAutocomplete.prototype.autoload = function() {
18		WPGMZA.Autocomplete.prototype.autoload.apply(this, arguments);
19
20        this.prepare();
21        this.setReady(true);
22	}
23
24	WPGMZA.NominatimAutocomplete.prototype.getProvider = function(){
25        return WPGMZA.Autocomplete.Providers.NOMINATIM;
26	}
27
28	WPGMZA.NominatimAutocomplete.prototype.find = function(){
29		WPGMZA.Autocomplete.prototype.find.apply(this, arguments);
30
31        let term = this.getTerm();
32        if(term){
33            
34            this.setBusy(true);
35            this.queryCache(term, (locations) => {
36                if(locations && locations.length){
37                    this.setItems(locations);
38                    this.setBusy(false);
39                    this.present();
40                } else {
41                    this.queryNominatim(term, (locations) => {
42                        if(locations && locations.length){
43                            this.setItems(locations);
44                            this.setBusy(false);
45                            this.present();
46                        }
47                    })
48                }
49            });
50        }
51	}
52
53	WPGMZA.NominatimAutocomplete.prototype.remapItem = function(item){
54		return {
55			display : item.displayName ? item.displayName : false,
56			address : item.adrFormatAddress ? item.adrFormatAddress : false,
57			type : item.primaryTypeDisplayName ? item.primaryTypeDisplayName.replaceAll("_", " ") : "Location"
58		};
59	}
60
61    WPGMZA.NominatimAutocomplete.prototype.queryCache = function(query, callback) {
62		WPGMZA.restAPI.call("/geocode-cache", {
63			data: {
64				query: JSON.stringify({location: query, options: {address : query}})
65			},
66			success: function(response, xhr, status) {
67				callback(response);
68			},
69			useCompressedPathVariable: true
70		});
71	}
72
73    WPGMZA.NominatimAutocomplete.prototype.queryNominatim = function(query, callback) {
74        const config = this.getConfig(query);
75		
76        if(this.options && this.options.country){
77            config.countrycodes = this.options.country;
78        }
79
80		config._query = JSON.stringify({location: query, options: {address : query}});
81		
82		WPGMZA.restAPI.call("/query-nominatim", {
83			data: {
84				data: config,
85			},
86			success: function(response, xhr, status) {
87				if(response && response.length){
88					callback(response);
89				} else {
90					callback(null)
91				}
92			},
93			error: function(response, xhr, status) {
94				callback(null)
95			}
96		});
97	}
98
99    WPGMZA.NominatimAutocomplete.prototype.getConfig = function(term){
100		return {
101			q : term,
102			format : "json"
103		};
104	}
105
106    WPGMZA.NominatimAutocomplete.prototype.remapItem = function(item){
107		return {
108			display : item.name ? item.name : false,
109			address : item.display_name ? item.display_name : false,
110			type : item.addresstype ? WPGMZA.capitalizeWords(item.addresstype.replaceAll("_", " ")) : "Location",
111            coordinates : item.lat && item.lon ? `${item.lat}, ${item.lon}` : false
112		};
113	}
114});

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.