我编写此代码是为了在 javascript 中的 Esri Arcgis 地图上显示标记,但这不起作用,请在我的代码中描述这里的问题?
I wrote this code to show the marker on my Esri's Arcgis map in javascript, but this doesn't work, Please describe the problem here in my code?
我需要有关在我的 arcgis 地图集成中正确实施 Graphic 和 GraphicLayer 的说明
{ <script src="https://js.arcgis.com/4.12/"></script>
<script>
require([
"esri/Map",
"esri/graphic",
"esri/views/MapView",
"esri/geometry/Point",
"esri/graphic",
"esri/symbols/PictureMarkerSymbol",
"esri/layers/GraphicsLayer",
"esri/dijit/BasemapToggle",
"esri/dijit/HomeButton"],
function (Map, MapView, Point, Graphic, GraphicsLayer,
PictureMarkerSymbol) {
var map = new Map({
basemap: "hybrid"
});
on(map, "load",addgraphics);
var view = new MapView({
container: "viewDiv",
map: map,
center: [72.952335,19.180190],
zoom: 15
});
var marker = new PictureMarkerSymbol('http://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png', 32, 32);
function addgraphics(){
var markerPoint = new Point([72.952335,19.180190]);
var storepoint = new Graphic(markerPoint,marker);
var layer = new GraphicsLayer();
layer.add(storepoint);
view.addLayer(layer);
}
});
}
我希望输出应该是一张带有指定纬度和经度标记的地图。
输出是空白的空白,我认为这是错误的。
检查这个例子。 https://codepen.io/mcantonbul/pen/vYBdVmQ
错误是层被添加到 "Map" 对象,而不是 "MapView" 对象。
view.addLayer(layer);
至
map.add(layer);
和
var markerPoint = new Point([72.952335,19.180190]);
至
var markerPoint = new Point({x:72.952335,y:19.180190});
我需要有关在我的 arcgis 地图集成中正确实施 Graphic 和 GraphicLayer 的说明
{ <script src="https://js.arcgis.com/4.12/"></script>
<script>
require([
"esri/Map",
"esri/graphic",
"esri/views/MapView",
"esri/geometry/Point",
"esri/graphic",
"esri/symbols/PictureMarkerSymbol",
"esri/layers/GraphicsLayer",
"esri/dijit/BasemapToggle",
"esri/dijit/HomeButton"],
function (Map, MapView, Point, Graphic, GraphicsLayer,
PictureMarkerSymbol) {
var map = new Map({
basemap: "hybrid"
});
on(map, "load",addgraphics);
var view = new MapView({
container: "viewDiv",
map: map,
center: [72.952335,19.180190],
zoom: 15
});
var marker = new PictureMarkerSymbol('http://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png', 32, 32);
function addgraphics(){
var markerPoint = new Point([72.952335,19.180190]);
var storepoint = new Graphic(markerPoint,marker);
var layer = new GraphicsLayer();
layer.add(storepoint);
view.addLayer(layer);
}
});
}
我希望输出应该是一张带有指定纬度和经度标记的地图。 输出是空白的空白,我认为这是错误的。
检查这个例子。 https://codepen.io/mcantonbul/pen/vYBdVmQ
错误是层被添加到 "Map" 对象,而不是 "MapView" 对象。
view.addLayer(layer);
至
map.add(layer);
和
var markerPoint = new Point([72.952335,19.180190]);
至
var markerPoint = new Point({x:72.952335,y:19.180190});