   qq.maps.event.addListener map, "zoom_changed", mapListener
   qq.maps.event.addListener map, "click", (e) ->
     marker.setPosition e.latLng
-)
 
 # function loadScript() {
 #   var script = document.createElement("script");

# }

mapListener = (e) ->
  map = e.target;
  pixel = e.pixel;
  lat = e.latLng;
  # TODO send backend ,map scope
  # $.ajax({
    # url: "",
      # data: map.getBounds(),
  # })
  # .done(function (data) {
    # call the fillPOIs
  # })
  # .fail(function (data) {
  # });
  fillPOI {}, map

fillPOI = (data, map) ->
  # data = [{id , mood, location{lat,lon}}, ...]
  # TODO for each data
  circle = new qq.maps.Circle
    center: map.getCenter()
    visible: true
    radius: 50
    strokeWeight: 4
    fillColor: "#00f"
    map: map
  qq.maps.event.addListener circle, 'click', (e) ->
    info = map.window
    info.setPosition e.latLng
    info.setContent "My location is " + e.latLng
    info.open()

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
jQuery ->
  # make dianping position defalut
  # dpLatlng = new qq.maps.LatLng 31.215240, 121.420290
  currentPosition = new qq.maps.LatLng 31.215240, 121.420290
