code: def heatmap_layer(
      locations,
      weights=None,
      max_intensity=None,
      dissipating=True,
      point_radius=None,
      opacity=0.6,
      gradient=None,
  ):
      """
      Create a heatmap layer.
  
      This returns a :class:`gmaps.Heatmap` or a :class:`gmaps.WeightedHeatmap`
      object that can be added to a :class:`gmaps.Figure` to draw a
      heatmap. A heatmap shows the density of points in or near
      a particular area.
  
      To set the parameters, pass them to the constructor or set
      them on the ``Heatmap`` object after construction::
  
      >>> heatmap = gmaps.heatmap_layer(locations, max_intensity=10)
  
      or::
  
      >>> heatmap = gmaps.heatmap_layer(locations)
      >>> heatmap.max_intensity = 10
  
      :Examples:
  
      >>> fig = gmaps.figure()
      >>> locations = [(46.1, 5.2), (46.2, 5.3), (46.3, 5.4)]
      >>> heatmap = gmaps.heatmap_layer(locations)
      >>> heatmap.max_intensity = 2
      >>> heatmap.point_radius = 3
      >>> heatmap.gradient = ['white', 'gray']
      >>> fig.add_layer(heatmap)
  
      {locations}
  
      :param weights:
          Iterable of weights of the same length as `locations`.
          All the weights must be positive.
      :type weights: iterable of floats, optional
  
      {options}
  
      :returns:
          A :class:`gmaps.Heatmap` or a :class:`gmaps.WeightedHeatmap` widget.
      """
      widget_args, is_weighted = _heatmap_options(
          locations,
          weights,
          max_intensity,
          dissipating,
          point_radius,
          opacity,
          gradient,
      )
      if is_weighted:
          return WeightedHeatmap(**widget_args)
      else:
          return Heatmap(**widget_args)
  
imports: import ipywidgets
  from traitlets import Float, Bool, Unicode, HasTraits, default, List, observe
  from .None import bounds
  from .locations import locations_docstring
  from .None import geotraitlets
  from .maps import GMapsWidgetMixin
  from ._docutils import doc_subst
label_desc: Use image node_id 2 for calling a global function with example usage: heatmap_layer(locations, weights, max_intensity, dissipating, point_radius, opacity, gradient) and returns: WeightedHeatmap, Heatmap