<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[miCiudad18: Tell us what you do and don't like about your community]]></title>
	<link>http://146.155.17.19:15080/elgg18/pypMapComment/category/49?</link>
	<atom:link href="http://146.155.17.19:15080/elgg18/pypMapComment/category/49?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<div>
    <div id='address'></div>
    <div id='runIpPos'></div>
    <div id='ipPos'></div>
    <div>
    <!--
    <input id='address' type='text' placeholder='Enter an address or click on the map to add your comment' style='width:605px'/>
    <input type='button' value='Locate' class='elgg-button elgg-button-action' style='width:100px;height:30px' onclick='codeAddress()'/>
    -->
    </div><div style='margin: 10px;'>
    <img src='http://146.155.17.19:15080/elgg18/mod/pypMapComment/graphics/like_legend_mod.png' style='height:16px; width:16px; margin-right: 5px;'/>Likes
    <img src='http://146.155.17.19:15080/elgg18/mod/pypMapComment/graphics/dislike_legend_mod.png'  style='height:16px; width:16px; margin-left: 10px; margin-right: 5px;'/>Dislikes</div></div><div id='map' style='height:600px; width:100%'>
    <script type='text/javascript' src='http://146.155.17.19:15080/elgg18/mod/pypMapComment/js/leaflet.js'></script>
    <script	type='text/javascript' src='http://146.155.17.19:15080/elgg18/mod/pypMapComment/js/leaflet.markercluster.js'></script>
    <script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false'></script>
    <link type='text/css' rel='stylesheet' href='http://146.155.17.19:15080/elgg18/mod/pypMapComment/css/leaflet.css'/>
    <link type='text/css' rel='stylesheet' href='http://146.155.17.19:15080/elgg18/mod/pypMapComment/css/MarkerCluster.css'/>
    <link type='text/css' rel='stylesheet' href='http://146.155.17.19:15080/elgg18/mod/pypMapComment/css/MarkerCluster.Default.css'/>
    <script type='text/javascript'>

    //--- sstein: declare cookie functions to be able to use cookies for the user location
    //    and avoid unnecessary www.ipinfo.io requests
    function setCookie (cookieName, cookieValue,lifespanInDays, validDomain){
        // from http://www.thesitewizard.com/javascripts/cookies.shtml
    var domain_string = validDomain ?
                       ('; domain=' + validDomain) : '' ;
                        document.cookie = cookieName +
                        '=' + encodeURIComponent( cookieValue ) +
                        '; max-age=' + 60 * 60 *24 * lifespanInDays +
                        '; path=/' + domain_string ;
    }

    function getCookie (cname){
        var name = cname + '=';
        var ca = document.cookie.split(';');
            for(var i=0; i<ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1);
                if (c.indexOf(name) != -1) return decodeURIComponent(c.substring(name.length,c.length));
            }
        return '';
    }

    //-- set the predefined user location or if already existing the location
    //   we have stored in a cookie earlies
    //   later reset the location based on the IP
    var locCookieName = 'userPosition';
    var userCookieLoc = getCookie(locCookieName);
    var ipNorthing; var ipEasting;
    var runIPLocRecognition = false;
    if(userCookieLoc !=''){
        $('#address').html(' found a cookie! pos ' + userCookieLoc);
        var locarray = userCookieLoc.split(',');
        ipNorthing = locarray[0];
        ipEasting = locarray[1];
        var runIPLocRecognition = false;
    }
    else{
        $('#address').html(' no cookie found!');
        ipNorthing = -36.80;
        ipEasting = -73.07;
        var runIPLocRecognition = true;
    };
    //$('#setcenter').html('set north: ' + ipNorthing + ' --- east: ' + ipEasting);

    //-- setup of the map
        var map;
     //-- sstein [26.Sept.2014] start - using MapQuest instead of own Tile Provider
     /*
     var grey_map = L.tileLayer('http://a.tiles.mapbox.com/v3/planyourplace.glamorgan/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href=http://osm.org/copyright>OpenStreetMap</a> contributors',
            wax: 'http://a.tiles.mapbox.com/v3/planyourplace.glamorgan.jsonp'});
     */
      /*
      var grey_map = L.tileLayer('http://tilestream.geosteiniger.cl/v2/Fondef/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href=http://osm.org/copyright>OpenStreetMap</a> contributors'});

      */
      var grey_map = L.tileLayer('http://otile3.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png', {
            attribution: '&copy; Data and map information provided by <a href=http://open.mapquest.com>MapQuest</a>, <a href=http://osm.org/copyright>OpenStreetMap</a> and contributors'});

        //var map_options = {center: [-33.46, -70.64], //values for santiago
        var map_options = {center: [ipNorthing, ipEasting],
            zoom: 12,
            minZoom:5,
            layers: [grey_map]};
        map = new L.Map('map', map_options);

        //var southWest = new L.LatLng(51, -114.187),
        //northEast = new L.LatLng(51.0345, -114.118),
        //bounds = new L.LatLngBounds(southWest, northEast);
        //map.setMaxBounds(bounds);

        //-- if there is a zoom action, then get the coords
        //   testing if I can store the map states for each user
        //   However, probably this is not possible as we cannot
        //   assign client side js variables to server side php values without sending a form

        //map.on('zoomend', function e () {
        //    console.log('ZOOMEND', e);
        //    var zoomlevel = map.getZoom();
        //    //console.log('Zoomlevel:' + zoomlevel , e);
        //    //:: = zoomlevel;
        //});
     //-- sstein [26.Sept.2014] end
        if(runIPLocRecognition == true){
            centerToIPLocation();
        }

    //var geocoder = new google.maps.Geocoder();
