Giter VIP home page Giter VIP logo

nativescript-mapbox's Introduction

This project has moved:

This project is now being maintained here: https://github.com/nativescript-community/ui-mapbox as it's become clear contrary to what I thought, I don't actually have enough time to maintain it myself.

NativeScript Mapbox plugin

NPM version Downloads Twitter Follow

Awesome native OpenGL-powered maps - by Mapbox

There is a NativeScript Core Modules bug under Android that causes random crashes on navigation. See ./demo-angular/README.md for a workaround. NativeScript/NativeScript#7954 NativeScript/NativeScript#7867

Before you begin - Prerequisites

You either need your own tile server such as the one provided by openmaptiles.org or a Mapbox API access token (they have a 🆓 Starter plan!), so sign up with Mapbox. Once you've registered go to your Account > Apps > New token. The 'Default Secret Token' is what you'll need.

You will also need to set up your development environment. Please refer to the NativeScript documentation.

Installation

$ tns plugin install nativescript-mapbox

DEMOS

Two demo applications are available in the repository.

To run them, you'll need to clone the github repository and build the plugin. See below.

You will also need an access token. Your access_token can then be set in the top level mapbox_config.ts file.

The style can be set to one of the Mapbox style names or it can be the URL of your own hosted tile server.

NOTE: As of this writing, the NativeScript demo only works with a mapbox token. The demo-angular will work with either a self hosted tile server or a mapbox token.

To run the Angular demo

cd src
npm run build.release
cd ../demo-angular
tns run <platform>

To run the plain Nativescript demo

cd src
npm run build.release
cd ../demo
tns run <platform>

Debug Build

To come up to speed on the plugin, I added extensive trace messages. These can be turned on by replacing 'npm run build.release' with 'npm run build.debug' in the commands above.

Breaking Changes

This version includes breaking API changes.

The intent moving forward is to mirror, to the maximum extent practical, the Mapbox GL JS API to enable sharing of mapping code between browser based and native applications.

Issues

If you get an error during iOS build related to Podspec versions, probably the easiest fix is: tns platform remove ios and tns platform add ios.

On Android the plugin adds this to the <application> node of app/App_Resources/Android/AndroidManifest.xml (the plugin already attempts to do so):

  <service android:name="com.mapbox.services.android.telemetry.service.TelemetryService" />

If you get an error related to TelemetryService then please check it's there.

Usage

Demo app (XML + TypeScript)

If you want a quickstart, see the demo in this repository. It shows you how to draw a map in XML and JS with almost all possible options.

Demo app (Angular)

There is also the beginnings of an Angular demo in demo-angular in this repository.

Declaring a map in the view

XML

You can instantiate a map from JS or TS. As the map is yet another view component it will play nice with any NativeScript layout you throw it in. You can also easily add multiple maps to the same page or to different pages in any layout you like.

A simple layout could look like this:

Could be rendered by a definition like this:

<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:map="nativescript-mapbox" navigatingTo="navigatingTo">
  <StackLayout>
    <Label text="Nice map, huh!" class="title"/>
    <ContentView height="240" width="240">
      <map:MapboxView
          accessToken="your_token"
          mapStyle="traffic_night"
          latitude="52.3702160"
          longitude="4.8951680"
          zoomLevel="3"
          showUserLocation="true"
          mapReady="onMapReady">
      </map:MapboxView>
    </ContentView>
  </StackLayout>
</Page>

Angular

Component:

import { registerElement } from "nativescript-angular/element-registry";
registerElement("Mapbox", () => require("nativescript-mapbox").MapboxView);

View:

  <ContentView height="100%" width="100%">
    <Mapbox
        accessToken="your_token"
        mapStyle="traffic_day"
        latitude="50.467735"
        longitude="13.427718"
        hideCompass="true"
        zoomLevel="18"
        showUserLocation="false"
        disableZoom="false"
        disableRotation="false"
        disableScroll="false"
        disableTilt="false"
        (mapReady)="onMapReady($event)">
    </Mapbox>
  </ContentView>

Available XML/Angular options

