plugins icon indicating copy to clipboard operation
plugins copied to clipboard

feat/google-map-utils

Open herefishyfish opened this issue 2 years ago • 10 comments

Google map utilities library integration.

Features:

herefishyfish avatar Jul 05 '22 10:07 herefishyfish

@triniwiz @NathanWalker Hopefully I can come back to this soon but at the moment my time is becoming pretty limited. Might be worth pushing these feaures as a baseline till I get a chance to come back to this. Thoughts?

herefishyfish avatar Jul 16 '22 08:07 herefishyfish

@herefishyfish thank you, If you don't mind I can finish it up. 😄

triniwiz avatar Jul 17 '22 18:07 triniwiz

@triniwiz I don't mind. I did however notice that the iOS util tooling doesn't actually support the Icon generator for custom icons that android has available - so that makes this a bit easier again :)

herefishyfish avatar Jul 18 '22 02:07 herefishyfish

I'm very interested in the clustering feature, I tried implementing it myself on the old dapriett/nativescript-google-maps-sdk plugin but failed when it came to info windows and custom markers. @herefishyfish since it seems you have better understanding of this, do you think it's possible to implement clustering with custom marker icons (static resources, not clusters) and info windows? By this I mean, do both Android and iOS support this feature?

tommag21 avatar Jul 18 '22 08:07 tommag21

I'm very interested in the clustering feature, I tried implementing it myself on the old dapriett/nativescript-google-maps-sdk plugin but failed when it came to info windows and custom markers. @herefishyfish since it seems you have better understanding of this, do you think it's possible to implement clustering with custom marker icons (static resources, not clusters) and info windows? By this I mean, do both Android and iOS support this feature?

Both iOS and Android suppport custom cluster icons for sure. Not so sure about cluster info windows though. For iOS you would need to create a custom renderer delegate and add in your own logic to handle the cluster icons; something like this:

@ObjCClass(GMUClusterRendererDelegate)
@NativeClass()
class GMUClusterRendererDelegateImpl extends NSObject implements GMUClusterRendererDelegate {
	rendererWillRenderMarker(renderer: GMUClusterRenderer, marker: GMSMarker): void {
		// Determine if marker is a cluster or not, the google example uses userData
		if (marker.userData instanceof CustomMarkerData === false) {
			// Set custom cluster marker if it's a cluster.
			marker.icon = coolCustomMarker
		}
	}
}

Android you can extend the custom renderer I've created here or create your own and override the render function like so:

@NativeClass()
export class CustomClusterRenderer extends ClusterRenderer {
	constructor(map: GoogleMap, clusterManager: ClusterManager) {
		super(map, clusterManager);
	}

	override onBeforeClusterRendered(
                clusterItem: com.google.maps.android.clustering.Cluster<any>, 
                options: com.google.android.gms.maps.model.MarkerOptions): void 
        {
		super.onBeforeClusterRendered(clusterItem, options);

		options.icon = coolCustomMarker;
	}
} 

herefishyfish avatar Jul 18 '22 13:07 herefishyfish

I love this PR, I was looking for how to do clustering. Why is this PR not divided into smaller PRs? so we can have features faster and not have to wait for everything to be ready

vallemar avatar Aug 02 '22 14:08 vallemar

@herefishyfish if everything checked off list looks good on your end we could publish a minor version bump with this and handle KML in separate PR, lemme know your thoughts?

NathanWalker avatar Aug 08 '22 00:08 NathanWalker

@NathanWalker Heatmaps and clustering are in a pretty good state. GeoJson will most likely get refactored with the KML implementation.

I think there are a couple of stylistic differences between @triniwiz google-maps and how I have implemented the features and would like to get his aproval over anything else before we commit this PR. However I am perfectly okay with handling the KML/GeoJson part in a seperate PR and think we can push this for sure.

herefishyfish avatar Aug 08 '22 01:08 herefishyfish

Hi, has @triniwiz expressed his approval?

tommag21 avatar Oct 04 '22 13:10 tommag21

@tommag21 I'll wrap this up soon, sorry some other things came up.

triniwiz avatar Oct 04 '22 13:10 triniwiz