nativescript-mapbox icon indicating copy to clipboard operation
nativescript-mapbox copied to clipboard

Unable to draw lines based on the coordinates that were returned by the directions API

Open ejlocop opened this issue 4 years ago • 0 comments

It looks like addSource and addLayer to draw directions/route on the map isn't working.

below are my codes

await mapBox.addSource('route-line', {
		type: 'geojson',
		url: 'mapbox://mapbox.satellite',
		data: {
			type: "Feature",
			geometry: {
				type: "LineString",
				coordinates
			}
		}
	})

return await mapBox.addLayer({
		id: 'line',
		type: 'line',
		source: 'route-line',
		layout: {
			'line-cap': 'round',
			'line-join': 'round'
		},
		paint: {
			'line-color': '#ff0000',
			'line-width': 5,
			'line-opacity': 1
		}
	})

The coordinates are..

coordinates = [
          [
            120.966606,
            14.649952
          ],
          [
            120.966782,
            14.649673
          ],
          [
            120.966011,
            14.6493
          ],
          [
            120.966278,
            14.648105
          ],
          [
            120.96524,
            14.647702
          ],
          [
            120.962242,
            14.645054
          ],
          [
            120.962372,
            14.644881
          ],
          [
            120.959068,
            14.642092
          ],
          [
            120.954628,
            14.646876
          ],
          [
            120.952171,
            14.644948
          ],
          [
            120.950279,
            14.647659
          ],
          [
            120.951324,
            14.648144
          ],
          [
            120.95031,
            14.651459
          ],
          [
            120.944794,
            14.66421
          ],
          [
            120.944504,
            14.666482
          ],
          [
            120.942108,
            14.669816
          ],
          [
            120.940193,
            14.67138
          ],
          [
            120.935692,
            14.672931
          ],
          [
            120.936005,
            14.673723
          ],
          [
            120.936401,
            14.673439
          ]
        ],

plugin version: 5.0.1 nativescript-vue: ^2.8.1 nativescript: 6.8.0

ejlocop avatar Sep 17 '20 10:09 ejlocop