All currently supported options for your XML based map are (don't use other properties - if you need styling wrap the map in a ContentView and apply things like width to that container!):

option default description
accesstoken - see 'Prerequisites' above
delay 0 A delay in milliseconds - you can set this to have better control over when Mapbox is invoked so it won't clash with other computations your app may need to perform.
mapStyle streets streets, light, dark, satellite_streets, satellite, traffic_day, traffic_night, an URL starting with mapbox:// or pointing to a custom JSON definition (http://, https://, or local relative to nativescript app path ~/)
latitude - Set the center of the map by passing this in
longitude - .. and this as well
zoomLevel 0 0-20
showUserLocation false Requires location permissions on Android which you can remove from AndroidManifest.xml if you don't need them
hideCompass false Don't show the compass in the top right corner during rotation of the map
hideLogo false Mapbox requires false if you're on a free plan
hideAttribution true Mapbox requires false if you're on a free plan
disableZoom false Don't allow the user to zoom in or out (pinch and double-tap)
disableRotation false Don't allow the user to rotate the map (two finger gesture)
disableScroll false Don't allow the user to move the center of the map (one finger drag)
disableTilt false Don't allow the user to tilt the map (two finger drag up or down)
mapReady - The name of a callback function you can declare to interact with the map after it has been drawn
moveBeginEvent - The name of a function to be called when the map is moved.
locationPermissionGranted - The name of a callback function you can declare to get notified when the user granted location permissions
locationPermissionDenied - The name of a callback function you can declare to get notified when the user denied location permissions (will never fire on iOS because there's nothing to deny)

Want to add markers?

This is where that last option in the table above comes in - mapReady. It allows you to interact with the map after it has been drawn to the page.

Open main-page.[js|ts] and add this (see addMarkers further below for the full marker API):

var mapbox = require("nativescript-mapbox");

function onMapReady(args) {
  // you can tap into the native MapView objects (MGLMapView for iOS and com.mapbox.mapboxsdk.maps.MapView for Android)
  var nativeMapView = args.ios ? args.ios : args.android;
  console.log("Mapbox onMapReady for " + (args.ios ? "iOS" : "Android") + ", native object received: " + nativeMapView);

  // .. or use the convenience methods exposed on args.map, for instance:
  args.map.addMarkers([
    {
      lat: 52.3602160,
      lng: 4.8891680,
      title: 'One-line title here',
      subtitle: 'Really really nice location',
      selected: true, // makes the callout show immediately when the marker is added (note: only 1 marker can be selected at a time)
      onCalloutTap: function(){console.log("'Nice location' marker callout tapped");}
    }]
  );
}

exports.onMapReady = onMapReady;

.. or want to set the viewport bounds?

var mapbox = require("nativescript-mapbox");

function onMapReady(args) {
  args.map.setViewport(
      {
        bounds: {
          north: 52.4820,
          east: 5.1087,
          south: 52.2581,
          west: 4.6816
        },
        animated: true
      }
  );
}

exports.onMapReady = onMapReady;

The methods you can invoke like this from an XML-declared map are: addMarkers, setViewport, removeMarkers, getCenter, setCenter, getZoomLevel, setZoomLevel, getViewport, getTilt, setTilt, setMapStyle, animateCamera, addPolygon, removePolygons, addPolyline, removePolylines, getUserLocation, trackUser, setOnMapClickListener, setOnMapLongClickListener and destroy.

Check out the usage details on the functions below.

Declaring a map programmatically

Add a container to your view XML where you want to programmatically add the map. Give it an id.

<ContentView id="mapContainer" />

show

    const contentView : ContentView = <ContentView>page.getViewById( 'mapContainer' );

    const settings = {

      // NOTE: passing in the container here.

      container: contentView,
      accessToken: ACCESS_TOKEN,
      style: MapStyle.LIGHT,
      margins: {
        left: 18,
        right: 18,
        top: isIOS ? 390 : 454,
        bottom: isIOS ? 50 : 8
      },
      center: {
        lat: 52.3702160,
        lng: 4.8951680
      },
      zoomLevel: 9, // 0 (most of the world) to 20, default 0
      showUserLocation: true, // default false
      hideAttribution: true, // default false
      hideLogo: true, // default false
      hideCompass: false, // default false
      disableRotation: false, // default false
      disableScroll: false, // default false
      disableZoom: false, // default false
      disableTilt: false, // default false
      markers: [
        {
          id: 1,
          lat: 52.3732160,
          lng: 4.8941680,
          title: 'Nice location',
          subtitle: 'Really really nice location',
          iconPath: 'res/markers/green_pin_marker.png',
          onTap: () => console.log("'Nice location' marker tapped"),
          onCalloutTap: () => console.log("'Nice location' marker callout tapped")
        }
      ]
    };

    console.log( "main-view-model:: doShow(): creating new MapboxView." );

    const mapView = new MapboxView();

    // Bind some event handlers onto our newly created map view. 

    mapView.on( 'mapReady', ( args : any ) => {

      console.log( "main-view-model: onMapReady fired." );

      // this is an instance of class MapboxView

      this.mapboxView = args.map;

      // get a reference to the Mapbox API shim object so we can directly call its methods.

      this.mapbox = this.mapboxView.getMapboxApi();

      this.mapbox.setOnMapClickListener( point => {
        console.log(`>> Map clicked: ${JSON.stringify(point)}`);
        return true;
      });

      this.mapbox.setOnMapLongClickListener( point => {
        console.log(`>> Map longpressed: ${JSON.stringify(point)}`);
        return true;
      });

      this.mapbox.setOnScrollListener((point: LatLng) => {
        // console.log(`>> Map scrolled`);
      });

      this.mapbox.setOnFlingListener(() => {
        console.log(`>> Map flinged"`);
      }).catch( err => console.log(err) );

    });

    mapView.setConfig( settings );
    contentView.content = mapView;
  

hide

All further examples assume mapbox has been required. Also, all functions support promises, but we're leaving out the .then() stuff for brevity where it doesn't add value.

  mapbox.hide();

unhide

If you previously called hide() you can quickly unhide the map, instead of redrawing it (which is a lot slower and you loose the viewport position, etc).

  mapbox.unhide();

destroy 💥

To clean up the map entirely you can destroy instead of hide it:

  mapbox.destroy();

setMapStyle

You can update the map style after you've loaded it.

With Mapbox Android SDK 6.1.x (used in plugin version 4.1.0) I've seen Android crash a few seconds after this has been used, so test this well and perhaps don't use it when in doubt.

  mapbox.setMapStyle(mapbox.MapStyle.DARK);

addMarkers

  import { MapboxMarker } from "nativescript-mapbox";

  const firstMarker = <MapboxMarker>{ //cast as a MapboxMarker to pick up helper functions such as update()
    id: 2, // can be user in 'removeMarkers()'
    lat: 52.3602160, // mandatory
    lng: 4.8891680, // mandatory
    title: 'One-line title here', // no popup unless set
    subtitle: 'Infamous subtitle!',
    // icon: 'res://cool_marker', // preferred way, otherwise use:
    icon: 'http(s)://website/coolimage.png', // from the internet (see the note at the bottom of this readme), or:
    iconPath: 'res/markers/home_marker.png',
    selected: true, // makes the callout show immediately when the marker is added (note: only 1 marker can be selected at a time)
    onTap: marker => console.log("Marker tapped with title: '" + marker.title + "'"),
    onCalloutTap: marker => alert("Marker callout tapped with title: '" + marker.title + "'")
  };

  mapbox.addMarkers([
    firstMarker,
    {
      // more markers..
    }
  ])

Updating markers

Plugin version 4.2.0 added the option to update makers. Just call update on the MapboxMarker reference you created above. You can update the following properties (all but the icon really):

  firstMarker.update({
    lat: 52.3622160,
    lng: 4.8911680,
    title: 'One-line title here (UPDATE)',
    subtitle: 'Updated subtitle',
    selected: true, // this will trigger the callout upon update
    onTap: (marker: MapboxMarker) => console.log(`UPDATED Marker tapped with title: ${marker.title}`),
    onCalloutTap: (marker: MapboxMarker) => alert(`UPDATED Marker callout tapped with title: ${marker.title}`)
  })

removeMarkers

You can either remove all markers by not passing in an argument, or remove specific marker id's (which you specified previously).

  // remove all markers
  mapbox.removeMarkers();

  // remove specific markers by id
  mapbox.removeMarkers([1, 2]);

setViewport

If you want to for instance make the viewport contain all markers you can set the bounds to the lat/lng of the outermost markers using this function.

  mapbox.setViewport(
      {
        bounds: {
          north: 52.4820,
          east: 5.1087,
          south: 52.2581,
          west: 4.6816
        },
        animated: true // default true
      }
  )

getViewport

  mapbox.getViewport().then(
      function(result) {
        console.log("Mapbox getViewport done, result: " + JSON.stringify(result));
      }
  )

setCenter

  mapbox.setCenter(
      {
        lat: 52.3602160, // mandatory
        lng: 4.8891680, // mandatory
        animated: false // default true
      }
  )

getCenter

Here the promise callback makes sense, so adding it to the example:

  mapbox.getCenter().then(
      function(result) {
        console.log("Mapbox getCenter done, result: " + JSON.stringify(result));
      },
      function(error) {
        console.log("mapbox getCenter error: " + error);
      }
  )

setZoomLevel

  mapbox.setZoomLevel(
      {
        level: 6.5, // mandatory, 0-20
        animated: true // default true
      }
  )

getZoomLevel

  mapbox.getZoomLevel().then(
      function(result) {
        console.log("Mapbox getZoomLevel done, result: " + JSON.stringify(result));
      },
      function(error) {
        console.log("mapbox getZoomLevel error: " + error);
      }
  )

animateCamera

  // this is a boring triangle drawn near Amsterdam Central Station
  mapbox.animateCamera({
    // this is where we animate to
    target: {
        lat: 52.3732160,
        lng: 4.8941680
    },
    zoomLevel: 17, // Android
    altitude: 2000, // iOS (meters from the ground)
    bearing: 270, // Where the camera is pointing, 0-360 (degrees)
    tilt: 50,
    duration: 5000 // default 10000 (milliseconds)
  })

setTilt (Android only)

  mapbox.setTilt(
      {
        tilt: 40, // default 30 (degrees angle)
        duration: 4000 // default 5000 (milliseconds)
      }
  )

getTilt (Android only)

  mapbox.getTilt().then(
      function(tilt) {
        console.log("Current map tilt: " +  tilt);
      }
  )

getUserLocation

If the user's location is shown on the map you can get their coordinates and speed:

  mapbox.getUserLocation().then(
      function(userLocation) {
        console.log("Current user location: " +  userLocation.location.lat + ", " + userLocation.location.lng);
        console.log("Current user speed: " +  userLocation.speed);
      }
  )

trackUser

In case you're showing the user's location, you can have the map track the position. The map will continuously move along with the last known location.

  mapbox.trackUser({
    mode: "FOLLOW_WITH_HEADING", // "NONE" | "FOLLOW" | "FOLLOW_WITH_HEADING" | "FOLLOW_WITH_COURSE"
    animated: true
  });

addSource

https://docs.mapbox.com/mapbox-gl-js/api/#map#addsource

Adds a vector to GeoJSON source to the map.

  mapbox.addSource( id, {
    type: 'vector',
    url: 'url to source'
  } );

-or-

  mapbox.addSource( id, {
    'type': 'geojson',
    'data': {
      "type": "Feature",
        "geometry": {
        "type": "LineString",
          "coordinates": [ [ lng, lat ], [ lng, lat ], ..... ]
        }
      }
    }
  );

removeSource

Remove a source by id

  mapbox.removeSource( id );

addLayer

NOTE: For version 5 the API for addLayer() has changed and is now a subset of the web-gl-js API.

https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers

To add a line:

  mapbox.addLayer({
    'id': someid,
    'type': 'line',
    'source': {
      'type': 'geojson',
      'data': {
        "type": "Feature",
          "geometry": {
          "type": "LineString",
            "coordinates": [ [ lng, lat ], [ lng, lat ], ..... ]
          }
        }
      }
    },
    'layout': {
      'line-cap': 'round',
      'line-join': 'round'
    },    
    'paint': {
      'line-color': '#ed6498',
      'line-width': 5,
      'line-opacity': .8,
      'line-dash-array': [ 1, 1, 1, ..]
    }
  });

To add a circle:

  mapbox.addLayer({
    "id": someid,
    "type": 'circle',
    "radius-meters": 500,   // FIXME: radius in meters used for in-circle click detection. 
    "source": {
      "type": 'geojson',
      "data": {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [ lng, lat ]
        }
      }
    }, 
    "paint": {
      "circle-radius": {
        "stops": [
          [0, 0],
          [20, 8000 ]
        ],
        "base": 2
      },
      'circle-opacity': 0.05,
      'circle-color': '#ed6498',
      'circle-stroke-width': 2,
      'circle-stroke-color': '#ed6498'
    } 
  });

