Javascript openWeatherMap不显示传单层&;geoJSON
我尝试使用传单地图和openWeatherAPI在我的地图上显示圆形和多边形,标记器可以工作,但其他的不行!! 你能帮我解决这个问题吗Javascript openWeatherMap不显示传单层&;geoJSON,javascript,json,ajax,leaflet,openweathermap,Javascript,Json,Ajax,Leaflet,Openweathermap,我尝试使用传单地图和openWeatherAPI在我的地图上显示圆形和多边形,标记器可以工作,但其他的不行!! 你能帮我解决这个问题吗 var circle = L.circle([51.508, -0.11], { color: 'red', fillColor: '#f03', fillOpacity: 0.5, radius: 500 }).addTo(map); L.geoJSON(circle).addTo
var circle = L.circle([51.508, -0.11], {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5,
radius: 500 }).addTo(map);
L.geoJSON(circle).addTo(map);
//polygon on map
var polygon = L.polygon([
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.044]
]).addTo(map);
L.geoJSON(polygon).addTo(map);
var geojsonFeature = {
"type": "Feature",
"properties": {
"name": "Coors Field",
"amenity": "Baseball Stadium",
"popupContent": "This is where the Rockies play!"
},
"geometry": {
"type": "Point",
"coordinates": [-104.99404, 39.75621]
}
};
L.geoJSON(geojsonFeature).addTo(map);
我也有这个代码和作品:
var map = L.map('map').setView({ lon: 0, lat: 0 }, 2);
// add the OpenStreetMap tiles
L.tileLayer('http://mt0.google.com/vt/lyrs=p&hl=en&x={x}&y={y}&z={z}&s=Ga', {
maxZoom: 19,
attribution: '© <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
}).addTo(map);
// show the scale bar on the lower left corner
L.control.scale().addTo(map);
map.on('dblclick', function(ev) {
app.request.get('http://api.openweathermap.org/data/2.5/weather', { appid: '38e6ae7b7f30d96079f5e8a9df837472', lon:''+ev.latlng.lng ,lat:''+ev.latlng.lat }, function (data)
{
var JsonWeatherData=JSON.parse(data);
alert(JsonWeatherData.weather[0].description);
});
L.marker({ lon: ev.latlng.lng, lat: ev.latlng.lat }).bindPopup('The center of the world').addTo(map);
});
var-map=L.map('map').setView({lon:0,lat:0},2);
//添加OpenStreetMap分幅
L.tileLayer('http://mt0.google.com/vt/lyrs=p&hl=en&x={x} &y={y}&z={z}&s=Ga',{
maxZoom:19,
属性:“©;”
}).addTo(地图);
//显示左下角的比例尺
L.control.scale().addTo(映射);
map.on('dblclick',函数(ev){
app.request.get('http://api.openweathermap.org/data/2.5/weather“,{appid:'38e6ae7b7f30d96079f5e8a9df837472',lon:''+ev.latlng.lng,lat:''+ev.latlng.lat},函数(数据)
{
var JsonWeatherData=JSON.parse(数据);
警报(JsonWeatherData.weather[0].说明);
});
L.marker({lon:ev.latlng.lng,lat:ev.latlng.lat}).bindpoop('世界中心').addTo(地图);
});
如果不是geoJSON特性,请不要向L.geoJSON
组添加类似的层
var circle=L.circle([51.508,-0.11]{
颜色:“红色”,
填充颜色:“#f03”,
填充不透明度:0.5,
半径:500});
var circleGroup=L.geoJSON().addTo(映射)
circleGroup.addLayer(圆形);
//地图上的多边形
var polygon=L.polygon([
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.044]
]);
var polyGroup=L.geoJSON().addTo(映射)
polyGroup.addLayer(多边形);
但是,如果您在geoJSON组中不需要这些层,请使用
L.featureGroup(circle).addTo(map)
um。。。实际上,当我没有得到圆和多边形的结果时,我添加了这些。。。这个代码对我也不起作用,唯一有效的是标记!!这是一个非常复杂的问题,它正在工作,只有标记和圆&多边形有不同的位置,而不是阿加尼有另一个代码,它现在添加到编辑中。那不会有什么问题吧?