Skip to content

Commit d035c4e

Browse files
authored
docs: update README.md to remove mentions to the v1 migration (#1521)
1 parent 506759f commit d035c4e

File tree

1 file changed

+0
-219
lines changed

1 file changed

+0
-219
lines changed

README.md

Lines changed: 0 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -123,225 +123,6 @@ By default, the `Source` is set to `Source.DEFAULT`, but you can also specify `S
123123

124124
</details>
125125

126-
<details>
127-
<summary>Migration Guide from v0.x to 1.0</summary>
128-
129-
### Migrating from v0.x to 1.0
130-
131-
Improvements made in version [1.0.0](https://github.com/googlemaps/android-maps-utils/releases/tag/1.0.0) of the library to support multiple layers on the map caused breaking changes to versions prior to it. These changes also modify behaviors that are documented in the [Maps SDK for Android Maps documentation](https://developers.google.com/maps/documentation/android-sdk/intro) site. This section outlines all those changes and how you can migrate to use this library since version 1.0.0.
132-
133-
134-
### Adding Click Events
135-
136-
Click events originate in the layer-specific object that added the marker/ground overlay/polyline/polygon. In each layer, the click handlers are passed to the marker, ground overlay, polyline, or polygon `Collection` object.
137-
138-
```java
139-
// Clustering
140-
ClusterManager<ClusterItem> clusterManager = // Initialize ClusterManager - if you're using multiple maps features, use the constructor that passes in Manager objects (see next section)
141-
clusterManager.setOnClusterItemClickListener(item -> {
142-
// Listen for clicks on a cluster item here
143-
return false;
144-
});
145-
clusterManager.setOnClusterClickListener(item -> {
146-
// Listen for clicks on a cluster here
147-
return false;
148-
});
149-
150-
// GeoJson
151-
GeoJsonLayer geoJsonLayer = // Initialize GeoJsonLayer - if you're using multiple maps features, use the constructor that passes in Manager objects (see next section)
152-
geoJsonLayer.setOnFeatureClickListener(feature -> {
153-
// Listen for clicks on GeoJson features here
154-
});
155-
156-
// KML
157-
KmlLayer kmlLayer = // Initialize KmlLayer - if you're using multiple maps features, use the constructor that passes in Manager objects (see next section)
158-
kmlLayer.setOnFeatureClickListener(feature -> {
159-
// Listen for clicks on KML features here
160-
});
161-
```
162-
163-
#### Using Manager Objects
164-
165-
If you use one of Manager objects in the package `com.google.maps.android` (e.g. `GroundOverlayManager`, `MarkerManager`, etc.), say from adding a KML layer, GeoJson layer, or Clustering, you will have to rely on the Collection specific to add an object to the map rather than adding that object directly to `GoogleMap`. This is because each Manager sets itself as a click listener so that it can manage click events coming from multiple layers.
166-
167-
For example, if you have additional `GroundOverlay` objects:
168-
169-
_New_
170-
171-
```java
172-
GroundOverlayManager groundOverlayManager = // Initialize
173-
174-
// Create a new collection first
175-
GroundOverlayManager.Collection groundOverlayCollection = groundOverlayManager.newCollection();
176-
177-
// Add a new ground overlay
178-
GroundOverlayOptions options = // ...
179-
groundOverlayCollection.addGroundOverlay(options);
180-
```
181-
182-
_Old_
183-
184-
```java
185-
GroundOverlayOptions options = // ...
186-
googleMap.addGroundOverlay(options);
187-
```
188-
189-
This same pattern applies for `Marker`, `Circle`, `Polyline`, and `Polygon`.
190-
191-
### Adding a Custom Info Window
192-
If you use `MarkerManager`, adding an `InfoWindowAdapter` and/or an `OnInfoWindowClickListener` should be done on the `MarkerManager.Collection` object.
193-
194-
_New_
195-
```java
196-
CustomInfoWindowAdapter adapter = // ...
197-
OnInfoWindowClickListener listener = // ...
198-
199-
// Create a new Collection from a MarkerManager
200-
MarkerManager markerManager = // ...
201-
MarkerManager.Collection collection = markerManager.newCollection();
202-
203-
// Set InfoWindowAdapter and OnInfoWindowClickListener
204-
collection.setInfoWindowAdapter(adapter);
205-
collection.setOnInfoWindowClickListener(listener);
206-
207-
// Alternatively, if you are using clustering
208-
ClusterManager<ClusterItem> clusterManager = // ...
209-
MarkerManager.Collection markerCollection = clusterManager.getMarkerCollection();
210-
markerCollection.setInfoWindowAdapter(adapter);
211-
markerCollection.setOnInfoWindowClickListener(listener);
212-
```
213-
214-
_Old_
215-
```java
216-
CustomInfoWindowAdapter adapter = // ...
217-
OnInfoWindowClickListener listener = // ...
218-
googleMap.setInfoWindowAdapter(adapter);
219-
googleMap.setOnInfoWindowClickListener(listener);
220-
```
221-
222-
### Adding a Marker Drag Listener
223-
224-
If you use `MarkerManager`, adding an `OnMarkerDragListener` should be done on the `MarkerManager.Collection` object.
225-
226-
_New_
227-
```java
228-
// Create a new Collection from a MarkerManager
229-
MarkerManager markerManager = // ...
230-
MarkerManager.Collection collection = markerManager.newCollection();
231-
232-
// Add markers to collection
233-
MarkerOptions markerOptions = // ...
234-
collection.addMarker(markerOptions);
235-
// ...
236-
237-
// Set OnMarkerDragListener
238-
GoogleMap.OnMarkerDragListener listener = // ...
239-
collection.setOnMarkerDragListener(listener);
240-
241-
// Alternatively, if you are using clustering
242-
ClusterManager<ClusterItem> clusterManager = // ...
243-
MarkerManager.Collection markerCollection = clusterManager.getMarkerCollection();
244-
markerCollection.setOnMarkerDragListener(listener);
245-
```
246-
247-
_Old_
248-
```java
249-
// Add markers
250-
MarkerOptions markerOptions = // ...
251-
googleMap.addMarker(makerOptions);
252-
253-
// Add listener
254-
GoogleMap.OnMarkerDragListener listener = // ...
255-
googleMap.setOnMarkerDragListener(listener);
256-
```
257-
258-
### Clustering
259-
260-
[A bug](https://github.com/googlemaps/android-maps-utils/issues/90) was fixed in v1 to properly clear and re-add markers via the `ClusterManager`.
261-
262-
For example, this didn't work pre-v1, but works for v1 and later:
263-
264-
```java
265-
clusterManager.clearItems();
266-
clusterManager.addItems(items);
267-
clusterManager.cluster();
268-
```
269-
270-
If you're using custom clustering (i.e, if you're extending `DefaultClusterRenderer`), you must override two additional methods in v1:
271-
* `onClusterItemUpdated()` - should be the same* as your `onBeforeClusterItemRendered()` method
272-
* `onClusterUpdated()` - should be the same* as your `onBeforeClusterRendered()` method
273-
274-
**Note that these methods can't be identical, as you need to use a `Marker` instead of `MarkerOptions`*
275-
276-
See the [`CustomMarkerClusteringDemoActivity`](demo/src/main/java/com/google/maps/android/utils/demo/CustomMarkerClusteringDemoActivity.java) in the demo app for a complete example.
277-
278-
_New_
279-
280-
```java
281-
private class PersonRenderer extends DefaultClusterRenderer<Person> {
282-
...
283-
@Override
284-
protected void onBeforeClusterItemRendered(Person person, MarkerOptions markerOptions) {
285-
// Draw a single person - show their profile photo and set the info window to show their name
286-
markerOptions
287-
.icon(getItemIcon(person))
288-
.title(person.name);
289-
}
290-
291-
/**
292-
* New in v1
293-
*/
294-
@Override
295-
protected void onClusterItemUpdated(Person person, Marker marker) {
296-
// Same implementation as onBeforeClusterItemRendered() (to update cached markers)
297-
marker.setIcon(getItemIcon(person));
298-
marker.setTitle(person.name);
299-
}
300-
301-
@Override
302-
protected void onBeforeClusterRendered(Cluster<Person> cluster, MarkerOptions markerOptions) {
303-
// Draw multiple people.
304-
// Note: this method runs on the UI thread. Don't spend too much time in here (like in this example).
305-
markerOptions.icon(getClusterIcon(cluster));
306-
}
307-
308-
/**
309-
* New in v1
310-
*/
311-
@Override
312-
protected void onClusterUpdated(Cluster<Person> cluster, Marker marker) {
313-
// Same implementation as onBeforeClusterRendered() (to update cached markers)
314-
marker.setIcon(getClusterIcon(cluster));
315-
}
316-
...
317-
}
318-
```
319-
320-
_Old_
321-
322-
```java
323-
private class PersonRenderer extends DefaultClusterRenderer<Person> {
324-
...
325-
@Override
326-
protected void onBeforeClusterItemRendered(Person person, MarkerOptions markerOptions) {
327-
// Draw a single person - show their profile photo and set the info window to show their name
328-
markerOptions
329-
.icon(getItemIcon(person))
330-
.title(person.name);
331-
}
332-
333-
@Override
334-
protected void onBeforeClusterRendered(Cluster<Person> cluster, MarkerOptions markerOptions) {
335-
// Draw multiple people.
336-
// Note: this method runs on the UI thread. Don't spend too much time in here (like in this example).
337-
markerOptions.icon(getClusterIcon(cluster));
338-
}
339-
...
340-
}
341-
```
342-
343-
</details>
344-
345126
## Contributing
346127

347128
Contributions are welcome and encouraged! If you'd like to contribute, send us a [pull request] and refer to our [code of conduct] and [contributing guide].

0 commit comments

Comments
 (0)