Source may be a geojson or vector source description or may be the id of a source added using addSource()

removeLayer

Remove a layer added with addLayer() by id.

  mapbox.removeLayer( id );

addLinePoint

Dynamically add a point to a line.

  mapbox.addLinePoint( <id of line layer>, lnglat )

where lnglat is an array of two points, a longitude and a latitude.

addPolygon

Draw a shape. Just connect the dots like we did as a toddler.

The first person to tweet a snowman drawn with this function gets a T-shirt.

  // after adding this, scroll to Amsterdam to see a semi-transparent red square
  mapbox.addPolygon(
      {
        id: 1, // optional, can be used in 'removePolygons'
        fillColor: new Color("red"),
        fillOpacity: 0.7,

        // stroke-related properties are only effective on iOS
        strokeColor: new Color("green"),
        strokeWidth: 8,
        strokeOpacity: 0.5,

        points: [
          {
            lat: 52.3923633970718,
            lng: 4.902648925781249
          },
          {
            lat: 52.35421556258807,
            lng: 4.9308013916015625
          },
          {
            lat: 52.353796172573944,
            lng: 4.8799896240234375
          },
          {
            lat: 52.3864966440161,
            lng: 4.8621368408203125
          },
          {
            lat: 52.3923633970718,
            lng: 4.902648925781249
          }
        ]
      })
      .then(result => console.log("Mapbox addPolygon done"))
      .catch((error: string) => console.log("mapbox addPolygon error: " + error));

