dapriett / nativescript-google-maps-sdk

Cross Platform Google Maps SDK for Nativescript
MIT License
244 stars 169 forks source link

Adding GroundOverlays #492

Open onfireprojects opened 2 years ago

onfireprojects commented 2 years ago

[edited for readability and specification]

I want to add GroundOverlays, which are a thing inside the iOS file "objc!GoogleMaps.d.ts" >> GMSGroundOverlay and i may be mistaken, but i don't see a way to use that right now, as it's also not a part of map-view.d.ts or other files. Is there a way to use those functionalities (and other map-related things for that matter) directly - or am i missing something completely?

My project is running nativescript-vue 2.9 with nativescript-google-maps-sdk 3.0.2 btw

MrSnoozles commented 2 years ago

Have you found a solution yet? I think your best bet would be to add them via the native Google Maps SDK. We did something like that for a tile overlay, and thanks to NativeScripts ability to access native SDKs it was not that complicated.

Here's an example of how to add the tile overlay. Ground overlay should be similar.

methods: {
  addTileOverlayAndroid() {
    addPrecipitationTileOverlayAndroid() {
            // load the map overlay
            let tileUrlProvider = com.google.android.gms.maps.model.UrlTileProvider.extend({
                getTileUrl: (x,y,zoom) => {
                    let url = this.getTileUrl(x, y, zoom);

                    return new java.net.URL(url);
                }
            });

            let tileProviderInstance = new tileUrlProvider(256, 256);

            this.currentFrame.overlay = this.mapView.gMap.addTileOverlay(new com.google.android.gms.maps.model.TileOverlayOptions()
                                                         .tileProvider(tileProviderInstance)
                                                         .transparency(0.9));
        },
  }
}