var stringDetails = ' Show Details ';

var dislike_overlay = show_markers({"type": "FeatureCollection", "features": [{"type": "Feature","geometry": {"type": "Point", "coordinates":[-73.03985595703124,-36.82192795249873]}, "properties": {"url": "http://146.155.17.19:15080/elgg18/pypMapComment/category/44", "icon": "http://146.155.17.19:15080/elgg18/mod/pypMapComment/graphics/dislike_legend_mod.png", "title": "blob 2",}}]}, 'dislike');
map.addLayer(dislike_overlay);

var like_overlay = show_markers({"type": "FeatureCollection", "features": [{"type": "Feature","geometry": {"type": "Point", "coordinates":[-70.61390519142151,-33.500053275670105]}, "properties": {"url": "http://146.155.17.19:15080/elgg18/pypMapComment/category/49", "icon": "http://146.155.17.19:15080/elgg18/mod/pypMapComment/graphics/like_legend_mod.png", "title": "How to get to Dpto. Transporte",}},{"type": "Feature","geometry": {"type": "Point", "coordinates":[-70.63436508178711,-33.43695664170687]}, "properties": {"url": "http://146.155.17.19:15080/elgg18/pypMapComment/category/46", "icon": "http://146.155.17.19:15080/elgg18/mod/pypMapComment/graphics/like_legend_mod.png", "title": "nice picture from 19xx",}},{"type": "Feature","geometry": {"type": "Point", "coordinates":[-73.14834594726562,-36.78179217131925]}, "properties": {"url": "http://146.155.17.19:15080/elgg18/pypMapComment/category/42", "icon": "http://146.155.17.19:15080/elgg18/mod/pypMapComment/graphics/like_legend_mod.png", "title": "blob 1",}}]}, 'like');
map.addLayer(like_overlay);

function show_markers(_data, _type) {
    var _markers = new L.MarkerClusterGroup({iconCreateFunction: function (cluster) {
                var childCount = cluster.getChildCount();
                var c = ' marker-cluster-'+_type;
                return new L.DivIcon({ html: '<div><span>' + childCount + '</span></div>', className: 'marker-cluster' + c, iconSize: new L.Point(40, 40)});
                },
                showCoverageOnHover: false});
    var geoJsonLayer = L.geoJson(_data,
    {
        onEachFeature: function (feature, layer) {
            setGeoJsonFeatureIcon(feature, layer);
            //sstein: adding popup with link to item
            layer.bindPopup(feature.properties.title + '<br/><a href=' + feature.properties.url + '>' + stringDetails + '</a>');
        }
    }
    );
    _markers.addLayer(geoJsonLayer);
    return _markers;
}

//-- sstein [26.Sept.2014] : added popup function
var popupComment = L.popup();

function onMapClickS (e) {
        popupComment.setLatLng(e.latlng).openOn(map);
    }
//-- sstein : end

function setGeoJsonFeatureIcon(feature, layer) {
    if (feature.properties && feature.properties.icon) {
        layer.setIcon(new L.Icon({
            iconUrl: feature.properties.icon,
            iconSize: [21, 21],
            iconAnchor: [10, 10], // point of the icon which will correspond to marker's location
            popupAnchor: [0, 0] // point from which the popup should open relative to the iconAnchor
        }));
    }
    //-- sstein [26.Sept.2014]: don't call direct issue display but open a popup instead
    //layer.on('click', function(){window.location = feature.properties.url;});
    layer.on('click', onMapClickS)
}

function codeAddress() {
    var address = document.getElementById('address').value;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {

        map.panTo([results[0].geometry.location.lat(),results[0].geometry.location.lng()]);
        map.setZoom(16);

      } else {
        $('#result').html('Geocode was not successful for the following reason: ' + status);
      }
    });
}

function centerToIPLocation(){
    $.get('http://ipinfo.io', function getUserLocation(ipinfo) {
        var ip_loc = ipinfo.loc;
        if(ip_loc != ''){
            $('#runIpPos').html('running user IP and position retrieval');
            var locarray = ipinfo.loc.split(',');
            ipNorthing = locarray[0];
            ipEasting = locarray[1];
            $('#ipPos').html('ip: ' + ipinfo.ip + ' ip region: ' + ipinfo.region + ' --- received north: ' + ipNorthing + ' --- east: ' + ipEasting);
            map.panTo(new L.LatLng(ipNorthing,ipEasting));
            //write a cookie for re-use
            setCookie(locCookieName, ip_loc, 90 );
        }
        else{
            ipNorthing = -36.80;
            ipEasting = -73.07;
        }
    }, 'jsonp');
}

    map.panTo(new L.LatLng(-33.500053275670105,-70.61390519142151));
    map.setZoom(18);
    
    </script>
</div>
</channel>
</rss>