removePolygons

You can either remove all polygons by not passing in an argument, or remove specific polygon id's (which you specified previously).

  // remove all polygons
  mapbox.removePolygons();

  // remove specific polygons by id
  mapbox.removePolygons([1, 2]);

addPolyline

Deprecated. Use addLayer() instead.

Draw a polyline. Connect the points given as parameters.

  // Draw a two segment line near Amsterdam Central Station
  mapbox.addPolyline({
      id: 1, // optional, can be used in 'removePolylines'
      color: '#336699', // Set the color of the line (default black)
      width: 7, // Set the width of the line (default 5)
      opacity: 0.6, //Transparency / alpha, ranging 0-1. Default fully opaque (1).
      points: [
          {
              'lat': 52.3833160, // mandatory
              'lng': 4.8991780 // mandatory
          },
          {
              'lat': 52.3834160,
              'lng': 4.8991880
          },
          {
              'lat': 52.3835160,
              'lng': 4.8991980
          }
      ]
  });

removePolylines

Deprecated. Use removeLayer() instead.

You can either remove all polylines by not passing in an argument, or remove specific polyline id's (which you specified previously).

  // remove all polylines
  mapbox.removePolylines();

  // remove specific polylines by id
  mapbox.removePolylines([1, 2]);

addSource

Add a source that can be used by addLayer. Note only vector type is currently supported.

  mapbox.addSource(
    id: "terrain-source", // required
    type: "vector", // supported types: vector
    url: "mapbox://mapbox.mapbox-terrain-v2"
  );

removeSource

Remove a source by id.

  mapbox.removeSource("terrain-source");

addLayer

Add a layer from a source to the map. Note only circle, fill and line types are currently supported.

  mapbox.addLayer(
    id: "terrain-data",  // required
    source: "terrain-source",  // id of source
    sourceLayer: "contour",  // id of layer from source
    type: "line", // supported types: circle, fill, line
    lineJoin: "round",
    lineCap: "round",
    lineColor: "#ff69b4",
    lineWidth: 1,
  );

removeLayer

Remove a layer by id.

  mapbox.removeLayer("terrain-data");

setOnMapClickListener

Add a listener to retrieve lat and lng of where the user taps the map (not a marker).

  mapbox.setOnMapClickListener((point: LatLng) => {
    console.log("Map clicked at latitude: " + point.lat + ", longitude: " + point.lng);
  });

setOnMapLongClickListener

Add a listener to retrieve lat and lng of where the user longpresses the map (not a marker).

  mapbox.setOnMapLongClickListener((point: LatLng) => {
    console.log("Map longpressed at latitude: " + point.lat + ", longitude: " + point.lng);
  });

setOnScrollListener

Add a listener to retrieve lat and lng of where the user scrolls to on the map.

  mapbox.setOnScrollListener((point?: LatLng) => {
    console.log("Map scrolled to latitude: " + point.lat + ", longitude: " + point.lng);
  });

Offline maps

For situations where you want the user to pre-load certain regions you can use these methods to create and remove offline regions.

Important read: the offline maps documentation by Mapbox.

downloadOfflineRegion

This example downloads the region 'Amsterdam' on zoom levels 9, 10 and 11 for map style 'outdoors'.

  mapbox.downloadOfflineRegion(
    {
      accessToken: accessToken, // required for Android in case no map has been shown yet
      name: "Amsterdam", // this name can be used to delete the region later
      style: mapbox.MapStyle.OUTDOORS,
      minZoom: 9,
      maxZoom: 11,
      bounds: {
        north: 52.4820,
        east: 5.1087,
        south: 52.2581,
        west: 4.6816
      },
      // this function is called many times during a download, so
      // use it to show an awesome progress bar!
      onProgress: function (progress) {
        console.log("Download progress: " + JSON.stringify(progress));
      }
    }
  ).then(
    function() {
      console.log("Offline region downloaded");
    },
    function(error) {
      console.log("Download error: " + error);
    }
  );

Advanced example: download the current viewport

Grab the viewport with the mapbox.getViewport() function and download it at various zoom levels:

  // I spare you the error handling on this one..
  mapbox.getViewport().then(function(viewport) {
    mapbox.downloadOfflineRegion(
      {
        name: "LastViewport", // anything you like really
        style: mapbox.MapStyle.LIGHT,
        minZoom: viewport.zoomLevel,
        maxZoom: viewport.zoomLevel + 2, // higher zoom level is lower to the ground
        bounds: viewport.bounds,
        onProgress: function (progress) {
          console.log("Download %: " + progress.percentage);
        }
      }
    );
  });

listOfflineRegions

To help you manage offline regions there's a listOfflineRegions function you can use. You can then fi. call deleteOfflineRegion (see below) and pass in the name to remove any cached region(s) you like.

  mapbox.listOfflineRegions({
    // required for Android in case no map has been shown yet
    accessToken: accessToken
  }).then(
    function(regions) {
      console.log(JSON.stringify(JSON.stringify(regions));
    },
    function(error) {
      console.log("Error while listing offline regions: " + error);
    }
  );

deleteOfflineRegion

You can remove regions you've previously downloaded. Any region(s) matching the name param will be removed locally.

  mapbox.deleteOfflineRegion({
    name: "Amsterdam"
  }).then(
    function() {
      console.log("Offline region deleted");
    },
    function(error) {
      console.log("Error while deleting an offline region: " + error);
    }
  );

Permissions

hasFineLocationPermission / requestFineLocationPermission

On Android 6 you need to request permission to be able to show the user's position on the map at runtime when targeting API level 23+. Even if the uses-permission tag for ACCESS_FINE_LOCATION is present in AndroidManifest.xml.

You don't need to do this with plugin version 2.4.0+ as permission is request when required while rendering the map. You're welcome :)

