我使用下面的代码将标记添加到mapbox地图.
var marker = L.marker([latitude, longitude],
{
icon: L.divIcon({
html: 'myhtml',
iconSize: [40, 40]
})
});
marker.addto(map);
Run Code Online (Sandbox Code Playgroud)
我使用上面的代码使用for循环添加了标记.现在我想删除标记来刷新地图.有没有我可以从地图中删除所有标记和折线.或者,如果有任何方法我可以重新加载地图集地图.
我是Leaflet的新手 - 虽然从一个免费的MapBox地图开始.我创建了一个带有媒体查询的网站.
我使用以下代码将MapBox映射添加到我的索引文件中:
<section id="map_section">
<div id='map'></div>
<script>
var map = L.mapbox.map('map', 'pandora.hn8og4ae', {
scrollWheelZoom: false,
minZoom: 5,
maxZoom: 18
}).setView([45, -67.874], 8);
</script>
</section>
Run Code Online (Sandbox Code Playgroud)
在较小的屏幕尺寸(移动设备)上,我希望地图以不同的缩放级别启动,因为我没有足够的屏幕尺寸来同时显示所有标记.你会怎么用css做这个?MapBox上一位乐于助人的人建议如下:
您需要以编程方式在JavaScript中监听窗口大小调整事件并在用户的屏幕达到特定大小时设置map.setZoom(NUMBER).
有人会介意告诉我如何做到这一点?
我已经迈出了迈向JavaScript的步骤并且了解到足够危险.:)我的组织正在检查Leaflet以生成更大的项目,这对我们来说是一个基本问题.所以即使我使用MapBox示例,我们也直接转向Leaflet.
我正在尝试在我的Android应用程序中使用mapbox.我使用android studio 0.8.0.我在build.gradle文件中包含了这一行
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.4.0@aar'){
transitive=true
}
compile ('com.cocoahero.android:geojson:1.0.0@aar'){
transitive=true
}
Run Code Online (Sandbox Code Playgroud)
但是当我在我的xml文件中使用它时,它有一个命名空间错误.mapbox命名空间导致了这一点.任何想法可能导致什么?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/parent_layout">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="15sp"
android:text="this is the general tab"/>
<com.mapbox.mapboxsdk.views.MapView -->not causing error
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:mapid="Your MapBox mapid" /> -->causing error
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) 我觉得这是执行Google / StackOverflow搜索的一项简单任务,但是我似乎找不到关于该主题的任何内容...无论如何,我要做的就是创建自己的Geocoder搜索栏,该栏可以在其他地方使用我的mapbox地图。
例如,进入Zillow主页。当您访问主页时,您尚未在地图上。您可以在提供的搜索栏中输入邮政编码,然后按Enter(或按钮),然后地图便会以您提供的邮政编码为中心。
我基本上是想做同样的事情。在我的主页上,我想要一个简单的邮政编码输入和一个单击按钮,以触发地图出现并居中于所提供的邮政编码上。
有人可以提供一些有关如何实现此目标的见解吗?非常感谢!
我们可以在谷歌地图中使用传单吗?搜索和阅读有关它的文章,我们发现有一些传单插件可用.使用它我们可以使用谷歌地图+传单建立应用程序.
我想在地图上添加自定义标记。我正在使用mapbox gl脚本。
我发现与此主题相关的唯一文档是https://www.mapbox.com/mapbox-gl-js/example/geojson-markers/。
我尝试自定义给定的示例,并设法添加了一个标记并对其进行了一些修改,以更改其大小,但是由于我不了解所有参数,因此我不知道如何添加自己的标记。有没有更详细的文档?
这是我的代码:
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiYWl3YXRrbyIsImEiOiJjaXBncnI5ejgwMDE0dmJucTA5aDRrb2wzIn0.B2zm8WB9M_qiS1tNESWslg';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/aiwatko/cipo0wkip002ddfm1tp395va4', //stylesheet location
center: [7.449932,46.948856], // starting position
zoom: 14.3, // starting zoom
interactive: true
});
map.on('load', function () {
map.addSource("markers", {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [7.4368330, 46.9516040]
},
"properties": {
"title": "Duotones",
"marker-symbol": "marker",
}
}]
}
});
map.addLayer({
"id": "markers",
"type": "symbol",
"source": "markers",
"layout": …Run Code Online (Sandbox Code Playgroud) 我有一些外部HTML(由GeoJSON生成),其中包含地图上的标记列表.项目的示例是:
<ul id="marker-list">
<li data-lat="53.3895673" data-lng="-1.4725166">Marker 1</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
然后我有以下jQuery监听其中一个项目的click事件,然后应该关注这些坐标并触发标记上的click事件(打开它的弹出窗口).
$(document).on('click', '#marker-list li', function(e){
e.preventDefault();
var latlngPoint = new L.latLng($(this).attr('data-lat'), $(this).attr('data-lng'));
map.setView(latlngPoint, 18);
map.fireEvent('click', {
latlng: latlngPoint,
layerPoint: map.latLngToLayerPoint(latlngPoint),
containerPoint: map.latLngToContainerPoint(latlngPoint)
});
});
Run Code Online (Sandbox Code Playgroud)
该setView工作正常,但弹出窗口没有被打开...
添加:
map.on('click', function(e){
console.log(e);
});
Run Code Online (Sandbox Code Playgroud)
显示click事件被触发,但它不会导致弹出窗口打开...如何让弹出窗口打开?有没有办法定位标记?
我可以marker使用中的以下代码在地图上创建一个(注释)react-native。
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import MapboxGL from '@mapbox/react-native-mapbox-gl';
import Mapbox from '@mapbox/react-native-mapbox-gl';
const columbusCircleCoordinates = [
-73.98197650909422, 40.768793007758816
];
Mapbox.setAccessToken('your access key');
export default class App extends Component {
renderAnnotations () {
return (
<Mapbox.PointAnnotation
key='pointAnnotation'
id='pointAnnotation'
coordinate={[11.254, 43.772]}>
<View style={styles.annotationContainer}>
<View style={styles.annotationFill} />
</View>
<Mapbox.Callout title='Look! An annotation!' />
</Mapbox.PointAnnotation>
)
}
render() {
return (
<View style={styles.container}>
<Mapbox.MapView
styleURL={Mapbox.StyleURL.Street}
zoomLevel={15}
centerCoordinate={[11.256, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MapBox地理编码API,为此我尝试将"CenterHospitalierRégionald'Orléans"(法国的一家医院,奥尔良)翻译成Lng/Lat坐标.
当我在MapBox Studio中单击它时,它被公认为兴趣点(POI)(poi-label):
但是当我尝试使用Geocoding API找到它时,我找不到它.这是我运行的请求:
https://api.mapbox.com/geocoding/v5/mapbox.places/Centre%20Hospitalier.json?access_token=pk.eyJ1IjoibWF0dGZpY2tlIiwiYSI6ImNqNnM2YmFoNzAwcTMzM214NTB1NHdwbnoifQ.Or19S7KmYPHW8YjRz82v6g&cachebuster=1547469044480&autocomplete=true&country=fr&proximity=1.909251%2C47.902964
这是正常的吗?我做错了什么还是错误?
我正在使用JAVA中的Selenium使基于地图的Web应用程序(使用'MapBox')自动化。
将地图作为单个图像检索,我必须在地图中找到不同区域的坐标。
为此,我找到了x&y坐标并执行了点击操作。但是我们确实有不同分辨率的机器来运行脚本。
此时,坐标会发生变化,因此会单击不正确的点(区域)。
请通过对坐标进行归纳来解决此问题,而与机器分辨率无关。
用于单击特定坐标的代码如下:
Actions action = new Actions(getDriver());
action.moveByOffset(xcordinate, ycordinate).click().build().perform(); //coordinates changes as the resolution changes
Run Code Online (Sandbox Code Playgroud) mapbox ×10
leaflet ×3
android ×2
geocoding ×2
javascript ×2
mapbox-gl ×2
markers ×2
geojson ×1
google-maps ×1
ios ×1
java ×1
jquery ×1
line ×1
map ×1
mapbox-gl-js ×1
polyline ×1
react-native ×1
selenium ×1
xml ×1
zoom ×1