0

I'm having a problem with my code. I'm just trying to add a simple marker. Here's my implementation

<script setup lang="ts">
import { AbsoluteLayout, Page } from '@nativescript/core';
import type { GoogleMap } from '@nativescript/google-maps';
import { ref } from 'nativescript-vue';

const mapRef = ref<GoogleMap | null>(null);

const handleMapReady = (args: { map: GoogleMap }) => {
  console.log("Map is ready");
  mapRef.value = args.map;

  mapRef.value.addMarker({
    position: {
      lat: 1.4478297,
      lng: 124.8293001,
    }
  });
};
</script>

<template>
  <Page>
    <AbsoluteLayout width="100%" height="100%">
      <MapView
        width="100%"
        height="100%"
        @ready="handleMapReady"
      />
    </AbsoluteLayout>
  </Page>
</template>

But the app keeps closing. No force close message. No error in console. The last log entry is just:

Map is ready

Remove the .addMarker() statement, and the app runs just fine.

Here's the versions of NS core and the Google Maps plugin:

{
  "@nativescript/google-maps": "^1.8.0",
  "@nativescript/core": "~8.9.1"
}

Also, app.ts in case it matters:

import { createApp } from 'nativescript-vue';
import GoogleMaps from '@nativescript/google-maps/vue'
import App from './App.vue';

createApp(App)
  .use(GoogleMaps)
  .start();

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.