|
POST
|
Actually, you can keep the ShowLocation function outside the init function. However, the variable "map" was declared inside the init function, so it was only usable with all the properties you set in that function. When you used the variable "map" in the ShowLocation function, you were in a sense creating another variable "map". Take a look at these articles that talk about the scopt of variables. This would work equally well. Notice where the variable "map" is declared. <!DOCTYPE html> <html> <head> <title>Create a Map</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <link rel="stylesheet" href="http://js.arcgis.com/3.8/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css"> <style> html, body, #mapDiv { padding: 0; margin: 0; height: 100%; } </style> <script src="http://js.arcgis.com/3.8/"></script> <script> dojo.require("esri.map"); var map; function init() { map = new esri.Map("mapDiv", { center: [-56.049, 38.485], zoom: 3, basemap: "streets" }); dojo.connect(map, "onLoad", function () { ShowLocation(150, -33); }); } function ShowLocation(x, y) { var point = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 })); map.graphics.add(new esri.Graphic(point, new esri.symbol.SimpleMarkerSymbol())); } dojo.ready(init); </script> </head> <body class="claro"> <div id="mapDiv"></div> </body> </html> As a side note, if you're learning how to use the JavaScript API, I would recommend that you learn how to use the AMD style of coding. At some point in the future, using dojo.connect will be depreciated.
... View more
01-16-2014
05:26 AM
|
0
|
0
|
844
|
|
POST
|
You should mark your own post as having answered the question. This will help others when they are searching for a solution to this question.
... View more
01-15-2014
03:44 AM
|
0
|
0
|
1956
|
|
POST
|
If you right click on the page, you can see the code using View Source (IE) or View Page Source (Chrome and Firefox).
... View more
01-14-2014
08:26 AM
|
0
|
0
|
2337
|
|
POST
|
I used an existing sample and inserted this code var url = "http://www.esri.com"; var template = new esri.InfoTemplate("", "${Postal Address} <br/> Owner of record: ${First Owner Name} <br/>" + "<a target='_blank' href=" + url +">Esri home page</a>");
... View more
01-14-2014
04:55 AM
|
0
|
0
|
930
|
|
POST
|
Glad to help. Definitely read up on the events topic in the documentation. And don't forget to click the check mark on the post that answered your question. It will help others searching for this same answer in the future.
... View more
01-13-2014
10:22 AM
|
0
|
0
|
526
|
|
POST
|
Try this instead require(["esri/map", "dojo/domReady!", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/SpatialReference",], function(Map) { var layer1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/carte1/MapServer"); map = new Map("maptest1"); map.addLayers([layer1]); map.on("layers-add-result", function(){ var extent = layer1.fullExtent; map.setExtent(extent); alert(extent.xmax); }); });
... View more
01-13-2014
10:02 AM
|
0
|
0
|
3545
|
|
POST
|
You may be checking the fullExtent property before the layer is ready. Try getting the full extent in the layer's load event.
... View more
01-13-2014
09:45 AM
|
0
|
0
|
3545
|
|
POST
|
I think what you're going to have to do is use a Geometry Service to project it. If I use Jon's code, I get a point at 0, 0. [ATTACH=CONFIG]30405[/ATTACH] I went to this sample, added the wkid 26973 to the list, and used the geometry service to get the projected coordinate, which comes out to be somewhere in Kentucky (-84.5304109050132, 36.8066895277335). Not surprising, since this wkid is Indiana State Plane (NAD_1983_StatePlane_Indiana_East_FIPS_1301).
... View more
01-10-2014
11:43 AM
|
0
|
0
|
2409
|
|
POST
|
But you can get back many results from executing an IdentifyTask identifyTask.execute(identifyParams, function (results) { console.log(results.length); });
... View more
01-10-2014
10:27 AM
|
0
|
0
|
1340
|
|
POST
|
It's not that these coordinate aren't 10200. They're just located very close to 0°N, 0°W
... View more
01-10-2014
09:04 AM
|
0
|
0
|
2409
|
|
POST
|
Are you sure those are the correct coordinates for the line? If you change the first coordinate, you'll see the line off the coast of Africa.
var polylineJson2 = { "paths":[[[2013940.01178484457,1736610.08635829584],... Also, can you get in the habit of putting your code within the CODE tags? It makes it much easier to read.
... View more
01-10-2014
08:57 AM
|
0
|
0
|
1205
|
|
POST
|
It could be an issue where the map hasn't been initialized by the time you try to get its spatialReference property. Have you tried putting this in the map's onLoad or onLayersAddResult event?
... View more
01-10-2014
04:15 AM
|
0
|
0
|
1560
|
|
POST
|
Executing a QueryTask will return a FeatureSet. You can use "graphicsUtils.graphicsExtent" to get the extent of the FeatureSet
... View more
01-10-2014
04:02 AM
|
0
|
0
|
2193
|
|
POST
|
I'm glad to help. Please remember to click the check mark if this answered your question. This helps others searching for a similar answer.
... View more
01-09-2014
11:17 AM
|
0
|
0
|
2337
|
|
POST
|
You can set the content of an infoWindow to be just about anything you want. I don't know of any specific popup that would have the capability of what you're looking for, but you can be quite creative. It's just a matter of coding it. You've probably seen the samples of Popup and InfoWindows that show several different ways of formatting it. Here's an example where I use a dGrid to show the results of an IdentifyTask for multiple layers in a dynamic layer.
... View more
01-09-2014
09:01 AM
|
0
|
0
|
2337
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|