 React = require 'react'
 {div, p, a, button, span, input, label, h1} = React.DOM
 L = global.L or require('leaflet')
+backend = require './backend.coffee'
 # require 'leaflet/dist/leaflet.css'
 L.Icon.Default.imagePath = '/styles/images'
 
 
 
 map = L.map 'map',
-    center: [38, 0]
-    zoom: 3
+    center: [13, -37]
+    zoom: 2
     doubleClickZoom: false
 
-# coffeelint: disable=max_line_length
 OpenStreetMap_France =
   L.tileLayer('http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png',
   maxZoom: 19
-  attribution: '&copy; Openstreetmap France | &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>')
-# coffeelint: enable=max_line_length
-
+  attribution:
+      '&copy;
+      Openstreetmap France | &copy;
+      <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>')
 
 Layers = OpenStreetMap_France
 .addTo map
 
-markerPosition = [42, 0]
-popupContent = 'Are you a Mapper?'
 
-MarkerDefault = L.marker markerPosition
-.addTo map
-.bindPopup popupContent
-.openPopup map
 
+configIcon = L.icon(
+    iconUrl: '/styles/images/homemarker.png'
+    shadowUrl: '/styles/images/marker-shadow.png'
+    iconSize: [25, 41]
+    iconAnchor: [12, 41]
+    popupAnchor: [1, -34]
+    shadowSize: [41, 41])
 
 redIcon = L.icon(
     iconUrl: '/styles/images/marker2-icon.png'

            opacity: '0.65'
        marker.addTo map
# Module PeaceMarker end

    shadowSize: [41, 41])



# Module HomeConfig
markerPosition = [13, -37]

configmarker = L.marker markerPosition,
    icon: configIcon
    draggable:'true'
    opacity: '0.98'
configmarker.addTo map

onSvClicked: ->
    lat = @refs.latInput.getDOMNode().value
    lng = @refs.lngInput.getDOMNode().value
    zoom = @refs.zoomInput.getDOMNode().value

    homedata =
        id: @props.homedata.id
        lat: lat
        lng: lng
        zoom: zoom

    backend.putConfigid homedata, ->
        console.log "data saved"

configmarker.on 'dragend', (event) ->
    configmarker = event.target
    configmarkerzoom = map.getZoom()
    configposition = configmarker.getLatLng()

    popupContent = (
        'Set this place as the "Home" view!' + '<br>' +
        'Or... drag me where you want to!' + '<br>' +
        'Check your preferences to show me or not!' + '<br>' +
        '<br>' +

        '[Lat; Lng](zoom) = [' +
        configposition.lat.toFixed(4) + '; ' +
        configposition.lng.toFixed(4) + '](' +
        configmarkerzoom + ')' + '<br>' +

        '<input type="hidden" ref="latInput" value="configposition.lat">' +
        '<input type="hidden" ref="lngInput" value="configposition.lng">' +
        '<input type="hidden" ref="zoomInput" value="configmarkerzoom">' +
        '<input type="submit" value="save it!" onClick="onSvClicked">'
    )
    configmarker.setLatLng new L.LatLng(configposition.lat, configposition.lng),
        draggable: 'true'
    configmarker.bindPopup(popupContent)
# End Module HomeConfig



# Module PeaceMarker
map.on 'dblclick', (event) ->

    marker = new L.marker event.latlng,
