|
| 1 | +/*- |
| 2 | + * #%L |
| 3 | + * Google Maps Addon |
| 4 | + * %% |
| 5 | + * Copyright (C) 2020 - 2023 Flowing Code |
| 6 | + * %% |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + * #L% |
| 19 | + */ |
| 20 | +package com.flowingcode.vaadin.addons.googlemaps; |
| 21 | + |
| 22 | +import com.flowingcode.vaadin.addons.demo.DemoSource; |
| 23 | +import com.flowingcode.vaadin.addons.googlemaps.GoogleMap.MapType; |
| 24 | +import com.vaadin.flow.component.dependency.JsModule; |
| 25 | +import com.vaadin.flow.router.PageTitle; |
| 26 | +import com.vaadin.flow.router.Route; |
| 27 | + |
| 28 | +@PageTitle("Clustering With Custom Renderer Demo") |
| 29 | +@DemoSource |
| 30 | +@Route(value = "googlemaps/clustering-custom-renderer", layout = GooglemapsDemoView.class) |
| 31 | +@JsModule("./src/clustering-custom-renderer-example.js") |
| 32 | +@SuppressWarnings("serial") |
| 33 | +public class ClusteringWithCustomRendererDemo extends AbstractGoogleMapsDemo { |
| 34 | + |
| 35 | + @Override |
| 36 | + protected void createGoogleMapsDemo(String apiKey) { |
| 37 | + GoogleMap gmaps = new GoogleMap(apiKey, null, null); |
| 38 | + gmaps.setMapType(MapType.ROADMAP); |
| 39 | + gmaps.setSizeFull(); |
| 40 | + gmaps.setZoom(5); |
| 41 | + gmaps.setCenter(new LatLon(-31.636036, -60.7055271)); |
| 42 | + |
| 43 | + gmaps.addMarker("Marker 1", new LatLon(-31.646036, -58.7055290), true, Markers.PURPLE); |
| 44 | + gmaps.addMarker("Marker 2", new LatLon(-31.562346, -58.6176364), true, Markers.PURPLE); |
| 45 | + gmaps.addMarker("Marker 3", new LatLon(-31.531917, -58.8456027), true, Markers.PURPLE); |
| 46 | + gmaps.addMarker("Marker 4", new LatLon(-31.651667, -58.9555557), true, Markers.PURPLE); |
| 47 | + |
| 48 | + gmaps.addMarker("Marker 5", new LatLon(-30.997815, -68.60542944), false, Markers.BLUE); |
| 49 | + gmaps.addMarker("Marker 6", new LatLon(-31.298693, -68.50630836), false, Markers.BLUE); |
| 50 | + gmaps.addMarker("Marker 7", new LatLon(-31.878914, -68.28658178), false, Markers.BLUE); |
| 51 | + |
| 52 | + gmaps.addMarker("Marker 8", new LatLon(-35.138889, -65.95699194), false, Markers.GREEN); |
| 53 | + gmaps.addMarker("Marker 9", new LatLon(-35.322683, -65.12203100), false, Markers.GREEN); |
| 54 | + gmaps.addMarker("Marker 10", new LatLon(-35.652538, -65.737265381), false, Markers.GREEN); |
| 55 | + gmaps.addMarker("Marker 11", new LatLon(-35.512548, -65.565465771), false, Markers.GREEN); |
| 56 | + gmaps.addMarker("Marker 12", new LatLon(-35.650638, -65.707366381), false, Markers.YELLOW); |
| 57 | + gmaps.addMarker("Marker 13", new LatLon(-35.550638, -65.703360000), false, Markers.YELLOW); |
| 58 | + |
| 59 | + // enable clustering |
| 60 | + gmaps.enableMarkersClustering(); |
| 61 | + |
| 62 | + /* |
| 63 | + * set custom renderer for clustering (see |
| 64 | + * /google-maps/src/test/resources/META-INF/resources/frontend/src/clustering-custom-renderer- |
| 65 | + * example.js for definition) |
| 66 | + */ |
| 67 | + gmaps.setClusteringRenderer("customRenderer"); |
| 68 | + |
| 69 | + add(gmaps); |
| 70 | + } |
| 71 | + |
| 72 | +} |
0 commit comments