Note that hasFineLocationPermission will return true when:

  • You're running this on iOS, or
  • You're targeting an API level lower than 23, or
  • You're using Android < 6, or
  • You've already granted permission.
  mapbox.hasFineLocationPermission().then(
      function(granted) {
        // if this is 'false' you probably want to call 'requestFineLocationPermission' now
        console.log("Has Location Permission? " + granted);
      }
  );

  // if no permission was granted previously this will open a user consent screen
  mapbox.requestFineLocationPermission().then(
      function() {
        console.log("Location permission requested");
      }
  );

Note that the show function will also check for permission if you passed in showUserLocation : true. If you didn't request permission before showing the map, and permission was needed, the plugin will ask the user permission while rendering the map.

Using marker images from the internet

If you specify icon: 'http(s)://some-remote-image', then on iOS you'll need to whitelist the domain. Google for iOS ATS for detailed options, but for a quick test you can add this to app/App_Resources/iOS/Info.plist:

	<key>NSAppTransportSecurity</key>
	<dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
	</dict>

nativescript-mapbox's People

Contributors

ahalls avatar bradmartin avatar codex- avatar dogabudak avatar eddyverbruggen avatar equisetum avatar gcuencam avatar jastmicro avatar keerl avatar lbaey-mobizel avatar lochstar avatar madmas avatar marvinernst-cognitio avatar neomac avatar permpkin avatar piotrilski avatar rohanrichards avatar seros00 avatar sk0pe avatar steinerjakob avatar thatrainbowbear avatar ticdenis avatar yermo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-mapbox's Issues

Create map as XML element?

For ease of positioning, curious if it could be possible to instantiate the map as an XML element instead of calling the javascript and explicitly marking coordinates?

iOS crash - this._mapLoadedCallback is not a function

version 2.3

Exception:

file:///app/tns_modules/nativescript-mapbox/mapbox.js:794:28: JS ERROR TypeError: this._mapLoadedCallback is not a function. (In 'this._mapLoadedCallback()', 'this._mapLoadedCallback' is undefined)

I haven't pinned down when/why this throws but saw it once when I navigated to the page with the map and then the map worked fine the next time (I think) sorry I don't have much more right now.

Question: marker tap on iOS simulator

Unfortunately, I don't have an iOS device handy right now. On the simulator should/do the marker taps work? I have the markers rendered for locations and Android everything works fine so just curious if it should be working with the marker opening the callOut so I can get to that event.

Not working with Angular2/Typescript?

I'm trying to use this plugin in an angular 2 typescript project.

I added the plugin via the tns plugin add command and imported it with var mapbox = require('nativescript-mapbox'); in my component.ts file.
In the angular 2 ngOnInit event i call mapbox.show({ accessToken: '...' }); but i'm getting the following error:
Uncaught (in promise): TypeError: Cannot read property 'mapboxsdk' of undefined

Any idea how to solve this?

Question: remove the polyline

I didn't find anything in the native android sdk, curious if you've seen support to remove a previously drawn line or have any suggestion on a good approach for that?

I've drawn a line and plotted the markers, successfully removed the markers but now need to remove the line so it's not there for a new line (route) with the new markers plotted, hope that makes sense. I'll dig around later and see but just curious. Thanks.

Custom Styles In Maps

Hi.

MapBox SDK allows you to set styles for maps. In your excellent implementation, for iOs and Android, styles are established through an enum with default styles.

The SDK also allows you to define your own styles, created with MapBox Studio, setting the style to map through the styleUrl function.

It would be quite useful this capability in the library.

Thank you!

Unable to start activity ComponentInfo{org.nativescript.mapboxdemo/com.tns.NativeScriptActivity}

NativeScript: 1.6.2

Today I have checkout your current mapbox demo but I'cant get it running on my system. I get this error (only a part of fully error text, couldn't copy it all).

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.mapboxdemo/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
Calling js method onCreate failed

TypeError: Cannot read property 'widgets' of undefined
File: "/data/data/org.nativescript.mapboxdemo/files/app/tns_modules/ui/frame/frame.js, line: 327, column: 39

StackTrace: 
    Frame: function:'NativeActivity.onCreate', file:'/data/data/org.nativescript.mapboxdemo/files/app/tns_modules/ui/frame/frame.js', line: 327, column: 40


    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native M[...]

Generally I have amount of experience in software development, but I'm new to nativescript. Maybe is a really simple fault and I don't recognize it ...

Can't find variable: MGLOfflineStorage

Thanks for building this awesome plugin!

I followed the steps what they do during NativeScript 2.3 webinar by using Angular 2 typescript with NativeScript to build an ios app.

https://youtu.be/WQktviwAGb0?t=25m3s

I have defined the "mapbox", "token" variable and loadMap function in the imagesList.component.ts.

Once I run the app in the IOS simulator, I got this error:

JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
JS: ReferenceError: Can't find variable: MGLOfflineStorage

I have generated a token with everything ticked on mapbox.com after I registered an account.

Plugin size impact

The plugin significantly the output .apk , with about +10mb...Is this actually expected?

NullPointerException when running on Android

Hey @EddyVerbruggen,

Just tried out the plugin and it works great on iOS, but I’m getting the following error on Android:

JS: Error in mapbox.show: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
JS:     android.view.ViewConfiguration.get(ViewConfiguration.java:359)
JS:     android.view.View.<init>(View.java:3587)
JS:     android.view.View.<init>(View.java:3682)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:497)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:493)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:489)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:485)
JS:     android.widget.FrameLayout.<init>(FrameLayout.java:103)
JS:     com.mapbox.mapboxsdk.views.MapView.<init>(MapView.java:685)

