这是现在的javascript。注意事项:
这一切都在我的机器上本地运行
food.csv与主HTML文件
我从ESRI的开发者网站获得了静态图像。
到目前为止,当我在浏览器中加载时,地图运行正常。但是,我不知道为什么CSVLayer没有被渲染。请帮忙!
<script src="https://js.arcgis.com/3.20/"></script>
<script>
var map;
require([
"esri/map",
"esri/layers/CSVLayer",
"esri/symbols/PictureMarkerSymbol",
"esri/renderers/SimpleRenderer",
"dojo/domReady!"
],
function(Map, CSVLayer, PictureMarkerSymbol, SimpleRenderer) {
var map = new Map("map", {
basemap: "gray",
center: [-.1, 34.75], // longitude, latitude
zoom: 2
});
// CSV Layer created using the fields we want to bring through to the client
var layer = new CSVLayer("food.csv", {
fields: [{name: "amount", type: "Number"}]
});
var logo = new PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Basic/YellowStickpin.png", 16, 11); // Define a marker image
var simpleRenderer = new SimpleRenderer(logo); // Define a new renderer
layer.setRenderer(simpleRenderer); //Set the simple point renderer to the feature layer
map.addLayer(layer); // Add the layer to the map
});
</script>
答案 0 :(得分:0)
我从未设置过网络服务器。代码现在在MAMP上运行并且工作正常。