Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Search 传单地图和标记不显示_Search_Leaflet_Marker - Fatal编程技术网

Search 传单地图和标记不显示

Search 传单地图和标记不显示,search,leaflet,marker,Search,Leaflet,Marker,我想创建一个应用程序,帮助用户搜索城市中很棒的餐厅,以便他们将来可以再次访问。这个应用程序是我第一个使用传单的有趣项目。我想做的是从数据库中创建一个简单的映射和加载标记,在这个数据库中,当用户从类别中查询位置或在搜索栏中搜索时,标记才会出现。我确实在JSFIDLE中测试了索引pageand marker.js,但它只在搜索按钮、栏和类别旁边显示地图换行 Marker.js //now map reference the global map declared in the first line

我想创建一个应用程序,帮助用户搜索城市中很棒的餐厅,以便他们将来可以再次访问。这个应用程序是我第一个使用传单的有趣项目。我想做的是从数据库中创建一个简单的映射和加载标记,在这个数据库中,当用户从类别中查询位置或在搜索栏中搜索时,标记才会出现。我确实在JSFIDLE中测试了索引pageand marker.js,但它只在搜索按钮、栏和类别旁边显示地图换行

Marker.js

//now map reference the global map declared in the first line
map=L.map('map').setView(true)

//marker development

L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: 'Map data &copy;<a href="http://openstreetmap.org">OpenStreetMap</a>
     contributors,<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
        maxZoom:18
     }).addTo(map);
    newMarkerGroup = new L.LayerGroup();
    map.on('click',addMarker);
 });

 //add group layer to map
 map.addLayer(search_group);

 //start to initiate adding marker
 function addMarker(e){
        // Add marker to map at click location; add popup window
        var newMarker = new L.marker(e.latlng).addTo(map);
    }

//create array
var marker= new Array();
function onMapClick(e){
    marker = new L.Marker(e.latlng,
{draggable: false});

//pushing items into array each by each and then add markers
function itemWrap(){
    for(i=0; i<items.length; i++){
        var LamMarker = new
    L.marker([items[i].lat,items[i].lon]);
        marker.push(LamMarker);
        map.addLayer(marker[i]);
    }
  }

 //create popup
  marker.bindPopup().openPopup();
  };

//add to map function with a popup that contains a link, which when clicked will have a popup of details and booking options
//this link will have as its id the latlng of the point
//this id will then be compared to when you click on one of your created markers 
map.on('click',function(e){
    var clickPositionMarker = L.marker([e.latlng.lat,e.latlng.lng],{icon:idMarker});
    clickArr.push(clickPositionMarker);
    mapLat = e.latlng.lat;
    mapLon = e.latlng.lng;
    clickPositionMarker.addTo(search_group).bindPopup().openPopup();

        L.marker(e.latlng).addTo(map)
            .bindPopup("You're within " + radius + " meters from this point").openPopup();

        L.circle(e.latlng, radius).addTo(map);

}

map.on('locationfound' , onLocationFound);

        //access it using markers[i]["id"]
//现在映射引用第一行中声明的全局映射
map=L.map('map').setView(true)
//标记开发
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'{
属性:'地图数据和副本;
贡献者,',
最大缩放:18
}).addTo(地图);
newMarkerGroup=新的L.LayerGroup();
地图上('点击',添加标记);
});
//将组图层添加到地图
map.addLayer(搜索组);
//开始添加标记
功能添加标记(e){
//在单击位置向地图添加标记;添加弹出窗口
var newMarker=新的L.标记(e.latlng).addTo(地图);
}
//创建数组
var marker=新数组();
函数onMapClick(e){
标记器=新的L标记器(如板条,
{draggable:false});
//逐个将项目推入数组,然后添加标记
函数itemWrap(){

对于(i=0;i您将在
L.marker
之前抛出一个
new
,这不是此构造函数的格式。请注意
m
上的大小写差异。它需要是
L.marker(选项)
new L.marker(选项)
。您只需要
new
L.marker
样式的marker init。
请参见

非常感谢您的帮助。但是,如果我像修改标记一样修改地图或调整弹出窗口,为什么地图会变为空白?我必须更改平铺层吗?我必须在当前构建的应用程序的每个部分初始化平铺层吗?因为我的应用程序包含popup、upload、marker和map.js,还是只在index.ht中初始化它ml?我不知道为什么会发生这种情况……你能发布一个JSFIDLE吗?它仍然是空的,地图根本没有显示。你能告诉我写index.html的正确方法吗?它将标记链接到外部标记,即marker.js?我真的希望创建一个传单地图,从数据库中获取标记,并且只有当用户请求时才会显示用户。类似mysql获取的信息指示的标记由GeoHP转换为geojson,并在用户请求itL.tileLayer('htt[:/{s}.tile.osm.org/{z}/{x}/{y}.png',{attribute:'$copy;osm.org/copyright“>OpenStreetMap contributors})时将其指向地图。很抱歉,上面是我当前使用的瓷砖层