私はマップでロンドンに十字架を描こうとしています。 地理座標系またはWebメタファーのいずれかでポイントの座標を指定すると、コードが機能します。 ED50/UTMゾーン31Nで座標を指定すると機能しません。 ドキュメントによると、Pointコンストラクタは空間参照を最後の引数として取ります。私はこれがポイントが地図(Web mercator)の座標系に変換されることを意味すると思いますか?しかし、この点は現在、フランス中部のどこかに現れています。ここで何が起こっているのか分かりませんか?Web Mercator以外の投影座標系でマップにグラフィックスを追加するにはどうすればよいですか?
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>London Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<script src="https://js.arcgis.com/3.17/"></script>
<script>
var map;
require(["esri/map", "esri/geometry/Point", "esri/SpatialReference", "esri/graphic", "dojo/domReady!"], function (Map, Point, SpatialReference, Graphic) {
map = new Map("map", {
basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
center: [0.1, 51.5], // longitude, latitude
zoom: 8
});
map.on("load", function() {
//var P = new Point({ "x": 0.1, "y": 51.5, "spatialReference": { "wkid": 4326 } }); // geographic: works!
//var P = new Point({ "x": -10978, "y": 6708911, "spatialReference": { "wkid": 102100 } }); // web mercator: works!
//var P = new Point({ "x": 284879, "y": 5711864, "spatialReference": { "wkid": 23031 } }); // somewhere in the middle of France !!??
var P = new Point([284879, 5711864], new SpatialReference({ wkid: 23031 })); // somewhere in the middle of France !!??
var pointSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_X, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0]), 2), new dojo.Color([0, 255, 0, 0.25]));
var mapPointGraphic = new Graphic(P, pointSymbol);
map.graphics.add(mapPointGraphic);
});
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
ありがとうTカンビ!今は、Pointコンストラクタの空間参照引数が意味をなさないので、削除する必要があります。ロンドンのWeb Mercator座標系を使ってPointを作成しましたが、別の空間参照を使用していましたが、それはまだロンドンで描かれました。だから、空間参照の議論は無視されるようです。 – Andy