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

NS8 infoWindowTemplate is not working #480

Open
Woongsik opened this issue Jul 30, 2021 · 1 comment
Open

NS8 infoWindowTemplate is not working #480

Woongsik opened this issue Jul 30, 2021 · 1 comment

Comments

@Woongsik
Copy link

Woongsik commented Jul 30, 2021

Hi, I am using nativescript -vue and like to use custom info window.
As you mentioned it is not working with NS7 or 8 and tried to have alternatives you suggested.

in main.ts
import { MapView } from "nativescript-google-maps-sdk";
Vue.registerElement('MapView', () =>MapView);

in component,

 <GridLayout>
       <MapView mapReady="onMapReady">
            <!-- Default Info Window Template -->       		
            <MapView.infoWindowTemplate>
                <StackLayout orientation="vertical" width="200" height="150" >
                    <Label text="{{title}}" className="title" width="125"   />
                    <Label text="{{snippet}}" className="snippet" width="125"   />
                    <Label text="{{'LAT: ' + position.latitude}}" className="infoWindowCoordinates"  />
                    <Label text="{{'LON: ' + position.longitude}}" className="infoWindowCoordinates"  />
                </StackLayout>
            </MapView.infoWindowTemplate>
            <!-- Keyed Info Window Templates -->   
            <MapView.infoWindowTemplates>
                <template key="testWindow">
                    <StackLayout orientation="vertical" width="160" height="160" >
                        <Image src="res://icon" stretch="fill"  height="100" width="100" className="infoWindowImage" />
                        <Label text="Let's Begin!" className="title" />
                    </StackLayout>
                </template>
            </MapView.infoWindowTemplates>
        </MapView>
  </GridLayout>

If I use <MapView.infoWindowTemplate> then it became a blank and can't do anything.
But with old way mapView.infoWidowTemplate = "Some string as template", the error comes.

Error: Parsing XML at 1:2
System.err: > Module 'GridLayout' not found for element 'GridLayout'.
System.err: > com.tns.NativeScriptException: Failed to find module: "@nativescript/core/ui", relative to: app/tns_modules/

Any updates or any workaround here?

@Woongsik Woongsik changed the title NS8 infoWindowTemplate is not available NS8 infoWindowTemplate is not working Jul 30, 2021
@Woongsik
Copy link
Author

If somebody have a suffer from this, try it in main.ts as work around !!
You still can use mapView.infoWindowTemplate = "some string template" like NS6

In main.ts

// From webpack, DefinePlugins
declare let global.TNS_WEBPACK: string;

if (global.TNS_WEBPACK) {
require("@nativescript/core/bundle-entry-points");
const context = require.context("~/", true, /(page|fragment).(xml|css|js|ts|scss|less|sass)$/);
global.registerWebpackModules(context);
}

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

No branches or pull requests

1 participant