|
POST
|
Hey Ibrahim, I have created this Javascript API - Advanced Draw widget Maybe that can help you Tim
... View more
09-15-2014
09:58 AM
|
1
|
1
|
1522
|
|
POST
|
Hey Jules, I just tested it and you are right. Even though it throws this error, it still takes me to the right place. Thats at least something You should send an email here [email protected] They should be able to answer you. Tim
... View more
09-15-2014
06:58 AM
|
0
|
1
|
938
|
|
POST
|
Hey Richard, when you talk about the sandbox, are you talking about this? ArcGIS API for JavaScript Sandbox 1) I am using the sandbox a lot and everything works fine, maybe there is something missing in your code and that is why it is not working? I recommend using notepad++, create an html document and put it in your wwwroot folder. With this you can open your map in chrome or firefox and use the developer tools to see whats wrong with your code. 2) You can test the services by putting them into your browser. http://sampleserver1.arcgisonline.com/ArcGIS/rest/services If you can see them, then they work and there must be something wrong with your code. 3) I started by learning html and javascript through codeacademy. Once I felt comfortable with javascript I started here: Tutorials | ArcGIS API for JavaScript and then build from there. Hope this helps! Tim
... View more
09-15-2014
05:38 AM
|
0
|
0
|
1244
|
|
POST
|
Yes thats right. I have no idea why the geocoder would not be working, When I use the debugger it does not return anything after I run the geocoder.
... View more
09-12-2014
12:52 PM
|
0
|
0
|
2312
|
|
POST
|
Steven, try this:
<!DOCTYPE html>
<html>
<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">
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">
<title>Geocoder Widget</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
<style>
html, body, #map {
height:100%;
width:100%;
margin:0;
padding:0;
}
body {
background-color:#FFF;
overflow:hidden;
font-family:"Trebuchet MS";
}
#searchbox {
display: block;
position: absolute;
z-index: 2;
top: 20px;
left: 75px;
}
</style>
<script src="http://js.arcgis.com/3.9/"></script>
<script>
var map;
var geocoder;
require([
"esri/map", "esri/dijit/Geocoder", "esri/SpatialReference", "dijit/form/TextBox", "dojo/parser",
"esri/tasks/locator", "dojo/on", "dojo/dom", "dijit/registry", "dijit/form/Button" ,"dojo/domReady!"
], function(
Map, Geocoder, SpatialReference, TextBox, parser, Locator, on, dom, registry
) {
parser.parse();
var locatorUrl = "http://serverapps101.esri.com/arcgis/rest/services/MGRS/GeocodeServer";
var Gridlocator = new Locator(locatorUrl);
var locator = new Locator("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");
var spatialReference = new SpatialReference({wkid:4326});
map = new Map("map",{
basemap: "topo",
center: [-117.19,34.05], // lon, lat
zoom: 13,
spatialReference: spatialReference
});
var GridTextBox = new TextBox({
placeHolder: "18SUJ23480647",
value:"18SUJ23480647"
},"GridTextBoxDiv");
on(registry.byId("grid"), "click", setgrid);
function setgrid (){
var GridPoint = registry.byId("GridTextBoxDiv").get("value");
var gridnmb = {MGRS:GridPoint};
Gridlocator.addressToLocations(gridnmb);
map.graphics.clear();
}
Gridlocator.on("address-to-locations-complete", locateMeGridAddress);
function locateMeGridAddress(evt){
var FoundPointAr = evt.addresses;
var FoundPoint = FoundPointAr[0];
var LocPoint = FoundPoint.location;
map.centerAndZoom(LocPoint);
map.graphics.clear();
}
});
</script>
</head>
<body class="claro">
<div id="map">
<div id="searchbox"><input id="GridTextBoxDiv"/><button id="grid" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button">Get Location</button> </div>
</div>
</body>
</html>
Tim
... View more
09-12-2014
12:19 PM
|
0
|
2
|
2312
|
|
POST
|
Steven, do you need to do it through the geocoder or can you do it through a textbox like i have it? Tim
... View more
09-12-2014
11:18 AM
|
0
|
0
|
2312
|
|
POST
|
Hey Kelly, thanks for the quick reply and thanks for the zip file and the helpful links. At the moment I am working on an Advanced Draw Widget and wanted to include the redo/undo function. Instead of explaining the user how to install modules, I wanted a one-stop shop That is why I wanted to include everything in one file. Btw. let me know what you think of the widget Tim
... View more
09-12-2014
10:54 AM
|
0
|
0
|
1607
|
|
POST
|
Thanks Jake, would I be able to just include that in my application or is there another step I would have to do?
... View more
09-12-2014
10:46 AM
|
0
|
0
|
1607
|
|
POST
|
Maybe this can help? Javascript API - Location Widget
... View more
09-12-2014
07:40 AM
|
0
|
2
|
2312
|
|
POST
|
Hey everybody, I was thinking about implementing the undomanager in my map to remove or re-add graphics. When looking at the example page I found this: Graphics with undo redo | ArcGIS API for JavaScript I am able to get it to work, but I don't want to load an outside module, like they use the customoperation Does anyone have an example where all the code is within the application? Thanks, Tim
... View more
09-12-2014
07:38 AM
|
0
|
4
|
2292
|
|
POST
|
Joanna, I would go in the Javascript API direction. It is free and works across a lot of platforms! Check it out: ArcGIS API for JavaScript Tim
... View more
09-11-2014
09:55 AM
|
0
|
0
|
2179
|
|
POST
|
Great Article! I always hate it when the news reports on Ebola and just names the countries and they don't show any maps. Some people might think it is all over Africa, where as a map can actually show the area affacted. I am a very visual person, I guess thats why I work in GIS , so I need to see where something is, when someone talks about a place.
... View more
09-11-2014
08:50 AM
|
0
|
1
|
1734
|
|
POST
|
I had to upgrade you to 3.10. I had to stop your tracking on line 100 and 101. I removed your legacy code, now your application is AMD. I added lines 234 to 246.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>MCD Mobile GIS</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
<style>
html, body {
height: 100%; width: 100%;
margin: 0; padding: 0;
}
#map{
padding:0;
border:solid 1px #343642;
margin:5px 5px 5px 5px;
}
#titlePane{
width:240px;
}
#LocateButton {
position: absolute;
top: 95px;
left: 20px;
z-index: 50;
}
#top{
width:20%;
border-top: solid 1px #343642;
border-left: solid 1px #343642;
border-bottom: solid 1px #343642;
border-right: solid 1px #343642;
margin:5px 5px 5px 5px;
color: #343642;
font:90% Arial,"Arial",Arial,Arial;
/*letter-spacing: 0.05em;*/
}
</style>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i =i ||function(){
(i .q=i .q||[]).push(arguments)},i .l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-21888440-1', 'wiu.edu');
ga('send', 'pageview');
</script>
<script src="http://js.arcgis.com/3.10/"></script>
<script>
var map, locator;
require([
"esri/map", "esri/tasks/locator", "esri/graphic",
"esri/dijit/InfoWindowLite", "esri/InfoTemplate", "esri/layers/FeatureLayer", "dojo/dom-construct",
"esri/InfoTemplate", "esri/symbols/SimpleMarkerSymbol",
"esri/symbols/Font", "esri/symbols/TextSymbol",
"dojo/_base/array", "dojo/_base/Color",
"dojo/number", "dojo/parser", "dojo/dom", "dojo/on", "dijit/registry",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/dijit/LocateButton",
"esri/dijit/Scalebar",
"esri/dijit/Measurement", "esri/geometry/Extent",
"dijit/form/Button", "dijit/form/Textarea",
"dijit/layout/BorderContainer", "dijit/layout/ContentPane","dijit/TitlePane", "dojo/domReady!"
], function(
Map, Locator, Graphic,
InfoWindowLite, InfoTemplate, FeatureLayer, domConstruct,
InfoTemplate, SimpleMarkerSymbol,
Font, TextSymbol,
arrayUtils, Color,
number, parser, dom, on, registry,
ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, LocateButton, Scalebar, Measurement, Extent
) {
parser.parse();
var initExtent = new Extent({"xmin":-10093755,"ymin":4932648,"xmax":-10093139,"ymax":4933004,"spatialReference":{"wkid":3857}});
var map = new Map("map",{extent:initExtent});
var basemap2 = new ArcGISTiledMapServiceLayer("http://gis.wiu.edu/arcgis/rest/services/basemap/aerial_cache/MapServer",
{"opacity" : 0.6});
map.addLayer(basemap2);
var basemap = new ArcGISDynamicMapServiceLayer("http://gis.wiu.edu/arcgis/rest/services/mcdonough_mobile/MapServer");
map.addLayer(basemap);
geoLocate = new LocateButton({
map: map,
scale: 2400,
//tracking: true,
//useTracking: true
}, "LocateButton");
geoLocate.startup();
var scalebar = new Scalebar({
map: map,
// "dual" displays both miles and kilmometers
// "english" is the default, which displays miles
// use "metric" for kilometers
scalebarUnit: "dual"
});
/*var infoWindow = new InfoWindowLite(null, domConstruct.create("div", null, null, map.root));
infoWindow.startup();
map.setInfoWindow(infoWindow);*/
var template = new InfoTemplate();
template.setTitle("<b>${PARCELID}</b>");
template.setContent("${owner1_name} <br> ${site_address} <br> <a href =${wedge_url} target='_blank'>PRC Link</a>");
//add a layer to the map
var featureLayer = new FeatureLayer("http://gis.wiu.edu/arcgis/rest/services/mcdonough_highway/MapServer/21", {
mode: FeatureLayer.MODE_ONDEMAND,
maxAllowableOffset: 1000,
infoTemplate:template,
outFields: ["PARCELID" , "site_address", "owner1_name", "wedge_url"]
});
map.addLayer(featureLayer);
map.infoWindow.resize(200, 75);
//dojo.keys.copyKey maps to CTRL on windows and Cmd on Mac., but has wrong code for Chrome on Mac
// var snapManager = map.enableSnapping({
//snapKey: has("mac") ? keys.META : keys.CTRL
//});
//var layerInfos = [{
// layer: parcelsLayer
//}];
//snapManager.setLayerInfos(layerInfos);
var measurement = new Measurement({
map: map
}, dom.byId("measurementDiv"));
measurement.startup();
on(dom.byId("address"), "keyup", function(event){
if (event.keyCode == 13 && this.value.length > 0) {
locate();
}
})
locator = new Locator("http://gis.wiu.edu/arcgis/rest/services/mcdonough_structure/GeocodeServer");
locator.on("address-to-locations-complete", showResults);
// listen for button click then geocode
map.infoWindow.resize(200,125);
on(dom.byId("address"), 'onkeyup', function(event) {
if (event.keyCode == 13 && this.value.length > 0) {
locate();
}
});
function locate() {
map.graphics.clear();
var address = {
"Street": dom.byId("address").value
};
locator.outSpatialReference = map.spatialReference;
var options = {
address: address,
outFields: ["HouseNum"]
}
locator.addressToLocations(options);
}
function showResults(evt) {
var candidate;
var symbol = new SimpleMarkerSymbol();
var infoTemplate = new InfoTemplate(
"Location",
"Address: ${address}<br />Score: ${score}<br />Source locator: ${locatorName}"
);
symbol.setStyle(SimpleMarkerSymbol.STYLE_SQUARE);
symbol.setSize(10);
symbol.setColor(new Color("#ffff00"));
var geom;
arrayUtils.every(evt.addresses, function(candidate) {
console.log(candidate.score);
if (candidate.score > 80) {
console.log(candidate.location);
var attributes = {
address: candidate.address,
score: candidate.score,
locatorName: candidate.attributes.StreetName
};
geom = candidate.location;
var graphic = new Graphic(geom, symbol, attributes, infoTemplate);
//add a graphic to the map at the geocoded location
map.graphics.add(graphic);
//add a text symbol to the map listing the location of the matched address.
var displayText = candidate.address;
var font = new Font(
"12pt",
Font.STYLE_NORMAL,
Font.VARIANT_NORMAL,
Font.WEIGHT_BOLD,
"Helvetica"
);
var textSymbol = new TextSymbol(
displayText,
font,
new Color("#ffff00")
);
textSymbol.setOffset(0,15);
map.graphics.add(new Graphic(geom, textSymbol));
return false; //break out of loop after one candidate with score greater than 80 is found.
}
else{
alert("No results found, please enter another address");
}
});
if ( geom !== undefined ) {
map.centerAndZoom(geom, 19);
}
}
map.on("mouse-over", windowPop);
function windowPop(){
if (measurement.area.checked || measurement.distance.checked || measurement.location.checked){
map.setInfoWindowOnClick(false);
} else {
map.setInfoWindowOnClick(true);
}
}
measurement.on("measure-end", function (){
map.setInfoWindowOnClick(true);
});
});
</script>
</head>
<body class="claro">
<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer"
data-dojo-props="design:'sidebar', gutters:false"
style="width:100%; height:100%;">
<div id="top"
data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="region:'top'">
<font size = "3">MCD Mobile</font> <br>
<font size = "2">WIU GIS Center <a href="help.html"><b>Help</b></a></font> <br>
<input type="text" id="address" size="25" autofocus="autofocus"/>
<br>
</div>
<div id="map"
data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="region:'center'">
<div id="LocateButton"></div>
<div style="position:absolute; right:20px; top:10px; z-Index:999;">
<div id="titlePane" data-dojo-type="dijit/TitlePane" data-dojo-props="title:'Measurement', closable:'false', open:'false'">
<div id="measurementDiv"></div>
<span style="font-size:smaller;padding:5px 5px;">Press <b>CTRL</b> to enable snapping.</span>
</div>
</div>
</div>
</div>
</body>
</html>
... View more
09-11-2014
06:15 AM
|
1
|
0
|
543
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-06-2015 06:58 AM | |
| 1 | 05-04-2016 07:27 AM | |
| 1 | 07-06-2017 08:12 AM | |
| 1 | 10-26-2015 11:51 AM | |
| 1 | 12-12-2014 12:05 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|