我正在尝试构建一个API,以便了解是否CLLocation代表土地.我需要这个离线工作,因为我希望我的大多数用户都没有连接.我使用MapBox作为tile服务器,但这仍然是一个MapKit问题,因为我没有使用MapBox SDK.
我已经尝试了几种方法来确定给定坐标是代表陆地还是海洋位置:
另外(在上面的处理之后)是否有一种有效的方法来决定给定一个瓦片坐标(x,y,z)是否是陆地/海洋/海岸瓦片?
如果有人一直在努力解决这个问题,我会在此提出一些建议.
我有一个用mapbox studio设计的地图,但是我很难添加一个基本的标记,但是文本出现在标记应该是哪里表明标记会在那里.
所以这是具有该地图样式的代码:
mapboxgl.accessToken = 'pk.eyJ1Ijoic21pY2tpZSIsImEiOiJjaWtiM2JkdW0wMDJudnRseTY0NWdrbjFnIn0.WxGYL18BJjWUiNIu-r3MSA';
var map = new mapboxgl.Map({
container: 'map',
style: "mapbox://styles/smickie/cikb3fhvi0063cekqns0pk1f1",
center: [-30.50, 40],
zoom: 2,
interactive: false
});
Run Code Online (Sandbox Code Playgroud)
这里有一些标记从api的例子中添加:
map.on('style.load', function () {
map.addSource("markers", {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-77.03238901390978, 38.913188059745586]
},
"properties": {
"title": "Mapbox DC",
"marker-symbol": "monument"
}
}, {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-122.414, 37.776]
},
"properties": {
"title": "Mapbox SF",
"marker-color": "#ff00ff"
}
}]
}
});
map.addLayer({ …Run Code Online (Sandbox Code Playgroud) 使用以下代码将各种行添加到表示路径的地图中:
private LineLayer makeLineLayer(List<GeoPoint> routePoints, String title) {
String sourceTitle = "line-layer-" + lineCount;
List<Position> points = new ArrayList<>(routePoints.size());
List<Feature> routes = new ArrayList<>(routePoints.size());
for (GeoPoint point : routePoints) {
points.add(Position.fromCoordinates(point.getLongitude(), point.getLatitude()));
}
LineString route = LineString.fromCoordinates(points);
Feature routeFeature = Feature.fromGeometry(route);
routeFeature.addStringProperty("custom-line", "0");
routes.add(routeFeature);
GeoJsonSource linesSource = new GeoJsonSource(
sourceTitle,
FeatureCollection.fromFeatures(routes));
mapboxMap.addSource(linesSource);
LineLayer lineLayer = new LineLayer(title, sourceTitle);
lineLayer.setProperties(
//Sets properties...
);
return lineLayer;
}
LineLayer lineLayer = makeLineLayer(getRoutePoints());
mapboxMap.addLayer(lineLayer);
Run Code Online (Sandbox Code Playgroud)
我希望能够确定何时单击其中一行.目前,MapBox调用OnMapClick并传入一个LatLng对象.然后,我可以custom-line使用以下内容查询属性的渲染功能:
PointF pixel = …Run Code Online (Sandbox Code Playgroud) 在plotly网站Map Configuration and Styling in Python中描述了如何自动缩放“地理地图”:
import plotly.express as px
fig = px.line_geo(lat=[0,15,20,35], lon=[5,10,25,30]) # Creates a "Geo map" figure
fig.update_geos(fitbounds="locations") # Automatic Zooming !!!!
fig.show()
Run Code Online (Sandbox Code Playgroud)
这有效,而且如果我尝试在“Mapbox 地图”上进行相同的操作,它不会应用自动缩放:
fig = px.scatter_mapbox(filtered_df, lat="latitude", lon="longitude", color="ID") # Creates a "Mapbox map" figure
fig.update_layout(mapbox_style="open-street-map")
fig.update_geos(fitbounds="locations") # Automatic Zooming not working!!!
Run Code Online (Sandbox Code Playgroud)
在 Python 的 Mapbox 地图图层中没有如何执行此操作的信息。
我正在使用react 17.0.1和react-map-gl ^6.0.2我有一个地图组件。
\n无法解决这个问题
\n当我执行“npm run start”时没问题,它显示地图,但是当我执行“npm run build”时,它只显示:地图空白
\n它抛出这个错误:错误
\n我的代码如下:
\n import React, {useState } from "react";\nimport ReactMapGL from \'react-map-gl\';\nconst Map = () => {\n const[viewport, setViewport] = useState({\n width: "100%",\n height: "400px",\n latitude: 38.963745,\n longitude: 35.243322,\n zoom: 5\n });\n return (\n <div>\n <h2>Size yak\xc4\xb1n olan yerleri ke\xc5\x9ffedin!</h2>\n <ReactMapGL\n {...viewport}\n onViewportChange={setViewport}\n mapboxApiAccessToken={process.env.REACT_APP_MAPBOX_ACCESS_TOKEN}\n mapStyle="mapbox://styles/mapbox/streets-v11"\n />\n </div>\n );\n }\n export default Map\nRun Code Online (Sandbox Code Playgroud)\n 我想在我的Android应用程序中使用Mapbox GL.这项服务即将发布,我有一个关于使用渲染器的棘手问题.
我喜欢渲染器本身,但我真的想在应用程序中使用我自己的地图数据(而不是Mapbox提供的数据和支付的数据).例如,我想自己解析OpenStreetMaps数据,以某种方式自定义它,然后放入渲染器内部以在我的应用程序中显示它.
现在问题是:使用Mapbox GL时是否可以使用我自己的地图数据?或者它只能用于Mapbox数据?
预先感谢您的任何帮助.也许你知道其他任何做得好的解决方案吗?问题是,我想要矢量图块,而不是光栅图块.这个项目计划在以后为iOS开发.
我有问题在Android片段上膨胀Mapbox MapView.当我在Activity上使用相同的代码时(除了Activity和Fragment之间的标准差异),我可以正确加载MapView,但不能在Fragment上加载.
Mapbox 在这里也有一个MapFragment类,但我不确定如何在Fragment中正确使用它(该示例仍然在Activity中); 使用Google Maps API,我可以在片段上使用MapView而不会出现问题.
下面的logcat行:
at com.example.exampleapp.FragmentMap.onCreateView(FragmentMap.java:133)
Run Code Online (Sandbox Code Playgroud)
是指Java行:
fragmentLayout = inflater.inflate(R.layout.fragment_map, container, false);
Run Code Online (Sandbox Code Playgroud)
以下是此问题的相关代码以及日志:
fragment_map.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:access_token="@string/access_token"/>
<android.support.v7.widget.CardView
android:id="@+id/map_card"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp">
<com.mapbox.mapboxsdk.views.MapView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/mini_map"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
mapbox:access_token="@string/access_token"/>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
FragmentMap.java:
public class FragmentMap extends Fragment {
private MapView mv, miniMap;
View fragmentLayout;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
fragmentLayout = inflater.inflate(R.layout.fragment_map, container, false);
mv = (MapView) fragmentLayout.findViewById(R.id.mapview);
mv.onCreate(savedInstanceState);
miniMap …Run Code Online (Sandbox Code Playgroud) 我想绘制一个带有中心GPS点和两个GPS终点的弧.我可以使用任何可以与android一起使用的映射软件.
到目前为止,我已经尝试了Google Maps for android.Mapbox for android.ARCGIS for android.他们似乎都没有能够做这个简单的任务.
我猜我需要某种叠加?
我正在使用 Mapbox GL JS。有什么方法可以让我的基础层看起来像 Mapbox Light 示例,但只显示英国?
我假设我会使用 Mapbox Studio 来构建我自己的基础层,但我在 Studio 中看不到任何按国家/地区过滤的方法。
如果这是不可能的,有什么办法可以只在英国显示标签,而将其他国家/地区显示为填充的多边形?(根据这个未回答的问题。)
我正在使用Mapbox GL JS来显示多边形图层.我想允许用户从下拉列表中选择一个名称,然后突出显示并缩放到匹配的多边形.
我已经知道如何突出显示匹配的多边形map.setFilter,但我不知道如何缩放到匹配多边形的边界.这是我目前的代码:
map.addLayer({
'id': 'polygon_hover',
'source': 'mysource',
'source-layer': 'mylayer',
'type': 'fill',
'paint': {
'fill-color': 'red',
"fill-opacity": 0.6
},
"filter": ["==", 'CUSTNAME', ""]
});
// Get details from dropdown
custname.on("change", function(e) {
// get details of name from select event
map.setFilter('polygon_hover', ["==", 'CUSTNAME', name]);
// Get bounds of filtered polygon somehow?
// var bounds = ??;
// map.fitBounds(bounds);
});
Run Code Online (Sandbox Code Playgroud)
我已经检查了缩放到边界的Mapbox示例,但它假设您已经知道边界是什么.
有没有办法可以在Mapbox中获得与地图过滤器匹配的多边形边界?
mapbox ×10
android ×4
mapbox-gl-js ×3
java ×2
javascript ×2
geo ×1
ios ×1
mapbox-gl ×1
mapkit ×1
maps ×1
python ×1
react-map-gl ×1
reactjs ×1
xml ×1