PageSourceSearch

https://dubai-real.estate/assets/parts/js/markerwithlabel.js

js dubai-real.estate collected 2026-10-07 02:15:47 UTC 25,434 bytes, 631 lines download raw bytes

1/**
2 * @name MarkerWithLabel for V3
3 * @version 1.2.2
4 * @author Gary Little (inspired by code from Marc Ridey of Google).
5 * @copyright Copyright 2012 Gary Little [gary at luxcentral.com]
6 * @fileoverview MarkerWithLabel extends the Google Maps JavaScript API V3
7 *  <code>google.maps.Marker</code> class.
8 *  <p>
9 *  MarkerWithLabel allows you to define markers with associated labels. As you would expect,
10 *  if the marker is draggable, so too will be the label. In addition, a marker with a label
11 *  responds to all mouse events in the same manner as a regular marker. It also fires mouse
12 *  events and "property changed" events just as a regular marker would.
13 */
14
15/*!
16 *
17 * Licensed under the Apache License, Version 2.0 (the "License");
18 * you may not use this file except in compliance with the License.
19 * You may obtain a copy of the License at
20 *
21 *       http://www.apache.org/licenses/LICENSE-2.0
22 *
23 * Unless required by applicable law or agreed to in writing, software
24 * distributed under the License is distributed on an "AS IS" BASIS,
25 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 * See the License for the specific language governing permissions and
27 * limitations under the License.
28 */
29
30/*jslint browser:true */
31/*global document,google */
32
33/**
34 * @param {Function} childCtor Child class.
35 * @param {Function} parentCtor Parent class.
36 * @private
37 */
38function inherits(childCtor, parentCtor) {
39  /* @constructor */
40  function tempCtor() {}
41  tempCtor.prototype = parentCtor.prototype;
42  childCtor.superClass_ = parentCtor.prototype;
43  childCtor.prototype = new tempCtor();
44  /* @override */
45  childCtor.prototype.constructor = childCtor;
46}
47
48/**
49 * This constructor creates a label and associates it with a marker.
50 * It is for the private use of the MarkerWithLabel class.
51 * @constructor
52 * @param {Marker} marker The marker with which the label is to be associated.
53 * @param {string} crossURL The URL of the cross image =.
54 * @private
55 */
56function MarkerLabel_(marker, crossURL) {
57  this.marker_ = marker;
58
59  this.labelDiv_ = document.createElement("div");
60  this.labelDiv_.style.cssText = "position: absolute; overflow: hidden;";
61
62  // Set up the DIV for handling mouse events in the label. This DIV forms a transparent veil
63  // in the "overlayMouseTarget" pane, a veil that covers just the label. This is done so that
64  // events can be captured even if the label is in the shadow of a google.maps.InfoWindow.
65  // Code is included here to ensure the veil is always exactly the same size as the label.
66  this.eventDiv_ = document.createElement("div");
67  this.eventDiv_.style.cssText = this.labelDiv_.style.cssText;
68
69  // This is needed for proper behavior on MSIE:
70  this.eventDiv_.setAttribute("onselectstart", "return false;");
71  this.eventDiv_.setAttribute("ondragstart", "return false;");
72
73  // Get the DIV for the "X" to be displayed when the marker is raised.
74  this.crossDiv_ = MarkerLabel_.getSharedCross(crossURL);
75}
76
77if (typeof google !== 'undefined') {
78  inherits(MarkerLabel_, google.maps.OverlayView);
79}
80
81
82/**
83 * Returns the DIV for the cross used when dragging a marker when the
84 * crossOnDrag parameter set to true. One cross is shared with all markers.
85 * @param {string} crossURL The URL of the cross image.
86 * @private
87 */
88MarkerLabel_.getSharedCross = function (crossURL) {
89  var div;
90  if (typeof MarkerLabel_.getSharedCross.crossDiv === "undefined") {
91    div = document.createElement("img");
92    div.style.cssText = "position: absolute; z-index: 1000002; display: none;";
93    // Hopefully Google never changes the standard "X" attributes:
94    div.style.marginLeft = "-8px";
95    div.style.marginTop = "-9px";
96    div.src = crossURL;
97    MarkerLabel_.getSharedCross.crossDiv = div;
98  }
99  return MarkerLabel_.getSharedCross.crossDiv;
100};
101
102/**
103 * Adds the DIV representing the label to the DOM. This method is called
104 * automatically when the marker's <code>setMap</code> method is called.
105 * @private
106 */
107MarkerLabel_.prototype.onAdd = function () {
108  var me = this;
109
110  this.getPanes().markerLayer.appendChild(this.labelDiv_);
111  this.getPanes().overlayMouseTarget.appendChild(this.eventDiv_);
112  // One cross is shared with all markers, so only add it once:
113  if (typeof MarkerLabel_.getSharedCross.processed === "undefined") {
114    this.getPanes().overlayImage.appendChild(this.crossDiv_);
115    MarkerLabel_.getSharedCross.processed = true;
116  }
117
118  this.addMouseListeners();
119
120  this.listeners2_ = [
121    google.maps.event.addListener(this.marker_, "clickable_changed", function () {
122      me.setClickable();
123    }),
124    google.maps.event.addListener(this.marker_, "cursor_changed", function () {
125      me.setCursor();
126    }),
127    google.maps.event.addListener(this.marker_, "draggable_changed", function () {
128      me.setClickable();
129    }),
130    google.maps.event.addListener(this.marker_, "position_changed", function () {
131      me.setPosition();
132    }),
133    google.maps.event.addListener(this.marker_, "visible_changed", function () {
134      me.setVisible();
135    }),
136    google.maps.event.addListener(this.marker_, "title_changed", function () {
137      me.setTitle();
138    }),
139    google.maps.event.addListener(this.marker_, "zindex_changed", function () {
140      me.setZIndex();
141    }),
142    google.maps.event.addListener(this.marker_, "labelanchor_changed", function () {
143      me.setAnchor();
144    }),
145    google.maps.event.addListener(this.marker_, "labelclass_changed", function () {
146      me.setStyles();
147    }),
148    google.maps.event.addListener(this.marker_, "labelcontent_changed", function () {
149      me.setContent();
150    }),
151    google.maps.event.addListener(this.marker_, "labelstyle_changed", function () {
152      me.setStyles();
153    }),
154    google.maps.event.addListener(this.marker_, "labelvisible_changed", function () {
155      me.setVisible();
156    })
157  ];
158};
159
160/**
161 * Adds the listeners for a clickable label.
162 * @private
163 */
164MarkerLabel_.prototype.addMouseListeners = function () {
165  var me = this;
166  var cTouchScreen = false;
167  var cMouseIsDown = false;
168  var cDraggingLabel = false;
169  var cIgnoreClick;
170  var cLatOffset, cLngOffset;
171
172  // Stop all processing of an event.
173  //
174  var cAbortEvent = function (e) {
175    e = e || window.event;
176    if (e.stopPropagation) {
177      e.stopPropagation();
178    } else {
179      e.cancelBubble = true;
180    }
181    if (e.preventDefault) {
182      e.preventDefault();
183    } else {
184      e.returnValue = false;
185    }
186  };
187
188  // Stop an event from propagating.
189  //
190  var cStopPropagation = function (e) {
191    e = e || window.event;
192    if (e.stopPropagation) {
193      e.stopPropagation();
194    } else {
195      e.cancelBubble = true;
196    }
197  };
198
199  this.listeners1_ = [
200    google.maps.event.addDomListener(this.eventDiv_, "mouseover", function (e) {
201      var mEvent = {latLng: me.marker_.getPosition()};
202      if (me.marker_.getClickable() || me.marker_.getDraggable()) {
203        if (!cTouchScreen) {
204          this.style.cursor = (me.marker_.getCursor() || "pointer");
205          google.maps.event.trigger(me.marker_, "mouseover", mEvent);
206          cAbortEvent(e);
207        }
208      } else {
209        this.style.cursor = null;
210      }
211    }),
212    google.maps.event.addDomListener(this.eventDiv_, "mouseout", function (e) {
213      var mEvent = {latLng: me.marker_.getPosition()};
214      if (me.marker_.getClickable() || me.marker_.getDraggable()) {
215        if (!cTouchScreen) {
216          google.maps.event.trigger(me.marker_, "mouseout", mEvent);
217          cAbortEvent(e);
218        }
219      }
220    }),
221    google.maps.event.addDomListener(this.eventDiv_, "mousedown", function (e) {
222      var mEvent = {latLng: me.marker_.getPosition()};
223      cDraggingLabel = false;
224      if (me.marker_.getClickable() || me.marker_.getDraggable()) {
225        cMouseIsDown = true;
226        google.maps.event.trigger(me.marker_, "mousedown", mEvent);
227        if (!cTouchScreen) {
228          cAbortEvent(e); // Prevent map pan when starting a drag on a label
229        }
230      }
231    }),
232    google.maps.event.addDomListener(this.eventDiv_, "mouseup", function (e) {
233      var mEvent = {latLng: me.marker_.getPosition()};
234      if (cMouseIsDown) {
235        cMouseIsDown = false;
236        google.maps.event.trigger(me.marker_, "mouseup", mEvent);
237        if (cDraggingLabel) {
238          cDraggingLabel = false;
239          me.crossDiv_.style.display = "none";
240          cIgnoreClick = true; // Set flag to ignore the click event reported after a label drag
241          google.maps.event.trigger(me.marker_, "dragend", mEvent);
242        }
243        if (!me.marker_.getDraggable()) {
244          cAbortEvent(e);
245        }
246      }
247    }),
248    google.maps.event.addDomListener(this.eventDiv_, "click", function (e) {
249      var mEvent = {latLng: me.marker_.getPosition()};
250      if (me.marker_.getClickable() || me.marker_.getDraggable()) {
251        if (cIgnoreClick) { // Ignore the click reported when a label drag ends
252          cIgnoreClick = false;
253        } else {
254          google.maps.event.trigger(me.marker_, "click", mEvent);
255        }
256        cAbortEvent(e); // Prevent click from being passed on to map
257      }
258    }),
259    google.maps.event.addDomListener(this.eventDiv_, "dblclick", function (e) {
260      var mEvent = {latLng: me.marker_.getPosition()};
261      if (me.marker_.getClickable() || me.marker_.getDraggable()) {
262        google.maps.event.trigger(me.marker_, "dblclick", mEvent);
263        cAbortEvent(e); // Prevent map zoom when double-clicking on a label
264      }
265    }),
266    google.maps.event.addListener(this.marker_.getMap(), "mousemove", function (mEvent) {
267      var position;
268      if (cMouseIsDown && me.marker_.getDraggable()) {
269        if (cDraggingLabel) {
270          // Change the reported location from the mouse position to the marker position:
271          mEvent.latLng = new google.maps.LatLng(mEvent.latLng.lat() - cLatOffset, mEvent.latLng.lng() - cLngOffset);
272          if (me.marker_.get("crossOnDrag")) { // Position and display the cross
273            position = me.getProjection().fromLatLngToDivPixel(mEvent.latLng);
274            me.crossDiv_.style.left = position.x + "px";
275            me.crossDiv_.style.top = position.y + "px";
276            me.crossDiv_.style.display = "";
277          }
278          google.maps.event.trigger(me.marker_, "drag", mEvent);
279        } else {
280          // Calculate offsets from the click point to the marker position:
281          cLatOffset = mEvent.latLng.lat() - me.marker_.getPosition().lat();
282          cLngOffset = mEvent.latLng.lng() - me.marker_.getPosition().lng();
283          cDraggingLabel = true;
284          mEvent.latLng = me.marker_.getPosition();
285          google.maps.event.trigger(me.marker_, "dragstart", mEvent);
286        }
287      }
288    }),
289    google.maps.event.addListener(this.marker_, "dragstart", function (mEvent) {
290      // During a drag, the marker's z-index is temporarily set to 1000000 to ensure
291      // it appears above all other markers. Here we also set the label's z-index
292      // to 1000000 (plus or minus 1 depending on whether the label is supposed
293      // to be above or below the marker). (NOTE: For some reason, Google does not
294      // fire a zindex_changed event when changing the marker's z-index to 100000
295      // or else this task would be handled by the MarkerLabel_.setZIndex() method.)
296      //
297      me.labelDiv_.style.zIndex = 1000000 + (this.get("labelInBackgroun
297d") ? -1 : +1);
298      me.eventDiv_.style.zIndex = me.labelDiv_.style.zIndex;
299    }),
300    google.maps.event.addListener(this.marker_, "drag", function (mEvent) {
301      this.setPosition(mEvent.latLng);
302    }),
303    google.maps.event.addListener(this.marker_, "dragend", function (mEvent) {
304      me.setZIndex();
305    }),
306    // Prevent touch events from passing through the label DIV to the underlying map.
307    //
308    google.maps.event.addDomListener(this.eventDiv_, "touchstart", function (e) {
309      cTouchScreen = true;
310      cStopPropagation(e);
311    }),
312    google.maps.event.addDomListener(this.eventDiv_, "touchmove", function (e) {
313      cStopPropagation(e);
314    }),
315    google.maps.event.addDomListener(this.eventDiv_, "touchend", function (e) {
316      cStopPropagation(e);
317    })
318  ];
319};
320
321/**
322 * Removes the listeners for a clickable label.
323 * @private
324 */
325MarkerLabel_.prototype.removeMouseListeners = function () {
326  var i;
327
328  if (this.listeners1_) {
329    for (i = 0; i < this.listeners1_.length; i++) {
330      google.maps.event.removeListener(this.listeners1_[i]);
331    }
332  }
333};
334
335/**
336 * Removes the DIV for the label from the DOM. It also removes all event handlers.
337 * This method is called automatically when the marker's <code>setMap(null)</code>
338 * method is called.
339 * @private
340 */
341MarkerLabel_.prototype.onRemove = function () {
342  var i;
343  if (this.labelDiv_.parentNode) {
344    this.labelDiv_.parentNode.removeChild(this.labelDiv_);
345  }
346  if (this.eventDiv_.parentNode) {
347    this.eventDiv_.parentNode.removeChild(this.eventDiv_);
348  }
349  // Remove event listeners:
350  this.removeMouseListeners();
351
352  if (this.listeners2_) {
353    for (i = 0; i < this.listeners2_.length; i++) {
354      google.maps.event.removeListener(this.listeners2_[i]);
355    }
356  }
357};
358
359/**
360 * Draws the label on the map.
361 * @private
362 */
363MarkerLabel_.prototype.draw = function () {
364  this.setContent();
365  this.setTitle();
366  this.setStyles();
367};
368
369/**
370 * Sets the content of the label.
371 * The content can be plain text or an HTML DOM node.
372 * @private
373 */
374MarkerLabel_.prototype.setContent = function () {
375  var content = this.marker_.get("labelContent");
376  var previousContent = this.marker_._previousContent;
377  if(previousContent !== content){
378    this.marker_._previousContent = content;
379    if (typeof content.nodeType === "undefined") {
380      this.labelDiv_.innerHTML = content;
381      this.eventDiv_.innerHTML = this.labelDiv_.innerHTML;
382    } else {
383      this.labelDiv_.innerHTML = ""; // Remove current content
384      this.labelDiv_.appendChild(content);
385      content = content.cloneNode(true);
386      this.eventDiv_.innerHTML = ""; // Remove current content
387      this.eventDiv_.appendChild(content);
388    }
389  }
390};
391
392/**
393 * Sets the content of the tool tip for the label. It is
394 * always set to be the same as for the marker itself.
395 * @private
396 */
397MarkerLabel_.prototype.setTitle = function () {
398  this.eventDiv_.title = this.marker_.getTitle() || "";
399};
400
401/**
402 * Sets the style of the label by setting the style sheet and applying
403 * other specific styles requested.
404 * @private
405 */
406MarkerLabel_.prototype.setStyles = function () {
407  var i, labelStyle;
408
409  // Apply style values from the style sheet defined in the labelClass parameter:
410  this.labelDiv_.className = this.marker_.get("labelClass");
411  this.eventDiv_.className = this.labelDiv_.className;
412
413  // Clear existing inline style values:
414  this.labelDiv_.style.cssText = "";
415  this.eventDiv_.style.cssText = "";
416  // Apply style values defined in the labelStyle parameter:
417  labelStyle = this.marker_.get("labelStyle");
418  for (i in labelStyle) {
419    if (labelStyle.hasOwnProperty(i)) {
420      this.labelDiv_.style[i] = labelStyle[i];
421      this.eventDiv_.style[i] = labelStyle[i];
422    }
423  }
424  this.setMandatoryStyles();
425};
426
427/**
428 * Sets the mandatory styles to the DIV representing the label as well as to the
429 * associated event DIV. This includes setting the DIV position, z-index, and visibility.
430 * @private
431 */
432MarkerLabel_.prototype.setMandatoryStyles = function () {
433  this.labelDiv_.style.position = "absolute";
434  this.labelDiv_.style.overflow = "hidden";
435  // Make sure the opacity setting causes the desired effect on MSIE:
436  if (typeof this.labelDiv_.style.opacity !== "undefined" && this.labelDiv_.style.opacity !== "") {
437    this.labelDiv_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(opacity=" + (this.labelDiv_.style.opacity * 100) + ")\"";
438    this.labelDiv_.style.filter = "alpha(opacity=" + (this.labelDiv_.style.opacity * 100) + ")";
439  }
440
441  this.eventDiv_.style.position = this.labelDiv_.style.position;
442  this.eventDiv_.style.overflow = this.labelDiv_.style.overflow;
443  this.eventDiv_.style.cursor = "pointer"; // Required to make this clickable on iOS
444  this.eventDiv_.style.opacity = 0.01; // Don't use 0; DIV won't be clickable on MSIE
445  this.eventDiv_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(opacity=1)\"";
446  this.eventDiv_.style.filter = "alpha(opacity=1)"; // For MSIE
447
448  this.setAnchor();
449  this.setPosition();
450  this.setZIndex();
451  this.setVisible();
452};
453
454/**
455 * Sets the anchor point of the label.
456 * @private
457 */
458MarkerLabel_.prototype.setAnchor = function () {
459  var anchor = this.marker_.get("labelAnchor");
460  this.labelDiv_.style.marginLeft = -anchor.x + "px";
461  this.labelDiv_.style.marginTop = -anchor.y + "px";
462  this.eventDiv_.style.marginLeft = -anchor.x + "px";
463  this.eventDiv_.style.marginTop = -anchor.y + "px";
464};
465
466/**
467 * Sets the position of the label. The z-index is also updated, if necessary.
468 * @private
469 */
470MarkerLabel_.prototype.setPosition = function () {
471  var position = this.getProjection().fromLatLngToDivPixel(this.marker_.getPosition());
472  this.labelDiv_.style.left = Math.round(position.x) + "px";
473  this.labelDiv_.style.top = Math.round(position.y) + "px";
474  this.eventDiv_.style.left = this.labelDiv_.style.left;
475  this.eventDiv_.style.top = this.labelDiv_.style.top;
476};
477
478/**
479 * Sets the z-index of the label. If the marker's z-index property has not been defined, the z-index
480 * of the label is set to the vertical coordinate of the label. This is in keeping with the default
481 * stacking order for Google Maps: markers to the south are in front of markers to the north.
482 * @private
483 */
484MarkerLabel_.prototype.setZIndex = function () {
485  var zAdjust = (this.marker_.get("labelInBackground") ? -1 : +1);
486  if (typeof this.marker_.getZIndex() === "undefined") {
487    this.labelDiv_.style.zIndex = parseInt(this.labelDiv_.style.top, 10) + zAdjust;
488    this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;
489  } else {
490    this.labelDiv_.style.zIndex = this.marker_.getZIndex() + zAdjust;
491    this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;
492  }
493};
494
495/**
496 * Sets the clickability of the label. The label is clickable only if the
497 * marker itself is clickable (i.e., its clickable property is true) or if
498 * it is draggable (i.e., its draggable property is true).
499 * @private
500 */
501MarkerLabel_.prototype.setClickable = function () {
502  this.removeMouseListeners();
503  this.eventDiv_.style.cursor = null;
504  if (this.marker_.getClickable() || this.marker_.getDraggable()) {
505    this.addMouseListeners();
506  }
507};
508
509/**
510 * Sets the cursor for the label.
511 * @private
512 */
513MarkerLabel_.prototype.setCursor = function () {
514  this.eventDiv_.style.cursor = this.marker_.getCursor();
515};
516
517/**
518 * Sets the visibility of the label. The label is visible only if the marker itself is
519 * visible (i.e., its visible property is true) and the labelVisible property is true.
520 * @private
521 */
522MarkerLabel_.prototype.setVisible = function () {
523  if (this.marker_.get("labelVisible")) {
524    this.labelDiv_.style.display = this.marker_.getVisible() ? "block" : "none";
525  } else {
526    this.labelDiv_.style.display = "none";
527  }
528  this.eventDiv_.style.display = this.labelDiv_.style.display;
529};
530
531/**
532 * @name MarkerWithLabelOptions
533 * @class This class represents the optional parameter passed to the {@link MarkerWithLabel} constructor.
534 *  The properties available are the same as for <code>google.maps.Marker</code> with the addition
535 *  of the properties listed below. To change any of these additional properties after the labeled
536 *  marker has been created, call <code>google.maps.Marker.set(propertyName, propertyValue)</code>.
537 *  <p>
538 *  When any of these properties changes, a property changed event is fired. The names of these
539 *  events are derived from the name of the property and are of the form <code>propertyname_changed</code>.
540 *  For example, if the content of the label changes, a <code>labelcontent_changed</code> event
541 *  is fired.
542 *  <p>
543 * @property {string|Node} [labelContent] The content of the label (plain text or an HTML DOM node).
544 * @property {Point} [labelAnchor] By default, a label is drawn with its anchor point at (0,0) so
545 *  that its top left corner is positioned at the anchor point of the associated marker. Use this
546 *  property to change the anchor point of the label. For example, to center a 50px-wide label
547 *  beneath a marker, specify a <code>labelAnchor</code> of <code>google.maps.Point(25, 0)</code>.
548 *  (Note: x-values increase to the right and y-values increase to the top.)
549 * @property {string} [labelClass] The name of the CSS class defining the styles for the label.
550 *  Note that style values for <code>position</code>, <code>overflow</code>, <code>top</code>,
551 *  <code>left</code>, <code>zIndex</code>, <code>display</code>, <code>marginLeft</code>, and
552 *  <code>marginTop</code> are ignored; these styles are for internal use only.
553 * @property {Object} [labelStyle] An object literal whose properties define specific CSS
554 *  style values to be applied to the label. Style values defined here override those that may
555 *  be defined in the <code>labelClass</code> style sheet. If this property is changed after the
556 *  label has been created, all previously set styles (except those defined in the style sheet)
557 *  are removed from the label before the new style values are applied.
558 *  Note that style values for <code>position</code>, <code>overflow</code>, <code>top</code>,
559 *  <code>left</code>, <code>zIndex</code>, <code>display</code>, <code>marginLeft</code>, and
560 *  <code>marginTop</code> are ignored; these styles are for internal use only.
561 * @property {boolean}
561 [labelInBackground] A flag indicating whether a label that overlaps its
562 *  associated marker should appear in the background (i.e., in a plane below the marker).
563 *  The default is <code>false</code>, which causes the label to appear in the foreground.
564 * @property {boolean} [labelVisible] A flag indicating whether the label is to be visible.
565 *  The default is <code>true</code>. Note that even if <code>labelVisible</code> is
566 *  <code>true</code>, the label will <i>not</i> be visible unless the associated marker is also
567 *  visible (i.e., unless the marker's <code>visible</code> property is <code>true</code>).
568 * @property {boolean} [crossOnDrag] A flag indicating whether a cross ("X") is to be
569 *  shown when the marker label is dragged. The default is <code>true</code>. The marker
570 *  is placed at the position of the cross when the drag ends.
571 * @property {boolean} [optimized] A flag indicating whether rendering is to be optimized
572 *  for the marker. <b>Important: The optimized rendering technique is not supported by
573 *  MarkerWithLabel, so the value of this parameter is always forced to <code>false</code>.
574 * @property {string} [crossImage="//maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png"]
575 *  The URL of the cross image to be displayed while dragging a marker.
576 */
577/**
578 * Creates a MarkerWithLabel with the options specified in {@link MarkerWithLabelOptions}.
579 * @constructor
580 * @param {MarkerWithLabelOptions} [opt_options] The optional parameters.
581 */
582class MarkerWithLabel extends google.maps.Marker {
583	constructor(opt_options) {
584		super(opt_options);
585	  	opt_options = opt_options || {};
586	  	opt_options.labelContent = opt_options.labelContent || "";
587	  	opt_options.labelAnchor = opt_options.labelAnchor || new google.maps.Point(0, 0);
588	  	opt_options.labelClass = opt_options.labelClass || "markerLabels";
589	  	opt_options.labelStyle = opt_options.labelStyle || {};
590	  	opt_options.labelInBackground = opt_options.labelInBackground || false;
591		  if (typeof opt_options.labelVisible === "undefined") {
592			opt_options.labelVisible = true;
593		  }
594		  if (typeof opt_options.crossOnDrag === "undefined") {
595			opt_options.crossOnDrag = true;
596		  }
597		  if (typeof opt_options.clickable === "undefined") {
598			opt_options.clickable = true;
599		  }
600		  if (typeof opt_options.draggable === "undefined") {
601			opt_options.draggable = false;
602		  }
603		  if (typeof opt_options.optimized === "undefined") {
604			opt_options.optimized = false;
605		  }
606		  opt_options.crossImage = opt_options.crossImage || "//maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png";
607		  opt_options.optimized = false; // Optimized rendering is not supported
608
609		  this.label = new MarkerLabel_(this, opt_options.crossImage); // Bind the label to the marker
610	}
611}
612
613/**
614 * Overrides the standard Marker setMap function.
615 * @param {Map} theMap The map to which the marker is to be added.
616 * @private
617 */
618MarkerWithLabel.prototype.setMap = function (theMap) {
619
620  // Call the inherited function...
621  google.maps.Marker.prototype.setMap.apply(this, arguments);
622
623  // ... then deal with the label:
624	if(this.label) {
625  		this.label.setMap(theMap);
626	}
627};
628
629if (typeof module == 'object') {
630  module.exports = MarkerWithLabel;
631}

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.