POST
|
require([
"esri/views/MapView",
"esri/WebMap",
"esri/Graphic",
"esri/geometry/Point",
"dojo/domReady!"
], function(MapView, WebMap, Graphic, Point) {
/**************************************************
* Create the map and view
**************************************************/
var webmap = new WebMap({
portalItem: {
id: "35277b863fde4449849662393868457e"
}
});
var view = new MapView({
container: @divId,
map: webmap,
zoom: 9,
center: [-95.3630556, 29.7630556] // longitude, latitude
});
for(var i=0, il=data.length; i<il; i++){
var p = new Point({
longitude: data.XCoordinate,
latitude: data.YCoordinate,
spatialReference: { wkid: 4326 }
});
var g = new Graphic({
geometry: p,
symbol: {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
style: "square",
color: "blue",
size: "8px", // pixels
outline: { // autocasts as new SimpleLineSymbol()
color: [255, 255, 0],
width: 3 // points
}
}
}) //had to remove the semicolon that was here too!
view.graphics.add(g);
}
}); The above is my working solution. I had a semicolon in the code as well that was causing issues.
... View more
11-13-2017
06:36 AM
|
0
|
0
|
1028
|
POST
|
Here's the source code. I still can't figure out how to add it using the "source code" button. <script> require([ "esri/views/MapView", "esri/WebMap", "esri/layers/FeatureLayer", "esri/Graphic", "esri/geometry/Point", "dojo/domReady!" ], function(MapView, WebMap, FeatureLayer, Point, Graphic) { var newdata, lyr; /************************************************** * Define the specification for each field to create * in the layer **************************************************/ /************************************************** * Create the map and view **************************************************/ var webmap = new WebMap({ portalItem: { id: "35277b863fde4449849662393868457e" } }); var view = new MapView({ container: "viewDiv", map: webmap, zoom: 10, center: [-95.3630556, 29.7630556] // longitude, latitude }); for(var i=0, il=data.length; i<il; i++){ var p = new Point({ longitude: data.XCoordinate, latitude: data.YCoordinate, spatialReference: { wkid: 4326 } }); var g = new Graphic({ geometry: p, symbol: { type: "simple-marker", // autocasts as new SimpleMarkerSymbol() style: "square", color: "blue", size: "8px", // pixels outline: { // autocasts as new SimpleLineSymbol() color: [255, 255, 0], width: 3 // points } } }); view.graphics.add(g); } }); </script>
... View more
11-10-2017
12:58 PM
|
0
|
1
|
910
|
POST
|
This has to be one of the easiest things there is, as there are no examples for it, except for the complex examples. I am getting an error from the MapView.js about a "type" being null. I am able to plot single points, but not more than one. I am able to see my data going into the Latitude and Longitude, but I must be missing something.
... View more
11-10-2017
12:58 PM
|
0
|
2
|
2009
|
POST
|
I have tried to follow the example at https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/index.html The first issue I have is that I am not using any URL to get my data. I have a .cshtml page and my data is stored in my ViewBag, which I store in a script variable. <script> var data = [{"MAST_REL":"704834405041S00676","XCoordinate":-95.455847,"YCoordinate":29.912856},{"MAST_REL":"706050261041C40974","XCoordinate":-95.465469,"YCoordinate":30.074337}]; </script> Secondly, I get an error message: Object doesn't support property or method 'then' which is thrown from the createGraphics method. My abbreviated code: view.then(function() { createGraphics() .then(createLayer) // when graphics are created, create the layer .otherwise(errback); }); function createGraphics() { debugger; // Create an array of Graphics from each GeoJSON feature return data.map(function(feature, i) { return { geometry: new Point({ x: feature.XCoordinate, y: feature.YCoordinate }), // select only the attributes you care about attributes: { ObjectID: i, //title: feature.properties.title, //type: feature.properties.type, //place: feature.properties.place, //depth: feature.geometry.coordinates[2] + " km", //time: feature.properties.time, //mag: feature.properties.mag, //mmi: feature.properties.mmi, //felt: feature.properties.felt, //sig: feature.properties.sig, //url: feature.properties.url } }; }); } The last couple of issues. I am not familiar with JavaScript nor the GIS ESRI Api. Thanks. Also, the "Source Code" button is not working or I don't know how to use that either. I'd think you would highlight the source code and select it.
... View more
11-10-2017
07:34 AM
|
0
|
2
|
2807
|
POST
|
The page displays now, even on the codepen page! Yesterday that page was blank too. Thanks so much for all the information!
... View more
10-24-2017
06:54 AM
|
0
|
0
|
276
|
POST
|
I was using IE 11. Its the standard browser here. I will look at the new post.
... View more
10-24-2017
06:44 AM
|
0
|
0
|
276
|
POST
|
I did that, received the same Syntax error as I posted above.
... View more
10-24-2017
06:16 AM
|
0
|
3
|
276
|
POST
|
No. I just created an HTML page on my computer and tried to open it. I could move it to a server to try it. I did select Allow All Content when prompted.
... View more
10-23-2017
02:20 PM
|
0
|
0
|
607
|
POST
|
When I copy that code into an HTML page, it only loads a blank page. No map and nothing happens.
... View more
10-23-2017
01:44 PM
|
0
|
10
|
607
|
POST
|
I still do not see how to pass the result to the map to plot the point returned. There are no code samples, just samples on how to call the API. Thanks for your patience.
... View more
10-23-2017
12:27 PM
|
0
|
12
|
607
|
POST
|
I have looked at the sample code which creates something far more complex than I am looking for. I'd like to be able to click a link containing the address, which goes to my page with the Map on it. I'd like to see the particular address marker, just as if you had typed in the Search widget, but without the necessity to even see a Search widget. I am successfully able to load the map, but unable to figure out how to set a location by address. Thanks.
... View more
10-23-2017
11:56 AM
|
0
|
14
|
1056
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|