mapbox

Mapbox.js - Fallback tile image from lower zoom level, when missing in requested zoom level

邮差的信 提交于 2019-12-21 17:14:12
问题 I serve map png files from disk and I have tile pngs for whole city in zoom level 15. I have also tiles in zoom levels 16-18 but only for certain areas. I would like to set up the tile Layer, so that when the user is in zoom level 18 the map will display scaled tiles from level 15 as a fallback. I tried setting option maxNativeZoom , but didn't work for me. Here is my code: offlineLayer = L.mapbox.tileLayer(tileJSON, { minZoom: 8, maxZoom: 18, maxNativeZoom: 15 }); map.addLayer(offlineLayer,

Mapbox GL JS: ignore map click event if marker is clicked

試著忘記壹切 提交于 2019-12-21 16:58:34
问题 I have a marker in the map. I want to change its state when it is clicked and change it back when other place on the map is clicked. The problem is that map.on("click", console.log) is also fired upon clicking the marker. I want to see only the marker clicked event, because map click invokes state rollback. <!DOCTYPE html> <html> <head> <meta charset='utf-8' /> <title></title> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <script src='https://api.tiles

How to calculate the distance of a polyline in Leaflet like geojson.io?

点点圈 提交于 2019-12-21 10:50:10
问题 I am working on a map with Mapbox and Leaflet and I am supposed to let the user draw polygons and calculate and show the are of that polygon and I also need to let the user draw a polyline and show the distance of the polyline. I have figured out the polygon area feature but I cannot figure out how to calculate the distance of a polyline. My code is as follows: loadScript('https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.js', function(){ loadScript('https://api

Offer packages of map tiles for offline use

≡放荡痞女 提交于 2019-12-21 03:12:11
问题 I'm making a web application that has to work offline. So far everything works and my last step is to take the map tiles offline. Luckily I know exactly what areas of the map will need to be accessible to users, so I don't have to allow caching of millions of tiles. The map is split into areas and so the idea is to offer the tiles for these areas as downloadable 'packages.' For instance, when I'm online, I go to the 'tile packages' page, which offers downloads for several areas. I choose the

Add some basic markers to a map in mapbox via mapbox gl js

拥有回忆 提交于 2019-12-20 18:45:16
问题 I have a map styled with mapbox studio, however I'm having difficulty adding even a basic marker to it, however text is appearing where the marker should be which suggests that the marker would be there. So here's the code with that map style: mapboxgl.accessToken = 'pk.eyJ1Ijoic21pY2tpZSIsImEiOiJjaWtiM2JkdW0wMDJudnRseTY0NWdrbjFnIn0.WxGYL18BJjWUiNIu-r3MSA'; var map = new mapboxgl.Map({ container: 'map', style: "mapbox://styles/smickie/cikb3fhvi0063cekqns0pk1f1", center: [-30.50, 40], zoom: 2,

Mapbox GL JS getBounds()/fitBounds()

↘锁芯ラ 提交于 2019-12-20 09:48:01
问题 I'm using Mapbox GL JS v0.14.2 and I've searched high and low through the documentation and very little is clear about this. If you use the standard JS API, it's very clear to 'fit map to markers' using an example they have provided (https://www.mapbox.com/mapbox.js/example/v1.0.0/fit-map-to-markers/); however the setup when using the GL api is quite different. The GL API has getBounds() (https://www.mapbox.com/mapbox-gl-js/api/#Map.getBounds) but because you don't have a named layer, like

IBOutlet variables return nil when I try to access them. Error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

為{幸葍}努か 提交于 2019-12-20 07:40:19
问题 I have a UIViewController that implements MGLMapViewDelegate . I'm trying to place a nav bar at the top, with two buttons. I couldn't get my buttons or nav bar visible so I tried using the function view.bringSubviewToFront() within my viewDidLoadFunction() as suggested on this post When I did this, I received the error Error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value I don't understand how the IBOutlet variables can ever be nil, I thought they were

Is it possible to make MGLPolyLines selectable? - Swift, MapBox

拟墨画扇 提交于 2019-12-20 07:33:12
问题 Is it possible to make an MGLPolyLine touchable/selectable/have user interaction? In my project, the user needs to touch the polyline. There was this question asked before but it is outdated by about 2 years. Have they (MapBox) updated this? 回答1: I've just checked back and it looks like this has been implemented though I'm not sure which Mapbox release rolled this out. If you take a look at the simple Mapbox example, Annotation Models, that demos an MGLPolyline and interspaced circular

Get Directions between two points in Mapbox?

拜拜、爱过 提交于 2019-12-20 05:38:16
问题 I recently using mapbox gl on react native instead of Google maps, I am trying to add a feature that shows a direction from point A to point B on the map. OR use Mapbox directions API inside my React Native App here is my code I tried but after my screen mounted, the app crashed successfully :D import MapboxGL from '@react-native-mapbox-gl/maps'; import React from 'react'; import {View} from 'react-native'; MapboxGL.setAccessToken( '....', ); class TwoPoints extends React.Component {

Use of MBTiles in offline iOS app

痴心易碎 提交于 2019-12-20 02:39:10
问题 I already have a map stored using the MBTiles format that I want to use in an app I am making. It is vital that the app will run with no signal/connection on the mobile device. Mapbox previously had an example of how to use MBTiles together with RMMBTilesSource so that the mapping data could all be stored locally. This has now been deprecated, see https://github.com/mapbox/mapbox-ios-example. I also enquired with Mapbox as to whether they were going to replace this example with another that