Any idea what’s up? I’m testing on an Android 5.x emulator and I have showUserLocation turned off. Here’s the code I’m using:

mapbox.show({
    accessToken: "---MY TOKEN---",
    style: mapbox.MapStyle.EMERALD,
    margins: {
        left: 0,
        right: 0,
        top: 0,
        bottom: 300
    },
    showUserLocation: false,
    hideAttribution: true,
    hideLogo: true,
    hideCompass: true
});

Thanks.

Allow to use icon path from resource

Cannot find a way to use iconPath from a resource (as res://) to use native methods for selecting the best image for the current device screen density.

Not working

when i click show the app stops with an error

Change map style method

I've not looked into the source of the SDKs to see if it's possible, but being able to change the map style dynamically would be a nice feature 😄 .

Specifcally looking to do against the XML rendered map after the fact.

Scenario: user loads the app doesn't like the default style or is hard on their eyes so they can try out 'dark'.

onTap/onCalloutTap not working from XML declared map

 <!-- MapBox -->
<map:Mapbox row="1" col="0" rowSpan="5" colSpan="5" id="map" disableRotation="true" mapStyle="streets" mapReady="{{ onMapReady }}" latitude="39.8282" longitude="-98.5795" zoomLevel="2.42" showUserLocation="true" hideLogo="true" hideAttribution="true" accessToken="myKey"></map:Mapbox>
 /**
     * onMapReady
     */
    public onMapReady(args) {

        this._map = args.map;

        let opts: Array<MapBox.AddMarkersOption> = [{
            lat: 36.3884,
            lng: -86.4467,
            title: 'Gallatin, TN',
            subtitle: 'Hello World!',
            onTap: function (marker) {
                console.log('MARKER: ' + marker);
                console.log('TAP 1');
            },
            onCalloutTap: function () { console.log("'Nice location' marker callout tapped"); }
        }];
        args.map.addMarkers(opts);

    }

Marker is present on the map but tapping the marker and the callout do not log anything.

Cannot Place UI elements over viewport

I can't figure out how to draw some Ui elements over the map.
I was using google maps and cordova previously and I could "draw" over a map since it was drawn within a div container.

In this case I don't know which element, if any I can apply some css to in order to draw over the map. Is it even possible to do so?

Support for Marker Image URLs

Currently, the plugin only loads local resources as marker images. It would be nice if we could also specify a URL to use for the marker.

Adding Polylines

Hi.
I tried to add some polylines to the map but this resulted in an error.

Cannot find variable MGLMapViewDelegate

When I attempt to compile this plugin in my nativescript app, the compiler reports Cannot find variable MGLMapViewDelegate. Any ideas how I can get past this?

Offline and Element overlay capability question

Hello there, i'm starting a new project for which I need to use maps on both ios and android. However I need to show images overtop of the map sometimes, is it possible to show ui elements overtop of the map? (this is difficult for some hybrid frameworks)

Also, MapBox native libraries have support for offline usage and I was wondering if this is supported yet.

Kind regards.

Enhancement: expose other methods to XML map

Several much needed methods on the XML declared maps:

  • removeMarkers
  • setCenter
  • setZoomLevel
  • addPolyline

All of them would be great of course but these would seem to cover a lot of use cases for having dynamic capabilites of the map once its rendered for navigational purposes.

Mapbox-4.0.0 : Can't add a marker : markerOptions.title is not a function

Hi, I've got an issue with your mapbox-4.0.0 branch. I know it's under development, but I needed a mapbox 4 version to make it run on 64bits devices so I gave it a shot.

I succeeded to make the map show up by adding :
<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />
in the android manifest. I don't know why the one in the plugin doesn't work.

Then I tried to put a marker on the map but I go this error :

JS: Error in mapbox.addMarkers: TypeError: markerOptions.title is not a function
JS: EXCEPTION: Error: Uncaught (in promise): TypeError: markerOptions.title is not a function
JS: STACKTRACE:
JS: Error: Uncaught (in promise): TypeError: markerOptions.title is not a function
JS: at resolvePromise (/data/data/org.nativescript.gpadri/files/app/tns_modules/zone.js/dist/zone-node.js:496:32)
JS: at /data/data/org.nativescript.gpadri/files/app/tns_modules/zone.js/dist/zone-node.js:473:14
JS: at /data/data/org.nativescript.gpadri/files/app/tns_modules/nativescript-mapbox/mapbox.js:189:7
JS: at new ZoneAwarePromise (/data/data/org.nativescript.gpadri/files/app/tns_modules/zone.js/dist/zone-node.js:542:30)
JS: at Object.mapbox.addMarkers (/data/data/org.nativescript.gpadri/files/app/tns_modules/nativescript-mapbox/mapbox.js:175:10)
JS: at GeotrackPage.addMarkers (/data/data/org.nativescript.gpadri/files/app/geotrack/geotrack.components.js:66:16)
JS: at DebugAppView._View_GeotrackPage0._handle_tap_12_0 (GeotrackPage.template.js:92:28)
JS: at /data/data/org.nativescript.gpadri/files/app/tns_modules/@angular/core/src/linker/view.js:316:24
JS: at ZoneDelegate.invoke (/data/data/org.nativescript.gpadri/files/app/tns_modules/zone.js/dist/zone-node.js:281:29)
JS: at Object.NgZoneImpl.inner.inner.fork.onInvoke (/data/data/org.nativescript.gpadri/files/app/tns_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
JS: Unhandled Promise rejection: markerOptions.title is not a function ; Zone: angular ; Task: ; Value: TypeError: markerOptions.title is not a function
JS: Error: Uncaught (in promise): TypeError: markerOptions.title is not a function

By checking the mapbox documentation, your implementation looks good. I can't figure out why it doesn't want to find the title function.
I saw some Todo around so maybe it's something that you already know.

Remove Markers Function

Hi.

Checking the functionality of the library I see that there is a method that adds markers to the map. It strikes me that there is no method to clear the contents of the markers, or remove any of them.

I think it would be very useful that the library existed a similar method.

Happy coding!

Enhancement/Request: timeout when loading XML map

The mapbox loading into a view can cause an app to hang for half a second or so. When you declare the map in XML and navigate to the page you have no way to delay that execution so it doesn't cause an interruption to the navigation transition.

A simple solution would be to add a property on the XML view, such as delayMapInit and then accept a value in milliseconds, so then we can make sure the navigation transition has completed before the map constructor is started which isn't the smoothest process. Let me know your thoughts @EddyVerbruggen, you might have a better idea since you know the SDKs better than I for mapbox.

Mapbox not working

TNS Version: 2.1.1

When I run "tns livesync ios --emulator --watch" I get the following error messages:

Aug 5 14:51:44 Shivas-Air cngMobileApp[70894]: 1 0x45b82c -[TNSRuntime executeModule:]
Aug 5 14:51:44 Shivas-Air cngMobileApp[70894]: 2 0x8c60b main
Aug 5 14:51:44 Shivas-Air cngMobileApp[70894]: 3 0x3cc5a25 start
Aug 5 14:51:44 Shivas-Air cngMobileApp[70894]: file:///app/tns_modules/nativescript-mapbox/mapbox.js:7:20: JS ERROR ReferenceError: Can't find variable: MGLOfflineStorage
Aug 5 14:51:44 Shivas-Air com.apple.CoreSimulator.SimDevice.20124C04-21CD-486F-9DFE-439512DD31BD.launchd_sim65148: Service exited due to signal: Segmentation fault: 11

I installed nativescript-mapbox using "tns plugin add nativescript-mapbox". Can you assist me as to what could be causing the issue? Thanks.

Map not showing on Android 5.0.1 device

I'm getting exception:

mapbox show error: Error: java.lang.UnsatisfiedLinkError: com.mapbox.mapboxsdk.views.NativeMapView
com.mapbox.mapboxsdk.views.MapView.initialize(MapView.java:787)
com.mapbox.mapboxsdk.views.MapView.(MapView.java:690)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
com.tns.Runtime.callJSMethod(Runtime.java:712)
com.tns.Runtime.callJSMethod(Runtime.java:693)
com.tns.Runtime.callJSMethod(Runtime.java:683)
com.tns.gen.java.lang.Runnable_ftns_modules_timer_timer_l15_c20__.run(Runnable_ftns_modules_timer_timer_l15_c20__.java:10)
android.os.Handler.handleCallback(Handler.java:739)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:135)
android.app.ActivityThread.main(ActivityThread.java:5538)
java.lang.reflect.Method.invoke(Native Method)
java.lang.reflect.Method.invoke(Method.java:372)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:958)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:753)

