PageSourceSearch

https://www.duffielddentist.co.uk/wp-content/plugins/wp-google-maps/js/v8/pointlabel.js?ver=10.1.04

js duffielddentist.co.uk collected 2026-10-05 23:51:43 UTC 5,226 bytes, 256 lines download raw bytes

1/**
2 * @namespace WPGMZA
3 * @module Pointlabel
4 * @requires WPGMZA.Feature
5 */
6jQuery(function($) {
7	
8	WPGMZA.Pointlabel = function(options, pointlabel){
9		var self = this;
10		
11		WPGMZA.assertInstanceOf(this, "Pointlabel");
12		
13		if(!options)
14			options = {};
15		
16		if(options.map){
17			this.map = options.map;
18		} else if(!options.map && options.map_id){
19			let map = WPGMZA.getMapByID(options.map_id);
20			if(map){
21				this.map = map;
22			}
23		} 
24
25		this.center = new WPGMZA.LatLng();
26
27
28		WPGMZA.Feature.apply(this, arguments);
29
30		if(pointlabel){
31			this.setPosition(pointlabel.getPosition());
32
33			if(pointlabel.marker){
34				this.marker = pointlabel.marker;
35			}
36		}
37
38		this.on('mapchanged', this.updateNativeMap);
39		this.on('mapchanged', this.updateNativeFeature);
40	}
41	
42	WPGMZA.Pointlabel.prototype = Object.create(WPGMZA.Feature.prototype);
43	WPGMZA.Pointlabel.prototype.constructor = WPGMZA.Pointlabel;
44
45	Object.defineProperty(WPGMZA.Pointlabel.prototype, "map", {
46		enumerable: true,
47		"get": function(){
48			if(this._map){
49				return this._map;
50			}
51			
52			return null;
53		},
54		"set" : function(a){
55			if(this.textFeature && !a){
56				this.textFeature.remove();
57			}
58			this._map = a;
59
60			if(this.textFeature){
61				this.trigger("mapchanged");
62			}
63		}
64		
65	});
66
67	WPGMZA.Pointlabel.getConstructor = function(){
68		switch(WPGMZA.settings.engine){
69			case "open-layers":
70			case "open-layers-latest":
71				if(WPGMZA.isProVersion()){
72					return WPGMZA.OLProPointlabel;
73					break;
74				}
75				return WPGMZA.OLPointlabel;
76				break;
77			case "leaflet":
78			case "leaflet-azure":
79			case "leaflet-stadia":
80			case "leaflet-maptiler":
81			case "leaflet-locationiq":
82			case "leaflet-zerocost":
83				if(WPGMZA.isProVersion()){
84					return WPGMZA.LeafletProPointlabel;
85					break;
86				}
87				return WPGMZA.LeafletPointlabel;
88				break;
89			
90			default:
91				if(WPGMZA.isProVersion()){
92					return WPGMZA.GoogleProPointlabel;
93					break;
94				}
95				return WPGMZA.GooglePointlabel;
96				break;
97		}
98	}
99
100	WPGMZA.Pointlabel.createInstance = function(options, pointlabel){
101		var constructor = WPGMZA.Pointlabel.getConstructor();
102		return new constructor(options, pointlabel);
103	}
104
105	WPGMZA.Pointlabel.createEditableMarker = function(options){
106		var options = $.extend({
107			draggable: true,
108			disableInfoWindow: true
109		}, options);
110		
111		if(options.pointlabel){
112			let latLng = options.pointlabel.getPosition();
113			options.lat = latLng.lat;
114			options.lng = latLng.lng;
115		}
116		
117
118		var marker = WPGMZA.Marker.createInstance(options);
119		
120		// NB: Hack for constructor not accepting icon prooperly. Once it does, this can be removed
121		var callback = function(){
122			try{
123				// Try use Pro method to set a custom icon
124				marker.setIcon(WPGMZA.labelpointIcon);
125			} catch (ex){ }
126			
127			marker.off("added", callback);
128		};
129
130		marker.on("added", callback);
131
132		return marker;
133	}
134
135	WPGMZA.Pointlabel.prototype.setEditable = function(editable){
136		var self = this;
137		
138		if(this.marker){
139			this.marker.map.removeMarker(this.marker);
140			delete this.marker;
141		}
142		
143		if(this._prevMap){
144			delete this._prevMap;
145		}
146		
147		if(editable){
148			var options = {
149				pointlabel: this
150			};
151
152			this.marker = WPGMZA.Pointlabel.createEditableMarker(options);
153			this.map.addMarker(this.marker);
154			
155			
156			this._dragEndCallback = function(event) {
157				self.onDragEnd(event);
158			};
159
160			var map = this.map;
161
162			this.marker.on("dragend", this._dragEndCallback);
163			
164			map.on("pointlabelremoved", function(event) {
165				if(event.pointlabel !== self)
166					return;
167			});
168		}
169	}
170
171	WPGMZA.Pointlabel.prototype.onDragEnd = function(event){
172		if(!(event.target instanceof WPGMZA.Marker))
173			return;
174			
175		
176		if(!this.marker)
177			return;
178
179		if(event.latLng){
180			this.setPosition(event.latLng);
181		}
182		
183		this.trigger("change");
184	}
185
186	WPGMZA.Pointlabel.prototype.onMapMouseDown = function(event){
187		if(event.button == 0){
188			this._mouseDown = true;
189			event.preventDefault();
190			return false;
191		}
192	}
193	
194	WPGMZA.Pointlabel.prototype.onWindowMouseUp = function(event){
195		if(event.button == 0)
196			this._mouseDown = false;
197	}
198	
199	WPGMZA.Pointlabel.prototype.onMapMouseMove = function(event){
200		if(!this._mouseDown)
201			return;
202		
203		var pixels = {
204			x: event.pageX - $(this.map.element).offset().left,
205			y: (event.pageY + 30) - $(this.map.element).offset().top
206		}
207		
208		var latLng = this.map.pixelsToLatLng(pixels);
209		
210		if(latLng){
211			this.setPosition(latLng);
212		}
213
214		this.trigger("change");
215	}
216
217	WPGMZA.Pointlabel.prototype.getPosition = function(){
218		if(this.center){
219			return new WPGMZA.LatLng({
220				lat : this.center.lat,
221				lng : this.center.lng,
222			});
223		}
224		return null;
225	}
226
227	WPGMZA.Pointlabel.prototype.setPosition = function(position){
228		this.center = {};
229		this.center.lat = position.lat;
230		this.center.lng = position.lng;
231
232		if(this.textFeature){
233			this.textFeature.setPosition(this.getPosition());
234		}
235	}
236
237	WPGMZA.Pointlabel.prototype.getMap = function(){
238		return this.map;
239	}
240
241	WPGMZA.Pointlabel.prototype.setMap = function(map){
242		if(this.map){
243			this.map.removePointlabel(this);
244		}
245		
246		if(map){
247			map.addPointlabel(this);
248		}		
249	}
250
251	WPGMZA.Pointlabel.prototype.updateNativeMap = function(){
252		if(this.textFeature){
253			this.textFeature.setMap(this.map ? this.map : null);
254		}
255	}
256});

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.