2012-11-19 61 views
0

我按照有關如何創建圖層控制和自定義標記單張教程:Cloudmade和單張:多個自定義標記

標記:HTTP://leafletjs.com/examples/custom-icons.html控制: http://leafletjs.com/examples/layers-control.html

我正在使用控制代碼,我想向此添加MULTIPLE自定義市場。在應用代碼時,地圖會變得空白,但是隻有一個標記可以工作。任何幫助或指導都會很棒。

這是我對多個標記當前代碼打破:

我在控制檯得到一個錯誤,當它加載的:var officeoneIcon =新officeIcon({iconUrl:「圖像/ office1.png」}), officeIcon沒有定義。

[CODE]

var officeoneIcon = new officeIcon({iconUrl: 'images/office1.png'}), 
    officetwoIcon = new officeIcon({iconUrl: 'images/office2.png'}), 
    officethreeIcon = new officeIcon({iconUrl: 'images/office3.png'}); 


var officeone = L.marker([lat,long],{icon: officeoneIcon}).bindPopup('<b>Office Address</b>'); 

var officetwo = L.marker([lat,long],{icon: officetwoIcon}).bindPopup('<b>Office Address</b>'); 

var officethree = L.marker([lat,long],{icon: officethreeIcon}).bindPopup('<b>Office Address</b>'); 


var cities = L.layerGroup([officeone, officetwo, officethree]); 

var minimal = L.tileLayer(cloudmadeUrl, {styleId: 22677}), 
midnight = L.tileLayer(cloudmadeUrl, {styleId: 999}), 
motorways = L.tileLayer(cloudmadeUrl, {styleId: 46561}); 

var map = L.map('map', { 
center: new L.LatLng(lat,long), 
zoom: 10, 
scrollWheelZoom: true, 
layers: [minimal, motorways, cities] 
}); 

var baseMaps = { 
    "Minimal": minimal, 
    "Night View": midnight, 

}; 

var overlayMaps = { 
    "Motorways": motorways, 
    "Display Markers": cities 
}; 

L.control.layers(baseMaps, overlayMaps).addTo(map); 

[/ CODE]

回答

0

這通過將"var officeIcon =L.icon;"代碼iconUrl線的上方解決。