In /tns_modules/nativescript-mapbox/mapbox.js (.android) when trying to create mapView = new com.mapbox.mapboxsdk.views.MapView(application.android.context, settings.accessToken);

I'm with {N} CLI 2.0.1 and modules 2.0.0 version. The funny thing is that the same application works on Nexus 4 (5.0.1), Nexus 5 (6.0.1) , Samsung G. S4 (5.0.1) but it crashes on 3 different Huawei P8 devices with (5.0.1). Can you point me to something?
Thanks

Empty black box on iOS

Hey @EddyVerbruggen,

I tried out this plugin today and it works great on Android, but on iOS I’m unfortunately not seeing a map—all I see is a black box.

img_0837

I’ve tried your demo and my own custom app and I get the same. Any idea what might be up here? The logs tell me that I have permissions and mapbox.show doesn’t log any errors, so I’m not sure what’s up.

Thanks.

Nativescript Angular 2 issue while using MapBox inside the HTML

The case is the following.
I have registered new Element inside the main.ts file using registerElement method.

main.ts file

var map = require("nativescript-mapbox");
registerElement("Map", () => map.Mapbox);

Then I have try to use this element inside my HTML file as follow.
app.component.html

<GridLayout>
<Map
    accessToken="ACCESS_TOKEN"
    width="250" 
    height="150"  
    latitude="52.3702160"
    longitude="4.8951680"
    zoomLevel="3"
    mapStyle="light"
    hideAttribution="false"
   showUserLocation="true"
   hideCompass="false"></Map>
</GridLayout>

However on the screen will be show black box even, when the accessToken has been insert. The only way to use this component inside the NS Angular 2 project is to do from code behind, but the Component will be displayed above the other components.

[Question] add Marker on tap

Hello, I am creating the map programmatically. I'd like to add a marker on tapped location on the map. I know how to add markers to the map programmatically, but don't understand how to register a tap handler and get tapped coordinates. Can you point me to the solution please?

iOS Marker added using addMarkers is jumpy when zoomin in/out

Looks like the marker is fixed position relative to the Map. This doesn't happen when I set the markers in show method. Happens only for the markers added after showing the map. I need to do this to dynamically add markers. Any one else have this problem and how did you sort this out ?

Note: After adding the markers I am calling setCenter method too..

Marker Code:

mapbox.addMarkers({
    lat: latitude, // mandatory
    lng: longitude, // mandatory
    title: 'One-line title here', // no popup unless set
    subtitle: 'Infamous subtitle!' // can't span multiple lines, so keep it short and sweet
}).then(
    (result) => {
        console.log("Mapbox Marker done: " + latitude + ', ' + longitude);
        // this.animateCamera(latitude, longitude);
    },
    (error) => {console.log("Mapbox Marker error: " + error)}
);

Set Center Code:

mapbox.setCenter({
    lat: latitude,
    lng: longitude,
    animated: true
}).then(
    (result) => {
        console.log("Mapbox setCenter done: " + latitude + ', ' + longitude);
        // this.animateCamera(latitude, longitude);
    },
    (error) => {console.log("mapbox setCenter error: " + error)}
);

Does Mapbox measure this plugin's usage as a native app?

Hi

Great plugin, I just have a quick question.

Mapbox plans place limits based on either "map views" or "mobile users".
The starter plan being: 50,000 map views / mo, or 50,000 mobile users / mo

