|
POST
|
Sorry to get back to you so soon but I am not succeeding here. I am still unclear on how to push graphics to graphic layer. Here is what I have so far:
var gLayer = new GraphicsLayer();
gLayer.id = 'layer1';
map.addLayer(gLayer);
gLayer = new GraphicsLayer();
gLayer.id = 'layer2';
map.addLayer(gLayer);
function coordinates(layer1) {
console.log("Coordinates");
var lat = document.getElementById("sel_lat").value;
var longitude = document.getElementById("sel_long").value;
var mp = new Point(longitude, lat);
AddGraphictoLayer(mp, map.getLayer(layer1), symbol)
map.centerAndZoom(mp, 9);
}
Thank you for your help! Alex
... View more
10-01-2014
02:49 PM
|
0
|
4
|
3220
|
|
POST
|
ok, I will test with unique ids and see how that works for me.
... View more
10-01-2014
02:18 PM
|
0
|
0
|
842
|
|
POST
|
Robert, At the moment you answered, I found this thread : how to clear just one of multiple graphics layers? I am going to dig in Graphic Layer a little to see how it works. Thanks, Alex
... View more
10-01-2014
02:05 PM
|
0
|
6
|
3220
|
|
POST
|
Hi all, I am trying to figure out how to remove graphics from only one function at a time. I have two sets of graphics: the one for drawing polygons and the one to add marker to map when coordinates are added. I always use:
map.graphics.clear();
but it clears ALL the graphs from both functions. Is there a way to keep them separated? My map is here.
function coordinates() {
console.log("Coordinates");
var lat = document.getElementById("sel_lat").value;
var longitude = document.getElementById("sel_long").value;
var mp = new Point(longitude, lat);
var graphic = new Graphic(mp, symbol);
map.graphics.add(graphic);
map.centerAndZoom(mp, 9);
}
function clear() {
console.log("Clearing")
map.graphics.clear();
}
//Button to select features and deactivate select toolbar
on(dom.byId("polygon"), "click", function () {
activateTool(this.id);
});
on(dom.byId("freehandpolygon"), "click", function () {
activateTool(this.id);
});
on(dom.byId("stop"), "click", function () {
map.graphics.clear();
selectionToolbar.deactivate();
});
//Initiate Select Draw tool on map load dojo.connect
dojo.connect(map, "onLoad", function () {
selectionToolbar = new Draw(map);
selectionToolbar.on("draw-end", function (e) {
selectionToolbar.deactivate();
var symbol3 = new SimpleFillSymbol(
"solid",
"solid",
new SimpleLineSymbol("dash", new Color([255, 0, 0]), 2),
new Color([255, 255, 0, 0.25])
);
var graphic = new Graphic(e.geometry, symbol3);
map.graphics.add(graphic);
});
});
function activateTool(tool) {
map.graphics.clear();
// The draw.activate expects a string like "polygon" or "freehand_polygon".
selectionToolbar.activate(tool);
}
Thank you, Alex
... View more
10-01-2014
01:57 PM
|
0
|
8
|
4815
|
|
POST
|
Hi all, Here is my new problem to solve. I am trying to create a draggable panel that would allow the user to enter coordinates and place/zoom a graphic on the map. The function itself works well, however when the function is called from within the draggable panel, it seems like the JS nodes are not discover-able anymore. Not too sure why, must be one of these JQuery/dojo conflicts. Please let me know if you have any idea how to fix this. Here is the link to the map. After clicking on GIS tools click on Search by coordinates and then click on X/Y Toolbar. Thank you, Alex
... View more
10-01-2014
01:44 PM
|
0
|
3
|
2523
|
|
POST
|
Hi Robert, I did figure it out last evening thanks to Vankata's code above. All I really had to do was to use this:
map.centerAndZoom(mp, 9);
So my function would be:
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);
} }
Thank you again for your help! Alex
... View more
09-30-2014
08:54 AM
|
0
|
1
|
1932
|
|
POST
|
Thank you Robert! It works great! I am trying to apply code for an automatic zoom to graphic suggested above by vtammineni.
... View more
09-29-2014
03:09 PM
|
0
|
3
|
1930
|
|
POST
|
Hi all, Here is my new inquiry: I am trying to get the user to add a graphic marker using. I would imagine two text boxes as input values and a simple button GO to add the graphic and then zoom to graphic. Here is what I have so far, My fiddle. Thank you for your help, Alex
... View more
09-29-2014
01:55 PM
|
0
|
8
|
4388
|
|
POST
|
Hi all, I have a pretty general/complex question: My script is here I am trying to re-use the drag and drop code here . within my own JQuery. All I see that is needed are modules and then "mapCanvas" ID to hook up drophandler with the map canvas in html, and the script of course. But I keep getting errors such as "TypeError" (on is undefined) and such. I copied and pasted the template code to my app. What should I modify to make the drag and drop work in my template?? Any tip or advice is welcome. Thank you, Alex
... View more
09-25-2014
01:50 PM
|
0
|
1
|
1062
|
|
POST
|
Alright it does make more sense to me now. I am going to give it a shot and get here if I experience any issues. Thanks for your help! Alex
... View more
09-24-2014
04:07 PM
|
0
|
0
|
2731
|
|
POST
|
Harold and Jonathan, thank you, I think that is the way to go. A few things I need to clear before: 1) Can I pass the selected item value as a variable (ui.item)? In my old script I used a variable "county" as a way to pass the selected value to my query.
query.where = "NAME_PCASE = '" + county + "'";
I am looking to do something similar to the following with autocomplete select: This would , I believe, behave the same way as the autocomplete select
on(registry.byId("sel_unit"), "change", function () {
map.graphics.clear();
extractMethod = "extractByUnit";
});
Then .... I pass the "changed value" to a variable that will be used by my extractbycounty function:
case "extractByCounty":
var county = document.getElementById("sel_county").value;
extractByCounty(county);
break;
Finally, I launch my function this way (just a button click:
registry.byId("extract").on("click", myFunction);
Harold, I am not too sure how to use this in my script:
extractbycounty(ui.value);
Thank you for your help! Alex
... View more
09-24-2014
09:38 AM
|
0
|
2
|
2731
|
|
POST
|
Hi Jonathan, Thank you for your reply. To give you a better idea of what I am trying to achieve here. I started working on a web map that would allow the users to clip and ship using the ESRI template here. I wanted to add to the "Extract Data" tool a selection (for clipping) by "County" geometry and by "Unit" geometry. As you can see my clip and ship, I used a dojo drop down menu which worked great, but It would be much nicer to have a selection process based on JQuery autocomplete. 1) I got my first problem taken care of. You can see my code here. Click on about Tab and you will get my autocomplete box. Solution Code: $(function () { var queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3"); var availableTags = []; var query = new Query(); query.returnGeometry = false; query.outFields = ["STATE_NAME"]; query.where = "OBJECTID > 0"; queryTask.execute(query, function (results) { //parse results and add to autocomplete widget dojo.forEach(results.features, function (value, index) { availableTags.push(value.attributes.STATE_NAME); }); }, function (error) { alert("Error: " + error); }); $("#tags").autocomplete({ source: availableTags }); }); 2) Now here what I cannot figure out. How do I pass the selected autocomplete result to my extractbycounty and extractbyunit functions? I see that the autocomplete has a "select method... not too sure how to use it.
... View more
09-23-2014
11:48 AM
|
0
|
5
|
2731
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-31-2016 11:46 AM | |
| 1 | 10-15-2014 02:17 PM | |
| 1 | 11-19-2015 09:14 AM | |
| 1 | 10-29-2015 04:38 PM | |
| 1 | 02-02-2015 09:55 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-05-2021
12:09 PM
|