I have an old script that I am trying to use and it does not seem to work. The topo comes up but when I enter an XY and hit Go nothing happens....
I updated the 2 lines below
<link rel="stylesheet" href="https://js.arcgis.com/3.19/esri/css/esri.css">
<script src="https://js.arcgis.com/3.19/"></script>
Does ANYTHING stand out that is not used in the current js 3.19?
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.19/esri/css/esri.css">
<script src="https://js.arcgis.com/3.19/"></script>
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #FFF;
overflow: hidden;
font-family: "Trebuchet MS";
}
</style>
<script>
var map;
require(["esri/map",
"esri/symbols/SimpleLineSymbol",
"esri/graphic",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"dojo/on",
"dojo/dom",
"esri/geometry/Point",
"dojo/domReady!"
],
function(Map, SimpleLineSymbol, Graphic, SimpleMarkerSymbol, Color, on, dom, Point) {
map = new Map("map", {
basemap: "topo",
center: [-122.45, 37.75], // longitude, latitude
zoom: 13
});
var symbol = new SimpleMarkerSymbol(
SimpleMarkerSymbol.STYLE_CIRCLE,
15,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([0, 0, 255, 0.5]),
8
),
new Color([0, 0, 255])
);
function coordinates() {
console.log("Coordinates")
var lat = document.getElementById("sel_lat").value
var longitude = document.getElementById("sel_long").value
var coord = webMercatorUtils.lngLatToXY(longitude, lat);
var mp = new Point(longitude, lat);
var graphic = new Graphic(mp, symbol);
map.graphics.add(graphic);
map.centerAndZoom(mp, 9);
}
on(dom.byId("go"), "click", coordinates);
});
</script>
</head>
<body>
<div id="map">Tag Long:<input id="sel_long" type="text">
<br />
Tag Lat:<input id="sel_lat" type="text">
<br />
<button id="go">GO</button>
</div>
</body>
</html>
Solved! Go to Solution.
Jay,
You haven't declared the webMercatorUtils used on line 56ish...
Regards,
Tom
Jay,
You haven't declared the webMercatorUtils used on line 56ish...
Regards,
Tom
Got it...think this is what you were referring too.
require(["esri/map",
"esri/geometry/webMercatorUtils",
"esri/symbols/SimpleLineSymbol",
"esri/graphic",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"dojo/on",
"dojo/dom",
"esri/geometry/Point",
"dojo/domReady!"
],
function(Map, webMercatorUtils, SimpleLineSymbol, Graphic, SimpleMarkerSymbol, Color, on, dom, Point) {
Jay,
yes! That should do it.
Regards,
Tom