Example usage for com.google.gwt.maps.client.base LatLngBounds newInstance

List of usage examples for com.google.gwt.maps.client.base LatLngBounds newInstance

Introduction

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

Prototype

public final static LatLngBounds newInstance(LatLng sw, LatLng ne) 

Source Link

Document

creates A LatLngBounds instance represents a rectangle in geographical coordinates, including one that crosses the 180 degrees longitudinal meridian.

Usage

From source file:com.google.gwt.maps.testing.client.maps.OverlayViewMapWidget.java

License:Apache License

private void drawOverlay_GroundOverlay() {
    String url = "http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg";
    LatLng sw = LatLng.newInstance(40.716216, -74.213393);
    LatLng ne = LatLng.newInstance(40.765641, -74.139235);
    LatLngBounds bounds = LatLngBounds.newInstance(sw, ne);
    GroundOverlayOptions options = GroundOverlayOptions.newInstance();

    groundOverlay = GroundOverlay.newInstance(url, bounds, options);
    groundOverlay.setMap(mapWidget);/*w  w  w  .j a v  a 2 s  .  com*/
}

From source file:com.google.sampling.experiential.client.ChartPanel.java

License:Open Source License

private Widget renderEventsOnMap() {
    markers.clear();/* w  ww.ja  v  a  2  s  . co  m*/
    createMap();
    final LatLngBounds bounds = LatLngBounds.newInstance(google, google);
    for (final EventDAO event : data) {
        String latLon = event.getWhatByKey(input.getName());
        if (latLon == null || latLon.length() == 0) {
            continue;
        }
        String[] splits = latLon.split(",");
        if (splits == null || splits.length != 2) {
            continue;
        }
        try {
            double latitude = Double.parseDouble(splits[0]);
            double longitude = Double.parseDouble(splits[1]);

            MarkerOptions markerOptions = MarkerOptions.newInstance();
            markerOptions.setMap(map);
            markerOptions.setTitle(event.getWhatString());
            LatLng newInstance = LatLng.newInstance(latitude, longitude);
            final Marker marker = Marker.newInstance(markerOptions);
            marker.setPosition(newInstance);
            bounds.union(LatLngBounds.newInstance(marker.getPosition(), marker.getPosition()));
            marker.addClickHandler(new ClickMapHandler() {
                @Override
                public void onEvent(ClickMapEvent mapEvent) {
                    openInfoWindowForMarker(event, marker);
                }
            });
            markers.put(event, marker);
        } catch (NumberFormatException nfe) {
        }
    }

    map.fitBounds(bounds);

    final LatLng oldCenter = map.getCenter();
    final int oldZoom = map.getZoom();
    map.addResizeHandler(new ResizeMapHandler() {

        @Override
        public void onEvent(ResizeMapEvent event) {
            map.setCenter(oldCenter);
            map.setZoom(oldZoom);
            map.fitBounds(bounds);
        }
    });
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            MapHandlerRegistration.trigger(map, MapEventType.RESIZE);
            GWT.log("Window has been resized!");
        }
    });
    return map;
}

From source file:com.jettmarks.routes.client.bean.Route.java

License:Apache License

/**
 * Takes several parameters from an EncodedTrack to create a Route:
 * <UL>/*  ww  w  .  j a  va 2 s.  c  o  m*/
 * <LI>Name
 * <LI>Distance
 * <LI>The encoded points that can generate a Polyline
 * </UL>
 * 
 * From the list above, this creates:
 * <UL>
 * <LI>polyline - in the default color & width
 * <LI>selectedPolyline - in the default selected color and width
 * <LI>the bounds of this route
 * <LI>highlightedPolyline - something to show up better on a mouse-over.
 * <UL>
 * 
 * @param encodedTrack
 */
public void setEncodedTrack(EncodedTrack encTrk) {
    this.encodedTrack = encTrk;
    this.name = encodedTrack.getRouteName();
    this.distance = encodedTrack.getDistance();
    setFacilityType(encodedTrack.getFacilityType());
    this.displayName = encodedTrack.getDisplayName();
    this.extSourceURL = encodedTrack.getSourceUrl();

    // int zoomFactor = 2;
    // int numLevels = 18;

    // polyline = Polyline.fromEncoded(
    // encodedTrack.getEncodedPoints(),
    // zoomFactor,
    // encodedTrack.getEncodedLevels(),
    // numLevels);

    polyline = Polyline.newInstance(unselectedStyleOptions);
    highlightedPolyline = Polyline.newInstance(highlightedStyleOptions);

    // polyline.setPath(EncodingUtils.decodePath(encodedTrack.getEncodedPoints()));
    @SuppressWarnings("unchecked")
    JsArray<LatLng> path = (JsArray<LatLng>) JsArray.createArray();
    double[] lats = encTrk.getLats();
    double[] lons = encTrk.getLons();
    for (int i = 0; i < lats.length; i++) {
        LatLng point = LatLng.newInstance(lats[i], lons[i]);
        path.set(i, point);
    }
    polyline.setPath(path);
    highlightedPolyline.setPath(path);

    // if (facilityType == FacilityType.SEGREGATED)
    // polyline.setStrokeStyle(segregatedStyleOptions);
    // else if (facilityType == FacilityType.BIKE_ROUTE)
    // polyline.setStrokeStyle(bikeLaneStyleOptions);
    // else if (facilityType == FacilityType.BIKE_LANE)
    // polyline.setStrokeStyle(bikeRouteStyleOptions);
    // else
    // polyline.setStrokeStyle(unselectedStyleOptions);
    //
    // selectedPolyline = Polyline.fromEncoded(
    // encodedTrack.getEncodedPoints(),
    // zoomFactor,
    // encodedTrack.getEncodedLevels(),
    // numLevels);
    // selectedPolyline.setStrokeStyle(selectedStyleOptions);
    //
    // highlightedPolyline = Polyline.fromEncoded(
    // encodedTrack.getEncodedPoints(),
    // zoomFactor,
    // encodedTrack.getEncodedLevels(),
    // numLevels);
    // highlightedPolyline.setStrokeStyle(highlightedStyleOptions);

    LatLng ne = LatLng.newInstance(encodedTrack.getMaxLat(), encodedTrack.getMaxLon());
    LatLng sw = LatLng.newInstance(encodedTrack.getMinLat(), encodedTrack.getMinLon());

    if (bounds == null) {
        bounds = LatLngBounds.newInstance(sw, ne);
    } else {
        bounds.extend(ne);
        bounds.extend(sw);
    }

}

