Example usage for com.google.gwt.maps.client.overlays MarkerOptions newInstance

List of usage examples for com.google.gwt.maps.client.overlays MarkerOptions newInstance

Introduction

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

Prototype

public final static MarkerOptions newInstance() 

Source Link

Document

create Marker Options

Usage

From source file:com.arcbees.website.client.application.contact.ContactView.java

License:Apache License

private void onMapsLoaded() {
    // -- HOW TO STYLE A GOOGLE MAP
    // -> First, we create the style. To help : http://software.stadtwerk.org/google_maps_colorizr/
    MapTypeStyle style1 = MapTypeStyle.newInstance();
    style1.setElementType(MapTypeStyleElementType.GEOMETRY);
    style1.setFeatureType(MapTypeStyleFeatureType.ROAD);
    style1.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#FFF"),
            MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(100) });

    MapTypeStyle style2 = MapTypeStyle.newInstance();
    style2.setElementType(MapTypeStyleElementType.ALL);
    style2.setFeatureType(MapTypeStyleFeatureType.LANDSCAPE);
    style2.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#cccccc"),
            MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(-10) });

    MapTypeStyle style3 = MapTypeStyle.newInstance();
    style3.setElementType(MapTypeStyleElementType.ALL);
    style3.setFeatureType(MapTypeStyleFeatureType.POI);
    style3.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#f00"),
            MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(9), });

    MapTypeStyle style4 = MapTypeStyle.newInstance();
    style4.setElementType(MapTypeStyleElementType.ALL);
    style4.setFeatureType(MapTypeStyleFeatureType.WATER);
    style4.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#1c1c1c"),
            MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(86), });

    MapTypeStyle[] array = { style1, style2, style3, style4 };

    JsArray<MapTypeStyle> styles = ArrayHelper.toJsArray(array);

    // -> Then we tell the map to use our new style by default
    MapTypeControlOptions controlOptions = MapTypeControlOptions.newInstance();
    controlOptions.setMapTypeIds(new String[] {});
    controlOptions.setPosition(ControlPosition.TOP_RIGHT);

    // -> And tell the map what our custom style is
    StyledMapTypeOptions styledMapTypeOptions = StyledMapTypeOptions.newInstance();
    styledMapTypeOptions.setName("Arcbees");
    StyledMapType customMapType = StyledMapType.newInstance(styles, styledMapTypeOptions);

    // -> Then we define our Lat and Long
    LatLng arcbeesCoord = LatLng.newInstance(46.792097, -71.285362);

    // -> Then goes the map options
    MapOptions options = MapOptions.newInstance();
    options.setCenter(arcbeesCoord);/*from  w ww.j av a 2  s  .  com*/
    options.setZoom(16);
    options.setScrollWheel(false);
    options.setMapTypeControlOptions(controlOptions);
    options.setMapTypeId(ARCBEES_MAPTYPE);
    options.setPanControl(false);
    options.setDraggable(Window.getClientWidth() > 649);

    ZoomControlOptions zoomControlOptions = ZoomControlOptions.newInstance();
    zoomControlOptions.setPosition(ControlPosition.RIGHT_CENTER);
    options.setZoomControlOptions(zoomControlOptions);

    // -> We create the map with our options
    MapWidget mapWidget = new MapWidget(options);
    mapWidget.addStyleName(page.style().map());
    mapWidget.setCustomMapType(ARCBEES_MAPTYPE, customMapType);

    // -> We define the marker
    MarkerOptions markerOptions = MarkerOptions.newInstance();
    markerOptions.setIcon(pageContactResources.marker().getSafeUri().asString());
    markerOptions.setMap(mapWidget);
    markerOptions.setPosition(arcbeesCoord);

    Marker.newInstance(markerOptions);

    // -> And finally, add it to its container
    container.add(mapWidget);
}

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

License:Apache License

private void drawBasicMarker() {
    LatLng center = LatLng.newInstance(47.8, -121.4);
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);//from w  w w.  ja  va  2 s .co m
    options.setTitle("Hello World");

    markerBasic = Marker.newInstance(options);
    markerBasic.setMap(mapWidget);

    markerBasic.addClickHandler(new ClickMapHandler() {
        @Override
        public void onEvent(ClickMapEvent event) {
            drawInfoWindow(markerBasic, event.getMouseEvent());
        }
    });
}

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

License:Apache License

private void drawMarkerWithBounceAnimation() {
    LatLng center = LatLng.newInstance(46.33, -113.81);
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);/*w  w  w  .ja v a 2 s  . co m*/
    options.setTitle("Hi I'm marker 2. Thanks for clicking on me.");
    options.setAnimation(Animation.BOUNCE);

    markerBouncing = Marker.newInstance(options);
    markerBouncing.setMap(mapWidget);
}

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

License:Apache License

private void drawMarkerWithDropAnimation() {
    LatLng center = LatLng.newInstance(42.33, -120.81);
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);/*from w w w .  ja  va  2s .  c  o  m*/
    options.setTitle("Thanks for clicking on me.");
    options.setAnimation(Animation.DROP);

    markerDrop = Marker.newInstance(options);
    markerDrop.setMap(mapWidget);
}

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

License:Apache License

private void drawMarker1() {
    LatLng center = LatLng.newInstance(47.8, -121.4);
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);//from  w ww. jav a 2  s.  c om
    options.setTitle("Hello World");

    final Marker marker = Marker.newInstance(options);
    marker.setMap(mapWidget);

    marker.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            drawInfoWindow(marker, event.getMouseEvent());
        }
    });
}

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

