Example usage for com.google.gwt.maps.client.layers KmlLayer newInstance

List of usage examples for com.google.gwt.maps.client.layers KmlLayer newInstance

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.layers KmlLayer newInstance.

Prototype

public final static KmlLayer newInstance(String url, KmlLayerOptions options) 

Source Link

Document

Creates a KmlLayer which renders the contents of the specified KML/KMZ file (<a href="https://developers.google.com/kml/documentation/kmlreference">KML API Doc</a>) or GeoRSS file (<a href="http://www.georss.org">GeoRSS API Doc</a>).

Usage

From source file:org.wannatrak.client.MapController.java

License:Apache License

public void showSubjects(Set<Long> subjects, String fromDaysAgo, String fromHour, String fromMinute,
        String toDaysAgo, String toHour, String toMinute, boolean showErrors, boolean updateOnlyNew) {
    final Set<Long> subjectsToShow;

    if (updateOnlyNew) {
        subjectsToShow = new HashSet<Long>(subjects);

        for (Iterator<Long> it = layers.keySet().iterator(); it.hasNext();) {
            Long subjectId = it.next();
            if (!subjects.contains(subjectId)) {
                layers.get(subjectId).setMap(null);
                it.remove();/* w w w .  ja va  2 s.  c o m*/
            }
        }
    } else {
        subjectsToShow = subjects;
    }

    for (final Long subjectId : subjectsToShow) {
        mediator.showSublectLoading(subjectId);

        String url = "http://" + Window.Location.getHost() + "/show?subjectId=" + subjectId + "&sessionId="
                + Cookies.getCookie("JSESSIONID") + "&hfrom=" + fromHour + "&mfrom=" + fromMinute + "&dfrom="
                + fromDaysAgo + "&hto=" + toHour + "&mto=" + toMinute + "&dto=" + toDaysAgo + "&valid="
                + !showErrors + "&format="
                + DateTimeFormat.getMediumDateTimeFormat().getPattern().replaceAll(" ", "_SPACE_")
                + "&tzoffset=" + new Date().getTimezoneOffset() + "&nocache=" + Random.nextInt();
        options.setPreserveViewport(!updateOnlyNew);
        KmlLayer route = KmlLayer.newInstance(url, options);
        route.setMap(mapWidget);

        layers.put(subjectId, route);
        mediator.hideSubjectLoading(subjectId);
    }
}