question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nativescript-vue declaring a map in code.

See original GitHub issue

Currently is there any way to declare the nativescript-mapbox map via code using the nativescript-vue framework?

I have followed this tutorial https://www.nativescript.org/blog/include-feature-rich-maps-in-a-nativescript-vue-app-with-mapbox to get my project up and running but this only explains the xml implementation.

I know you have the available options/methods of the xml map written below the table but perhaps something near the top of the documentation about how the XML implementation is incomplete would have saved me a lot of time.

When trying to implement a map via code I have tried any of the following to import nativescript-mapbox in order to declare a map programmatically, all of which have failed.

At the top of the script section of the component I have tried using

import mapbox from 'nativescript-mapbox'
import * as mapbox from 'nativescript-mapbox'
import {Mapbox} from 'nativescript-mapbox

I have also tried including these names in the data section

mapbox: require('nativescript-mapbox'),
mapbox: require('nativescript-mapbox').Mapbox

please note each line is a seperate attempt at importing this. all of which result in NativeScript encountered a fatal error: TypeError: nativescript_mapbox__WEBPACK_IMPORTED_MODULE_2__["listOfflineRegions"] is not a function when trying to use any of the methods listed in the documentation (listOfflineRegions shown, but does the same with any of the functions). however the object is present so something is indeed being imported it just seems incomplete or not aligned with the documentation…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lochstarcommented, Apr 1, 2019

I’ve just tested this out in my own project.

Firstly, you can put the listOfflineRegions call in your loadMap function, so you don’t run in to the timing issue.

Secondly, you can call listOfflineRegions and downloadOfflineRegion using args.map.mapbox.listOfflineRegions and args.map.mapbox.downloadOfflineRegion.

To test this, I downloaded the current viewport, unloaded the mapview, turned on aeroplane mode and reloaded the mapview. The map correctly shows until I zoom in/out of the downloaded viewport.

1reaction
lochstarcommented, Mar 22, 2019

I’ve got this working with NativeScripe-Vue.

// import
import { Mapbox } from 'nativescript-mapbox'

// use in component
const map = new Mapbox()
map.show({...options})

Although, I use the XML implementation, it allows for more control over the position and placement of the map. You should be able to do everything you need once you have the map reference that you get via @mapReady.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a Map-based App with Nativescript Vue
In this post, I'll discuss how to use maps, location services and API calls to create a Nativescript Vue application that will display...
Read more >
Nativescript-vue declaring a map in code. · Issue #309 - GitHub
Currently is there any way to declare the nativescript-mapbox map via code using the nativescript-vue framework?
Read more >
Include Feature-Rich Maps in a NativeScript-Vue App with ...
We're going to see how to include Mapbox, a strong competitor to Google Maps, in our NativeScript with Vue.js application using clean and ......
Read more >
Building a Real-time Location Tracking app with NativeScript ...
Step 1: Project Setup​​ First, lets create a new project based on the vue-cli-template (a blank Nativescript-Vue app) using terminal. Installs ...
Read more >
Creating a Real-Time Location Tracking App with NativeScript ...
In this blog post, we explore the NativeScript-Vue template for building a real-time location tracking app that uses the Google Maps API.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found