Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/google-map-utils #298

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

herefishyfish
Copy link
Contributor

@herefishyfish herefishyfish commented Jul 5, 2022

Google map utilities library integration.

Features:

@cla-bot cla-bot bot added the cla: yes label Jul 5, 2022
@herefishyfish herefishyfish deleted the feat/google-map-utils branch July 5, 2022 10:42
@herefishyfish herefishyfish restored the feat/google-map-utils branch July 5, 2022 10:43
@herefishyfish herefishyfish reopened this Jul 5, 2022
@herefishyfish
Copy link
Contributor Author

@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?

@triniwiz
Copy link
Member

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

@herefishyfish
Copy link
Contributor Author

@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 :)

@tommag21
Copy link
Contributor

tommag21 commented Jul 18, 2022

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?

@herefishyfish
Copy link
Contributor Author

herefishyfish commented Jul 18, 2022

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;
	}
} 

@vallemar
Copy link
Contributor

vallemar commented Aug 2, 2022

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

@NathanWalker
Copy link
Contributor

@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?

@herefishyfish
Copy link
Contributor Author

@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.

@tommag21
Copy link
Contributor

tommag21 commented Oct 4, 2022

Hi, has @triniwiz expressed his approval?

@triniwiz
Copy link
Member

triniwiz commented Oct 4, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants