java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/Detail.java
author František Kučera <franta-hg@frantovo.cz>
Sat Jan 15 01:24:00 2011 +0100 (2011-01-15)
changeset 172 f0852ef58889
parent 145 0efefbf5f8b6
permissions -rw-r--r--
Označení místa na mapě.
     1 package cz.frantovo.nekurak.web;
     2 
     3 import cz.frantovo.nekurak.dto.Podnik;
     4 import java.io.UnsupportedEncodingException;
     5 import java.net.URLEncoder;
     6 
     7 /**
     8  *
     9  * @author fiki
    10  */
    11 public class Detail {
    12 
    13 	private HledacSluzby hledac = new HledacSluzby();
    14 	private int id;
    15 	private Podnik podnik;
    16 
    17 	/**
    18 	 * @return URL mapy – obrázku nebo null při chybě nebo absenci souřadnic
    19 	 */
    20 	public String getMapa() {
    21 		Podnik p = getPodnik();
    22 
    23 		if (p == null || p.getSirka() == null || p.getDelka() == null) {
    24 			return null;
    25 		} else {
    26 			try {
    27 				String souradnice = URLEncoder.encode(p.getSirka() + ", " + p.getDelka(), "UTF-8");
    28 				return "http://maps.google.com/maps/api/staticmap?size=400x400&sensor=false&markers=size:big|color:green|" + souradnice;
    29 			} catch (UnsupportedEncodingException e) {
    30 				return null;
    31 			}
    32 		}
    33 	}
    34 
    35 	public int getId() {
    36 		return id;
    37 	}
    38 
    39 	public void setId(int id) {
    40 		this.id = id;
    41 	}
    42 
    43 	public Podnik getPodnik() {
    44 		if (podnik == null) {
    45 			podnik = hledac.getPodnikEJB().getPodnik(id);
    46 		}
    47 		return podnik;
    48 	}
    49 }