List of usage examples for com.google.gwt.maps.client.controls MapTypeControlOptions setMapTypeIds
public final void setMapTypeIds(String[] mapTypeIds)
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 www . jav a2s . co m*/ 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.ControlsMapWidget.java
License:Apache License
private void drawMap() { MapTypeControlOptions controlOptions = MapTypeControlOptions.newInstance(); controlOptions.setMapTypeIds(MapTypeId.values()); // use all of them controlOptions.setPosition(ControlPosition.RIGHT_CENTER); LatLng center = LatLng.newInstance(49.496675, -102.65625); MapOptions options = MapOptions.newInstance(); options.setZoom(4);// w w w . j a va 2 s .c om options.setCenter(center); options.setMapTypeId(MapTypeId.HYBRID); options.setMapTypeControlOptions(controlOptions); mapWidget = new MapWidget(options); pWidget.add(mapWidget); mapWidget.setSize("750px", "500px"); mapWidget.addClickHandler(new ClickMapHandler() { public void onEvent(ClickMapEvent event) { // TODO fix the event getting, getting .... GWT.log("clicked on latlng=" + event.getMouseEvent().getLatLng()); } }); }
From source file:com.google.gwt.maps.testing.client.maps.ImageMapTypeWidget.java
License:Apache License
private void drawMap() { // make custom maps ImageMapType moonType = getMoonMapType(); ImageMapType marsType = getMarsMapType(); // draw map//from ww w. j a va2 s .co m MapTypeControlOptions controlOpts = MapTypeControlOptions.newInstance(); //TODO How it make it label as "Earth" not "Satellite" without redefining that standard map type? controlOpts.setMapTypeIds(new String[] { LUNAR_NAME, MARTIAN_NAME, MapTypeId.SATELLITE.toString() }); MapOptions opts = MapOptions.newInstance(); opts.setCenter(LatLng.newInstance(-12d, -70d)); opts.setZoom(7); opts.setMapTypeControlOptions(controlOpts); opts.setStreetViewControl(false); mapWidget = new MapWidget(opts); mapWidget.setSize("750px", "500px"); // add to map mapWidget.getMapTypeRegistry().set(MARTIAN_NAME, marsType); mapWidget.getMapTypeRegistry().set(LUNAR_NAME, moonType); mapWidget.setMapTypeId(MARTIAN_NAME); pWidget.add(mapWidget); }
From source file:com.google.gwt.maps.testing.client.maps.OpenStreetMapLayerWidget.java
License:Apache License
/** * Creates map widget and adds to container *//* w w w . j a v a2 s.co m*/ private void drawMap() { int zoomLevel = 13; LatLng center = LatLng.newInstance(42.35, -71.07); String osmMapTypeName = "OSM"; // need to be consistent in the // controlOptions and mapTypeRegistry /* Create a map and add the OSM layer */ MapTypeControlOptions controlOptions = MapTypeControlOptions.newInstance(); controlOptions.setMapTypeIds(new String[] { osmMapTypeName, MapTypeId.ROADMAP.toString() }); MapOptions options = MapOptions.newInstance(); options.setZoom(zoomLevel); options.setCenter(center); options.setMapTypeControlOptions(controlOptions); options.setMapTypeId(osmMapTypeName); // set the OSM as the selected type mapWidget = new MapWidget(options); // Add the new map type we created to the registry so it can be used by // the map mapWidget.getMapTypeRegistry().set(osmMapTypeName, getOsmMapType()); pWidget.add(mapWidget); mapWidget.setSize("750px", "500px"); }
From source file:com.google.gwt.maps.testing.client.maps.StyledMapWidget.java
License:Apache License
private void drawMap() { /** Create all your styles **/ // Style the roads MapTypeStyle style1 = MapTypeStyle.newInstance(); style1.setElementType(MapTypeStyleElementType.GEOMETRY); style1.setFeatureType(MapTypeStyleFeatureType.ROAD); style1.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#CC3232"), MapTypeStyler.newSaturationStyler(100), MapTypeStyler.newLightnessStyler(-45) }); // Style the landscape MapTypeStyle style2 = MapTypeStyle.newInstance(); style2.setElementType(MapTypeStyleElementType.GEOMETRY); style2.setFeatureType(MapTypeStyleFeatureType.LANDSCAPE); style2.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#000000"), MapTypeStyler.newSaturationStyler(75), MapTypeStyler.newLightnessStyler(-100) }); // Style the highways MapTypeStyle style3 = MapTypeStyle.newInstance(); style3.setElementType(MapTypeStyleElementType.GEOMETRY); style3.setFeatureType(MapTypeStyleFeatureType.ROAD__HIGHWAY); style3.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#0000FF"), MapTypeStyler.newSaturationStyler(5), }); // consolidate all style information MapTypeStyle[] array = { style1, style2, style3 }; JsArray<MapTypeStyle> styles = ArrayHelper.toJsArray(array); // JS needs // JSArray, // convert StyledMapTypeOptions options = StyledMapTypeOptions.newInstance(); options.setName("My Eyes Hurt!");// the name that appears on map controls options.setAlt("Hold onto your retinas!"); StyledMapType customMapType = StyledMapType.newInstance(styles, options); // apply // to // new // styled // map /** Create you map **/ // basic map options LatLng center = LatLng.newInstance(40.6743890, -73.9455); MapOptions opts = MapOptions.newInstance(); opts.setZoom(12);/*from w w w . java 2 s . com*/ opts.setCenter(center); opts.setMapTypeId(MapTypeId.ROADMAP); // NOTE: using the xString methods here on Map options b/c it can handle // either MapTypeId|string, but Java cannot. // If using custom id's, make sure to use the String methods (i.e. in below // block) MapTypeControlOptions controlOptions = MapTypeControlOptions.newInstance(); controlOptions.setMapTypeIds(new String[] { MapTypeId.ROADMAP.toString(), MY_COOL_MAPTYPE }); opts.setMapTypeControlOptions(controlOptions); opts.setMapTypeId(MY_COOL_MAPTYPE); mapWidget = new MapWidget(opts); pWidget.add(mapWidget); mapWidget.setSize("750px", "500px"); // finally add the map to the type registry mapWidget.setCustomMapType(MY_COOL_MAPTYPE, customMapType); }
From source file:com.sagar.restgwt.client.ui.OpenStreetMapLayerWidget.java
License:Apache License
/** * Creates map widget and adds to container *///from w ww . ja v a2s.c o m private void drawMap() { int zoomLevel = 10; LatLng center = LatLng.newInstance(14.5500, 121.0300); String osmMapTypeName = "OSM"; // need to be consistent in the // controlOptions and mapTypeRegistry /* Create a map and add the OSM layer */ MapTypeControlOptions controlOptions = MapTypeControlOptions.newInstance(); controlOptions.setMapTypeIds(new String[] { osmMapTypeName, MapTypeId.ROADMAP.toString() }); MapOptions options = MapOptions.newInstance(); options.setZoom(zoomLevel); options.setCenter(center); options.setMapTypeControlOptions(controlOptions); options.setMapTypeId(osmMapTypeName); // set the OSM as the selected type mapWidget = new MapWidget(options); // Add the new map type we created to the registry so it can be used by // the map mapWidget.getMapTypeRegistry().set(osmMapTypeName, getOsmMapType()); pWidget.add(mapWidget); mapWidget.setSize("100%", "100vh"); }
From source file:org.rebioma.client.MapView.java
License:Apache License
private void initMap() { MapOptions mapOptions = MapOptions.newInstance(); mapOptions.setCenter(HistoryState.DEFAULT_CENTER); mapOptions.setZoom(DEFAULT_ZOOM);/* ww w . j av a 2 s .c om*/ mapOptions.setDraggableCursor("crosshair"); mapOptions.setDraggingCursor("move"); mapOptions.setMapTypeId(DEFAULT_MAP_TYPE); mapOptions.setScaleControl(true); MapTypeControlOptions mapTypeControlOptions = MapTypeControlOptions.newInstance(); mapTypeControlOptions.setMapTypeIds(MapTypeId.values()); mapTypesMap.put(MapTypeId.TERRAIN.toString(), MapTypeId.TERRAIN); mapTypesMap.put(MapTypeId.ROADMAP.toString(), MapTypeId.ROADMAP); mapTypesMap.put(MapTypeId.SATELLITE.toString(), MapTypeId.SATELLITE); mapOptions.setMapTypeControlOptions(mapTypeControlOptions); mapOptions.setMapTypeControl(true); map = new MapWidget(mapOptions); map.setWidth("100%"); map.setHeight("100%"); final MapView mapView = this; // map.addControl(getModelControl()); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { HideControl hideControl = new HideControl(); map.setControls(ControlPosition.TOP_RIGHT, hideControl); controlsGroup.setMap(map, ControlPosition.RIGHT_TOP); // map.setControls(ControlPosition.TOP_RIGHT, geocoder); /*ScaleControl scaleControl = new ScaleControl(); LargeMapControl largeMapControl = new LargeMapControl(); MenuMapTypeControl mapTypeControl = new MenuMapTypeControl(); map.addControl(scaleControl); map.addControl(largeMapControl); map.addControl(mapTypeControl); ControlPosition hideControlPosition = new ControlPosition( ControlAnchor.TOP_RIGHT, 100, 10);*/ // envLayerSelector.setMap(map, ControlPosition.TOP_RIGHT); hideControl.addControlWidgetToHide(geocoder); hideControl.addControlWidgetToHide(envLayerSelector); CoordinatesControl coordinatesControl = new CoordinatesControl(map); MapDrawingControl mapDrawingControl = new MapDrawingControl(map, ControlPosition.TOP_CENTER); mapDrawingControl.addListener(mapView); ClearMapDrawingControl clearMapDrawingControl = new ClearMapDrawingControl(mapDrawingControl); map.setControls(ControlPosition.TOP_LEFT, clearMapDrawingControl); } }); map.addClickHandler(mapClickHandler); map.addZoomChangeHandler(mapZoomHandler); map.addMapTypeIdChangeHandler(mapTypeHandler); // map.checkResizeAndCenter(); }
From source file:pl.itrack.client.local.services.maps.TricitySchemaService.java
License:Apache License
@Override public MapOptions getMapOptions() { MapTypeControlOptions controlOpts = MapTypeControlOptions.newInstance(); controlOpts.setMapTypeIds(new String[] { MAP_TYPE_ID }); MapOptions opts = MapOptions.newInstance(); opts.setZoom(ZOOM_INITIAL);//from ww w .j a v a2 s . c o m opts.setMapTypeControlOptions(controlOpts); opts.setPanControl(false); opts.setStreetViewControl(false); opts.setBackgroundColor(BACKGROUND_COLOR); opts.setCenter(LatLng.newInstance(INITIAL_LATITUDE, INITIAL_LONGITUDE)); return opts; }