<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<meta charset="UTF-8">
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<style type="text/css">
    #map_canvas {
        height: 400px;
        width: 800px;
        border: 1px solid #333;
        margin-top: 30px;;
        margin-left: 50px;
        float: left;
    }
</style>
<script type="text/javascript">

    var geocoder;
    var map;
    function initialize() {
        geocoder = new google.maps.Geocoder();
        var myOptions = {
            zoom: 7,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            center: new google.maps.LatLng(40.00, 44.8414)
        }
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    <s:iterator var="subscriber" value="subscribers">
        codeAddress("<s:property value="#subscriber.address"/>", "<s:property value="#subscriber.name"/>" + "  " + "<s:property value="#subscriber.surname"/>" + "</br> " + "<s:property value="#subscriber.address"/>");
    </s:iterator>
    }
    var infowindow = new google.maps.InfoWindow({
    });
    var image = "images/topology/cpe.png"

    function codeAddress(address, info) {
        geocoder.geocode({ 'address': address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {

                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location,
                    icon: image
                });
                google.maps.event.addListener(marker, 'click', function() {
                    infowindow.setContent(info);
                    infowindow.open(map, this);
                });
            } else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });
    }
    google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="map_canvas"></div>
