{"version":3,"sources":["maplabel.js"],"names":["MapLabel","opt_options","set","setValues","prototype","google","maps","OverlayView","window","changed","prop","drawCanvas_","draw","canvas","canvas_","style","zIndex","get","ctx","getContext","clearRect","width","height","strokeStyle","fillStyle","font","strokeWeight","Number","text","lineWidth","strokeText","fillText","textMeasure","textWidth","measureText","marginLeft","getMarginLeft_","marginTop","onAdd","document","createElement","position","lineJoin","textBaseline","panes","getPanes","mapPane","appendChild","projection","getProjection","latLng","pos","fromLatLngToDivPixel","y","x","getVisible_","minZoom","maxZoom","undefined","map","getMap","mapZoom","getZoom","onRemove","parentNode","removeChild"],"mappings":";AA+BA,SAASA,EAASC,GACXC,KAAAA,IAAI,aAAc,cAClBA,KAAAA,IAAI,WAAY,IAChBA,KAAAA,IAAI,YAAa,WACjBA,KAAAA,IAAI,eAAgB,GACpBA,KAAAA,IAAI,cAAe,WACnBA,KAAAA,IAAI,QAAS,UAEbA,KAAAA,IAAI,SAAU,KAEdC,KAAAA,UAAUF,GAEjBD,EAASI,UAAY,IAAIC,OAAOC,KAAKC,YAErCC,OAAA,SAAqBR,EAIrBA,EAASI,UAAUK,QAAU,SAASC,GAC5BA,OAAAA,GACD,IAAA,aACA,IAAA,WACA,IAAA,YACA,IAAA,eACA,IAAA,cACA,IAAA,QACA,IAAA,OACI,OAAA,KAAKC,cACT,IAAA,UACA,IAAA,UACA,IAAA,WACI,OAAA,KAAKC,SAQlBZ,EAASI,UAAUO,YAAc,WAC3BE,IAAAA,EAAS,KAAKC,QACd,GAACD,EAAD,CAEAE,IAAAA,EAAQF,EAAOE,MACbC,EAAAA,OAA6B,KAAKC,IAAI,UAExCC,IAAAA,EAAML,EAAOM,WAAW,MACxBC,EAAAA,UAAU,EAAG,EAAGP,EAAOQ,MAAOR,EAAOS,QACrCC,EAAAA,YAAc,KAAKN,IAAI,eACvBO,EAAAA,UAAY,KAAKP,IAAI,aACrBQ,EAAAA,KAAO,KAAKR,IAAI,YAAc,MAAQ,KAAKA,IAAI,cAE/C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D,EACpB,MAAA,GAGLE,IAAAA,EAAM,KAAKC,SACX,IAACD,EACI,MAAA,GAGLE,IAAAA,EAAUF,EAAIG,UACdD,OAAAA,EAAUL,GAAWK,EAAUJ,EAC1B,SAEF,IAMTzD,EAASI,UAAU2D,SAAW,WACxBlD,IAAAA,EAAS,KAAKC,QACdD,GAAUA,EAAOmD,YACZA,EAAAA,WAAWC,YAAYpD,IAGlCb,EAASI,UAAT,SAAiCJ,EAASI,UAAU2D","file":"maplabel.c4d77c3f.map","sourceRoot":"..","sourcesContent":["/**\n * @license\n *\n * Copyright 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Map Label.\n *\n * @author Luke Mahe (lukem@google.com),\n *         Chris Broadfoot (cbro@google.com)\n */\n\n/**\n * Creates a new Map Label\n * @constructor\n * @extends google.maps.OverlayView\n * @param {Object.<string, *>=} opt_options Optional properties to set.\n */\nfunction MapLabel(opt_options) {\n  this.set('fontFamily', 'sans-serif');\n  this.set('fontSize', 12);\n  this.set('fontColor', '#000000');\n  this.set('strokeWeight', 4);\n  this.set('strokeColor', '#ffffff');\n  this.set('align', 'center');\n\n  this.set('zIndex', 1e3);\n\n  this.setValues(opt_options);\n}\nMapLabel.prototype = new google.maps.OverlayView;\n\nwindow['MapLabel'] = MapLabel;\n\n\n/** @inheritDoc */\nMapLabel.prototype.changed = function(prop) {\n  switch (prop) {\n    case 'fontFamily':\n    case 'fontSize':\n    case 'fontColor':\n    case 'strokeWeight':\n    case 'strokeColor':\n    case 'align':\n    case 'text':\n      return this.drawCanvas_();\n    case 'maxZoom':\n    case 'minZoom':\n    case 'position':\n      return this.draw();\n  }\n};\n\n/**\n * Draws the label to the canvas 2d context.\n * @private\n */\nMapLabel.prototype.drawCanvas_ = function() {\n  var canvas = this.canvas_;\n  if (!canvas) return;\n\n  var style = canvas.style;\n  style.zIndex = /** @type number */(this.get('zIndex'));\n\n  var ctx = canvas.getContext('2d');\n  ctx.clearRect(0, 0, canvas.width, canvas.height);\n  ctx.strokeStyle = this.get('strokeColor');\n  ctx.fillStyle = this.get('fontColor');\n  ctx.font = this.get('fontSize') + 'px ' + this.get('fontFamily');\n\n  var strokeWeight = Number(this.get('strokeWeight'));\n\n  var text = this.get('text');\n  if (text) {\n    if (strokeWeight) {\n      ctx.lineWidth = strokeWeight;\n      ctx.strokeText(text, strokeWeight, strokeWeight);\n    }\n\n    ctx.fillText(text, strokeWeight, strokeWeight);\n\n    var textMeasure = ctx.measureText(text);\n    var textWidth = textMeasure.width + strokeWeight;\n    style.marginLeft = this.getMarginLeft_(textWidth) + 'px';\n    // Bring actual text top in line with desired latitude.\n    // Cheaper than calculating height of text.\n    style.marginTop = '-0.4em';\n  }\n};\n\n/**\n * @inheritDoc\n */\nMapLabel.prototype.onAdd = function() {\n  var canvas = this.canvas_ = document.createElement('canvas');\n  var style = canvas.style;\n  style.position = 'absolute';\n\n  var ctx = canvas.getContext('2d');\n  ctx.lineJoin = 'round';\n  ctx.textBaseline = 'top';\n\n  this.drawCanvas_();\n\n  var panes = this.getPanes();\n  if (panes) {\n    panes.mapPane.appendChild(canvas);\n  }\n};\nMapLabel.prototype['onAdd'] = MapLabel.prototype.onAdd;\n\n/**\n * Gets the appropriate margin-left for the canvas.\n * @private\n * @param {number} textWidth  the width of the text, in pixels.\n * @return {number} the margin-left, in pixels.\n */\nMapLabel.prototype.getMarginLeft_ = function(textWidth) {\n  switch (this.get('align')) {\n    case 'left':\n      return 0;\n    case 'right':\n      return -textWidth;\n  }\n  return textWidth / -2;\n};\n\n/**\n * @inheritDoc\n */\nMapLabel.prototype.draw = function() {\n  var projection = this.getProjection();\n\n  if (!projection) {\n    // The map projection is not ready yet so do nothing\n    return;\n  }\n\n  if (!this.canvas_) {\n    // onAdd has not been called yet.\n    return;\n  }\n\n  var latLng = /** @type {google.maps.LatLng} */ (this.get('position'));\n  if (!latLng) {\n    return;\n  }\n  var pos = projection.fromLatLngToDivPixel(latLng);\n\n  var style = this.canvas_.style;\n\n  style['top'] = pos.y + 'px';\n  style['left'] = pos.x + 'px';\n\n  style['visibility'] = this.getVisible_();\n};\nMapLabel.prototype['draw'] = MapLabel.prototype.draw;\n\n/**\n * Get the visibility of the label.\n * @private\n * @return {string} blank string if visible, 'hidden' if invisible.\n */\nMapLabel.prototype.getVisible_ = function() {\n  var minZoom = /** @type number */(this.get('minZoom'));\n  var maxZoom = /** @type number */(this.get('maxZoom'));\n\n  if (minZoom === undefined && maxZoom === undefined) {\n    return '';\n  }\n\n  var map = this.getMap();\n  if (!map) {\n    return '';\n  }\n\n  var mapZoom = map.getZoom();\n  if (mapZoom < minZoom || mapZoom > maxZoom) {\n    return 'hidden';\n  }\n  return '';\n};\n\n/**\n * @inheritDoc\n */\nMapLabel.prototype.onRemove = function() {\n  var canvas = this.canvas_;\n  if (canvas && canvas.parentNode) {\n    canvas.parentNode.removeChild(canvas);\n  }\n};\nMapLabel.prototype['onRemove'] = MapLabel.prototype.onRemove;\n"]}