From source file:gov.nist.spectrumbrowser.client.SelectBySys2DetectCommand.java

License:Open Source License

@Override
public void execute() {

    int counter = 0;
    LatLngBounds bounds = null;/*from w ww.  ja  v  a2s  .  co m*/
    for (SensorInfoDisplay marker : spectrumBrowserShowDatasets.getSensorMarkers()) {
        if (sys2Detect == null || marker.containsSys2Detect(sys2Detect)) {
            counter++;
            if (bounds == null) {
                bounds = LatLngBounds.newInstance(marker.getLatLng(), marker.getLatLng());
            }
            bounds.extend(marker.getLatLng());
        }
    }

    if (counter != 0) {
        SpectrumBrowserShowDatasets.clearSelectedSensor();
        SensorGroupMarker.clearAllSelected();
        map.fitBounds(bounds);
        SensorGroupMarker.showMarkers();
        spectrumBrowserShowDatasets.showHelp();
    }

}

From source file:gov.nist.spectrumbrowser.client.SelectFreqCommand.java

License:Open Source License

@Override
public void execute() {
    int counter = 0;
    LatLngBounds bounds = null;//from  w ww  .  j  ava2s.  c om
    for (SensorInfoDisplay marker : spectrumBrowserShowDatasets.getSensorMarkers()) {
        // 0 and 0 indicates no freq selection has been done.
        if (freqRange.minFreq == 0 && freqRange.maxFreq == 0) {
            if (bounds == null) {
                bounds = LatLngBounds.newInstance(marker.getLatLng(), marker.getLatLng());
            }
            bounds.extend(marker.getLatLng());
            counter++;
        } else if (marker.getFreqRanges().contains(this.freqRange)) {
            if (bounds == null) {
                bounds = LatLngBounds.newInstance(marker.getLatLng(), marker.getLatLng());
            }
            bounds.extend(marker.getLatLng());
            counter++;
        }
    }
    logger.finer("SelectFreqCommand:    Found " + counter + " markers");
    if (counter != 0) {
        SpectrumBrowserShowDatasets.clearSelectedSensor();
        SensorGroupMarker.clearAllSelected();
        map.fitBounds(bounds);
        SensorGroupMarker.showMarkers();
        spectrumBrowserShowDatasets.showHelp();
    }

}

From source file:gov.nist.spectrumbrowser.client.SpectrumBrowserShowDatasets.java

License:Open Source License

public void showMarkers() {
    if (getSensorMarkers().size() != 0) {
        LatLngBounds bounds = null;//from w  w w  .j  a v a 2  s. c o m

        for (SensorInfoDisplay marker : getSensorMarkers()) {
            if (bounds == null) {
                bounds = LatLngBounds.newInstance(marker.getLatLng(), marker.getLatLng());
            } else {

                bounds.extend(marker.getLatLng());
            }
        }
        LatLng center = bounds.getCenter();
        getMap().setCenter(center);
        getMap().fitBounds(bounds);

        //populateMenuItems();
        SensorGroupMarker.showMarkers();

    }

    if (getSelectedSensor() != null) {
        SensorGroupMarker.setSelectedSensor(getSelectedSensor());
    }
}

From source file:net.cbtltd.client.form.SearchForm.java

private void setMarkers(ArrayList<AvailableItem> items) {
    mapField.clear();//  ww  w . j  a va 2 s .  com
    if (items != null && !items.isEmpty()) {
        LatLngBounds bounds = LatLngBounds.newInstance(LatLng.newInstance(0.0, 0.0),
                LatLng.newInstance(0.0, 0.0));
        for (AvailableItem item : items) {
            if (item.hasLatLng()) {
                mapField.addMarker(item.getLatLng(), item.getProductname());
                bounds.extend(item.getLatLng());
            }
        }
        //TODO:         mapField.setValue(bounds.getCenter());
    }
    setZoomLevel();
}