/* global google */

var React = require('react')
var blacklist = require('blacklist')

module.exports = React.createClass({
  componentWillUnmount: function () {
    if (!this.marker) return

    this.marker.setMap(null)
  },

  render: function () {
    var options = this.props
    if (!options.map) return null

    // avoid map reset
    if (options.map === this.map) {
      options = blacklist(options, 'map')
    }

    // new
    if (!this.marker) {
      this.marker = new google.maps.Marker(options)
      this.map = options.map

    // existing
    } else {
      this.marker.setOptions(options)
    }

    return null
  }
})

module.exports.Animation = google.maps.Animation

@@ -320,13 +320,24 @@
  // 
-avoid
+stop superfluous
  map
@@ -420,16 +420,59 @@
 , 'map')
+%0A%0A    %7D else %7B%0A      this.map = options.map
 %0A    %7D%0A%0A
@@ -561,37 +561,8 @@
 ons)
-%0A      this.map = options.map
 %0A%0A  

allow map changes