The Mapbox documentation specifically refers to native apps when it talks about measuring mobile users. Does this plugin interact with Mapbox like a native app? (i.e measuring mobile users) or does this affect map views instead?

Thanks :)

ShowUserLocation not working

Hi.

I cannot get the user location shown on the map properly. Is there anything that I am missing right now?

import {Component, OnInit} from "@angular/core";
import {Page} from "ui/page";

var mapbox = require("nativescript-mapbox");
var geolocation = require("nativescript-geolocation");

const accessToken: string = "...";

@Component({
    selector: "my-app",
    templateUrl: "app.component.html"
})
export class AppComponent implements OnInit {
    constructor(private page: Page) {
        this.page.actionBarHidden = true;
    }

    ngOnInit() {
        var that = this;

        // get geolocation permitted
        if (!geolocation.isEnabled()) {
            geolocation.enableLocationRequest();
        }

        mapbox.hasFineLocationPermission().then(
            function(granted) {
                // if this is 'false' you probably want to call 'requestFineLocationPermission' now
                console.log("Has Location Permission? " + granted);
        });

        // if no permission was granted previously this will open a user consent screen
        mapbox.requestFineLocationPermission().then(
            function() {
                console.log("Location permission requested");
            }
        );


        // get current location
        var lat_value = 0; var lng_value = 0;
        var location = geolocation.getCurrentLocation({desiredAccuracy: 3, updateDistance: 10, maximumAge: 20000, timeout: 20000}).
        then(function(loc) {
            if (loc) {
                console.log("Current location is: " + loc.latitude + ", " + loc.longitude);
                lat_value = loc.latitude;
                lng_value = loc.longitude;
            }
        }, function(e){
            console.log("Error: " + e.message);
        }).
        then(function() {
            // display the map for curr
            setTimeout(() => {
                that.show_map(lat_value, lng_value);
            }, 100);
        }
        );
    }

    show_map(latitude, longitude) {
        mapbox.show({
            accessToken: accessToken,
            style: mapbox.MapStyle.OUTDOORS,
            margins: {
                left: 30,
                right: 30,
                top: 30,
                bottom: 30
            },
            showUserLocation: true, // default false
            center: {
                lat: latitude,
                lng: longitude
            }, 
            zoomLevel: 14, // 0 (most of the world) to 20, default 0
            hideAttribution: true, // default false
            hideLogo: true, // default false
            hideCompass: false, // default false
            disableRotation: false, // default false
            disableScroll: false, // default false
            disableZoom: false, // default false
            disableTilt: false, // default false
        }).then(
            function(result) {
                console.log("Mapbox show done");
            },
            function(error) {
                console.log("mapbox show error: " + error);
            }
        );
    }
}

Not show map in demo

I’m testing the demo but home although I copied my accessToken of MapBox, not can see the map in the application, only the action buttons.

I'm using genymotion for testing and galaxy S3 image for run it.

image

When put in show button the app crashes:

image

In console shows:

Project successfully built Successfully deployed on device with identifier '192.168.57.101:5555'. E/FusionEngine( 1295): at com.tns.Runtime.callJSMethodNative(Native Method) E/FusionEngine( 1295): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethodImpl(Runtime.java:726) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethod(Runtime.java:712) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethod(Runtime.java:693) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethod(Runtime.java:683) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethodNative(Native Method) E/FusionEngine( 1295): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethodImpl(Runtime.java:726) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethod(Runtime.java:712) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethod(Runtime.java:693) E/FusionEngine( 1295): at com.tns.Runtime.callJSMethod(Runtime.java:683) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethodNative(Native Method) E/FusionEngine( 1341): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethodImpl(Runtime.java:726) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethod(Runtime.java:712) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethod(Runtime.java:693) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethod(Runtime.java:683) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethodNative(Native Method) E/FusionEngine( 1341): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethodImpl(Runtime.java:726) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethod(Runtime.java:712) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethod(Runtime.java:693) E/FusionEngine( 1341): at com.tns.Runtime.callJSMethod(Runtime.java:683)

I test with a AccessToken of mapbox called "Default public token" and with another token generated in mapbox studio with Mapbox Streets.

I make something wrong?

iOS accessToken in XML not working

Getting this dialog: https://github.com/EddyVerbruggen/nativescript-mapbox/blob/master/mapbox.ios.js#L34

Markup works fine on Android.

<map:Mapbox row="1" col="0" rowSpan="5" colSpan="5" id="map" delay="800" disableRotation="true" mapStyle="streets" mapReady="{{ onMapReady }}" latitude="39.8282" longitude="-98.5795" zoomLevel="3.0" showUserLocation="false" hideLogo="true" hideAttribution="false" accessToken="pk.whatever.GOhome"></map:Mapbox>
       

I'll dig around later and see if I'm missing something obvious

Angular 2 registerElement XML not setting property

I guess that the xml with angular2 is not setting the accessToken property:

<GridLayout rows="auto, *">
     <Map #map
          row="1"
          accessToken="bla"
          latitude="52.3702160"
          longitude="4.8951680"
          zoomLevel="3"
          showUserLocation="true"
          hideAttribution="false",
          hideLogo="false",
          hideCompass="false"
          (mapReady)="onMapReady($event)">
      </Map>
</GridLayout>
registerElement("Map", () => require("nativescript-mapbox").Mapbox)

The map load in black with the message: Please set the 'accessToken' property because now the map will be entirely black :)

Additional style for Markers

Hi,

Is there an additional style for Markers? I want to include two types of Markers on a Mapbox map to signify two different types of locations on a map. Thanks.

Custom maps

Hi, First of all, thanks.
Could you show me a little sample about how can I load a custom map using nativescript-mapbox please?
Thanks.
Best.

Dalmiro

'Zoom' attribute error

platforms\android\build\intermediates\exploded-aar\Common-2015.3.1307-trial-release\res\values\values.xml:2 : Attribute "zoom" has already been defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.