License:Apache License

private void processPanoSearch(LatLng latlng, final StreetViewPanoramaData data, StreetViewStatus status) {
    if (status != StreetViewStatus.OK) {
        // TODO error
        return;/*from w  w  w .j av  a2s  . c o  m*/
    }

    if (data == null) {
        // TODO error
        return;
    }

    // setup marker for location clicked
    MarkerOptions options = MarkerOptions.newInstance();
    options.setClickable(true);
    options.setPosition(latlng);
    options.setMap(mapWidget);
    options.setTitle(data.getLocation().getDescription());

    Marker marker = Marker.newInstance(options);

    // move back on click
    marker.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            moveStreetView(data);
        }
    });

    // move
    moveStreetView(data);
}

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

License:Open Source License

private Widget renderEventsOnMap() {
    markers.clear();//from w  ww .ja  v a  2s  .  c o 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.saveland.ancestry.client.InfoWindowMapWidget.java

License:Apache License

private void addPersonToMap(Person person) {
    final String key = person.key;
    LatLng center = LatLng.newInstance(person.lat, person.lon);
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);/*from w  ww .j av a2 s .  c  o m*/
    options.setTitle(person.getDisplayName());

    final Marker marker = Marker.newInstance(options);
    marker.setMap(mapWidget);

    marker.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            drawInfoWindow(key, marker, event.getMouseEvent());
            // fill the form with the person data
            cData.setCurrentPerson(key);
        }
    });
}

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

License:Open Source License

private SensorGroupMarker(double lat, double lon) {
    this.lat = lat;
    this.lon = lon;
    this.position = LatLng.newInstance(lat, lon);

    String iconPath = SpectrumBrowser.getIconsPath() + "mm_20_red.png";
    logger.finer("lon = " + lon + " lat = " + lat + " iconPath = " + iconPath);
    MarkerImage notSelectedIcon = MarkerImage.newInstance(iconPath);

    notSelectedIcon.setSize(Size.newInstance(12, 20));
    notSelectedIcon.setAnchor(Point.newInstance(6, 20));
    MarkerOptions notSelectedMarkerOptions = MarkerOptions.newInstance();
    notSelectedMarkerOptions.setIcon(notSelectedIcon);
    notSelectedMarkerOptions.setClickable(true);
    notSelectedMarker = Marker.newInstance(notSelectedMarkerOptions);

    // Attach marker to the map.

    notSelectedMarker.addMouseOverHandler(new NotSelectedMarkerMouseOverMapHandler());
    notSelectedMarker.addMouseOutMoveHandler(new NotSelectedMarkerMouseOutMapHandler());
    notSelectedMarker.addMouseDownHandler(new NotSelectedMarkerMouseDownMapHandler());
    notSelectedMarker.setPosition(position);
    notSelectedMarker.setVisible(true);/* w w  w  .  j a  v a  2 s  . co  m*/
    notSelectedMarker.setZindex(1);

    // Create icons for the selected marker.
    iconPath = SpectrumBrowser.getIconsPath() + "mm_20_yellow.png";
    MarkerImage selectedIcon = MarkerImage.newInstance(iconPath);
    selectedIcon.setSize(Size.newInstance(12, 20));
    selectedIcon.setAnchor(Point.newInstance(6, 20));
    // create marker options for the selected maker.
    MarkerOptions selectedMarkerOptions = MarkerOptions.newInstance();
    selectedMarkerOptions.setIcon(iconPath);
    selectedMarkerOptions.setClickable(true);

    // Create and attach the selected marker.
    selectedMarker = Marker.newInstance(selectedMarkerOptions);
    selectedMarker.setPosition(position);
    selectedMarker.setVisible(true);
    selectedMarker.setZindex(0);

}

From source file:gov.wa.wsdot.mobile.client.activities.ferries.vesselwatch.VesselWatchMapViewGwtImpl.java

License:Open Source License

@Override
public void addMapMarker(Position position) {
    if (myLocationMarker != null) {
        myLocationMarker.setMap((MapWidget) null);
    }/*from   w  ww  .j  av  a2  s. com*/

    if (myLocationError != null) {
        myLocationError.setMap(null);
    }

    LatLng center = LatLng.newInstance(position.getCoordinates().getLatitude(),
            position.getCoordinates().getLongitude());
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);
    MarkerImage icon = MarkerImage.newInstance(AppBundle.INSTANCE.myLocationPNG().getSafeUri().asString());
    icon.setAnchor(Point.newInstance(11, 11));
    options.setOptimized(true);
    options.setIcon(icon);
    myLocationMarker = Marker.newInstance(options);
    myLocationMarker.setMap(mapWidget);

    // create a circle the size of the error
    CircleOptions circleOptions = CircleOptions.newInstance();
    circleOptions.setFillOpacity(0.1);
    circleOptions.setFillColor("#1a75ff");
    circleOptions.setStrokeOpacity(0.12);
    circleOptions.setStrokeWeight(1);
    circleOptions.setStrokeColor("#1a75ff");
    myLocationError = Circle.newInstance(circleOptions);
    myLocationError.setCenter(center);
    myLocationError.setRadius(position.getCoordinates().getAccuracy());
    myLocationError.setMap(mapWidget);
}