POST
|
I updated my code as follows, but I get the error Uncaught SyntaxError: Unexpected token ( at the line where I say error occurs here: <!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.11/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css"> <style> html, body, #mapDiv { padding:0; margin:0; height:100%; width:100%; } #titlePane { width:240px; position:absolute; right:20px; top:10px; z-index:999; } .soria .dijitTitlePaneTitle { background: #fff; font-weight:600; border: none; border-bottom:solid 1px #29201A; border-top:solid 1px #29201A; } .soria .dijitTitlePaneTitleHover { background:#eee; } .soria .dijitTitlePaneTitleActive { background:#808775; } .soria .dijitTitlePaneContentOuter { border-right: none; border-bottom: none; border-left: none; } </style> <script src="http://js.arcgis.com/3.11/"></script> <script> var map; require(["esri/map", "esri/config", "dojo/parser", "esri/renderers/SimpleRenderer", "esri/Color", "esri/dijit/Measurement", "esri/dijit/Scalebar", "esri/geometry/Extent", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/ArcGISTiledMapServiceLayer", "esri/layers/LayerDrawingOptions", "esri/SnappingManager", "esri/sniff", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/tasks/GeometryService", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/form/CheckBox", "dijit/TitlePane", "dojo/dom", "dojo/keys", "dojo/on", "dojo/domReady!"], function (Map, esriConfig, parser, SimpleRenderer, Color, Measurement, Scalebar, Extent, ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, LayerDrawingOptions, SnappingManager, has, SimpleFillSymbol, SimpleLineSymbol, GeometryService, dom, keys, on ) { parser.parse(); // set custom extent var initialExtent = new Extent({ "xmin": 777229.03, "ymin": 1133467.92, "xmax": 848340.14, "ymax": 1185634.58, "spatialReference": { "wkid": 3435 } }); // create map and set slider style to small map = new Map("mapDiv", { showAttribution: false, sliderStyle: "small", extent: initialExtent }); // add imagery var tiled = new ArcGISTiledMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Aerial_2014_Tiled/MapServer"); map.addLayer(tiled); // set operational layers var operationalLayer = new ArcGISDynamicMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Public/InternetVector/MapServer", { "opacity": 0.5 }); // add operational layers map.addLayer(operationalLayer); // declare geometry service esriConfig.defaults.geometryService = new GeometryService("http://maps.decaturil.gov/arcgis/rest/services/Utilities/Geometry/GeometryServer"); // start measurement tool - the current layer we are measuring is the operational layer // error follows this line function (LayerDrawingOptions, SimpleRenderer) { var layerDrawingOptions = []; var layerDrawingOption = new LayerDrawingOptions(); var sfs = new SimpleFillSymbol( "solid", new SimpleLineSymbol("solid", new Color([195, 176, 23]), 2), null ); } layerDrawingOption.renderer = new SimpleRenderer(sfs); // change 1 to the layer index that you want to modify: layerDrawingOptions[1] = layerDrawingOption; dynamicData.setLayerDrawingOptions(layerDrawingOptions); //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: operationalLayer }]; snapManager.setLayerInfos(layerInfos); var measurement = new Measurement({ map: map }, dom.byId("measurementDiv")); measurement.startup(); // end measurement tool } ); </script> </head> <body class="soria"> <div id="mapDiv"></div> <div id="titlePane" data-dojo-type="dijit/TitlePane" data-dojo-props="title:'Measurement', closeable:'false',open:'false'"> <div id="measurementDiv"></div> <span style="font-size:smaller;padding:5px 5px;">Press <b>CTRL</b> to enable snapping.</span> </div> </body> </html>
... View more
11-20-2014
07:11 AM
|
0
|
2
|
878
|
POST
|
I tried create the measurement tool based on our web services and I receive the following error message: Uncaught TypeError: undefined is not a function for line 127 What is causing that? Here is my code:
<!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.11/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css">
<style>
html, body, #mapDiv
{
padding:0;
margin:0;
height:100%;
width:100%;
}
#titlePane
{
width:240px;
position:absolute;
right:20px;
top:10px;
z-index:999;
}
.soria .dijitTitlePaneTitle {
background: #fff;
font-weight:600;
border: none;
border-bottom:solid 1px #29201A;
border-top:solid 1px #29201A;
}
.soria .dijitTitlePaneTitleHover
{
background:#eee;
}
.soria .dijitTitlePaneTitleActive
{
background:#808775;
}
.soria .dijitTitlePaneContentOuter
{
border-right: none;
border-bottom: none;
border-left: none;
}
</style>
<script src="http://js.arcgis.com/3.11/"></script>
<script>
var map;
require(["esri/map", "esri/config",
"dojo/parser",
"esri/renderers/SimpleRenderer",
"esri/Color",
"esri/dijit/Measurement",
"esri/dijit/Scalebar",
"esri/geometry/Extent",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/layers/FeatureLayer",
"esri/SnappingManager",
"esri/sniff",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/GeometryService",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/form/CheckBox",
"dijit/TitlePane",
"dojo/dom",
"dojo/keys",
"dojo/on",
"dojo/domReady!"], function (Map, esriConfig, parser, SimpleRenderer, Color, Measurement, Scalebar, Extent,
ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, FeatureLayer, SnappingManager,
has, SimpleFillSymbol, SimpleLineSymbol, GeometryService, dom, keys, on
) {
parser.parse();
// set custom extent
var initialExtent = new Extent({
"xmin": 777229.03,
"ymin": 1133467.92,
"xmax": 848340.14,
"ymax": 1185634.58,
"spatialReference": {
"wkid": 3435
}
});
// create map and set slider style to small
map = new Map("mapDiv", {
showAttribution: false,
sliderStyle: "small",
extent: initialExtent
});
// add imagery
var tiled = new ArcGISTiledMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Aerial_2014_Tiled/MapServer");
map.addLayer(tiled);
// set operational layers
var operationalLayer = new ArcGISDynamicMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Public/InternetVector/MapServer", { "opacity": 0.5 });
// add operational layers
map.addLayer(operationalLayer);
// declare geometry service
esriConfig.defaults.geometryService = new GeometryService("http://maps.decaturil.gov/arcgis/rest/services/Utilities/Geometry/GeometryServer");
// start measurement tool - the current layer we are measuring is the operational layer
var sfs = new SimpleFillSymbol(
"solid",
new SimpleLineSymbol("solid", new Color([195, 176, 23]), 2),
null
);
operationalLayer.setRenderer(new SimpleRenderer(sfs));
//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: operationalLayer
}];
snapManager.setLayerInfos(layerInfos);
var measurement = new Measurement({
map: map
}, dom.byId("measurementDiv"));
measurement.startup();
// end measurement tool
}
);
</script>
</head>
<body class="soria">
<div id="mapDiv"></div>
<div id="titlePane" data-dojo-type="dijit/TitlePane" data-dojo-props="title:'Measurement', closeable:'false',open:'false'">
<div id="measurementDiv"></div>
<span style="font-size:smaller;padding:5px 5px;">Press <b>CTRL</b> to enable snapping.</span>
</div>
</body>
</html>
... View more
11-19-2014
02:01 PM
|
0
|
4
|
2069
|
POST
|
Thanks, I documented that in my code so I would have a reference.
... View more
11-19-2014
09:26 AM
|
0
|
0
|
592
|
POST
|
I added the information in the require statement and the declarations and changed my code as follows (what am I doing wrong?): // modified code starts here function zoomToLocation(location) { var pt = new Point(location.coords.longitude, location.coords.latitude); var params = new ProjectParameters(); params.geometries = [pt]; params.outSR = "3435"; params.transformation = "4326"; esriConfig.defaults.geometryService.project(params); addGraphic(pt); map.centerAndZoom(pt, 12); } function showLocation(location) { //zoom to the users location and add a graphic var pt = new Point(location.coords.longitude, location.coords.latitude); if (!graphic) { var params = new ProjectParameters(); params.geometries = [pt]; params.outSR = "3435"; params.transformation = "4326"; esriConfig.defaults.geometryService.project(params); addGraphic(pt); } else { // move the graphic if it already exists graphic.setGeometry(pt); } map.centerAt(pt); } // modified code ends here
... View more
11-19-2014
07:15 AM
|
0
|
3
|
592
|
POST
|
I was thinking something like this: require(["esri/geometry/Point"], function(Point) { new Point(x,y,3435}); but since it's geolocation I don't know what the x and y will be. And is this code even correct that I wrote?
... View more
11-18-2014
02:22 PM
|
0
|
5
|
973
|
POST
|
Our data uses a wkid of 3435. For accuracy, we need to use the 3435 wkid. The init.js file has a wkid of 4326, but I'm not sure how to work with the two to convert what I need.
... View more
11-18-2014
09:19 AM
|
0
|
0
|
973
|
POST
|
It looks like this would conflict with my extent:initialExtent which uses a different spatial reference. I tried it though and I receive a blank page.
... View more
11-18-2014
08:54 AM
|
0
|
2
|
973
|
POST
|
I am receiving this error when I attempt to use geolocation: Map: Geometry (wkid: 4326) cannot be converted to spatial reference of the map (wkid: 3435) What do I need to add in my following code to make this work? <!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.11/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css"> <style> html, body, #mapDiv { padding:0; margin:0; height:100%; width:100%; } @-webkit-keyframes pulse { 0% { opacity:1.0; } 45% { opacity:.20; } { 100% { opacity:1.0; } } @-moz-keyframes pulse { 0% { opacity:1.0; } 45% { opacity:.20; } 100% { opacity:1.0; } } #map_graphics_layer { -webkit-animation-duration: 3s; -webkit-animation-iteration-count: infinite; -webkit-animation-name: pulse; -moz-animation-duration: 3s; -moz-animation-iteration-count: infinite; -moz-animation-name: pulse; } </style> <script src="http://js.arcgis.com/3.11/"></script> <script> var map; var graphic; var currLocation; var watchId; require(["esri/map", "esri/config", "esri/Color", "esri/geometry/Extent", "esri/geometry/Point", "esri/graphic", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/ArcGISTiledMapServiceLayer", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleMarkerSymbol", "esri/tasks/GeometryService", "dojo/dom", "dojo/on", "dojo/parser", "dojo/domReady!"], function (Map, esriConfig, Color, Extent, Point, Graphic, ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, SimpleLineSymbol, SimpleMarkerSymbol, GeometryService, dom, on, parser ) { // set custom extent var initialExtent = new Extent({ "xmin": 777229.03, "ymin": 1133467.92, "xmax": 848340.14, "ymax": 1185634.58, "spatialReference": { "wkid": 3435 } }); // create map and set slider style to small map = new Map("mapDiv", { showAttribution: false, sliderStyle: "small", extent: initialExtent }); // add imagery var tiled = new ArcGISTiledMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Aerial_2014_Tiled/MapServer"); map.addLayer(tiled); // set operational layers var operationalLayer = new ArcGISDynamicMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Public/InternetVector/MapServer", { "opacity": 0.5 }); // add operational layers map.addLayer(operationalLayer); // declare geometry service esriConfig.defaults.geometryService = new GeometryService("http://maps.decaturil.gov/arcgis/rest/services/Utilities/Geometry/GeometryServer"); // geolocation functionality starts here map.on("load", initFunc); function orientationChanged() { if (map) { map.reposition(); map.resize(); } } function initFunc(map) { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(zoomToLocation, locationError); watchId = navigator.geolocation.watchPosition(showLocation, locationError); } else { alert("Browser doesn't support Geolocation. Visit http://caniuse.com to see browser support for the Geolocation API."); } } function locationError(error) { //error occurred so stop watchPosition if (navigator.geolocation) { navigator.geolocation.clearWatch(watchId); } switch (error.code) { case error.PERMISSION_DENIED: alert("Location not provided"); break; case error.POSITION_UNAVAILABLE: alert("Current location not available"); break; case error.TIMEOUT: alert("Timeout"); break; default: alert("unknown error"); break; } } function zoomToLocation(location) { var pt = new Point(location.coords.longitude, location.coords.latitude); addGraphic(pt); map.centerAndZoom(pt, 12); } function showLocation(location) { //zoom to the users location and add a graphic var pt = new Point(location.coords.longitude, location.coords.latitude); if (!graphic) { addGraphic(pt); } else { // move the graphic if it already exists graphic.setGeometry(pt); } map.centerAt(pt); } function addGraphic(pt) { var symbol = new SimpleMarkerSymbol( SimpleMarkerSymbol.STYLE_CIRCLE, 12, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([210, 105, 30, 0.5]), 8 ), new Color([210, 105, 30, 0.9]) ); graphic = new Graphic(pt, symbol); map.graphics.add(graphic); } } ); </script> </head> <body onorientationchange="orientationChanged();" class="soria"> <div id="mapDiv"></div> </body> </html>
... View more
11-18-2014
07:35 AM
|
0
|
16
|
2594
|
POST
|
That works too. Is there an advantage in placing it within the AMD scope? Does evt serve a purpose for this code block?
... View more
11-17-2014
12:30 PM
|
0
|
5
|
2247
|
POST
|
The alert does not work. I get this in the debugger: Uncaught ReferenceError: clearGraphics is not defined
... View more
11-17-2014
09:52 AM
|
0
|
2
|
2247
|
POST
|
I have an image button that I want to use so I can clear all graphics from a map. I thought it might be map.on, but I am not sure what I should write. Here is my code where I tried to clear the graphics from the map on a button click. <!DOCTYPE html> <html> <head> <title>Decatur GIS Template</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.11/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css"> <style> html, body, #mapDiv { padding:0; margin:0; height:100%; } #HomeButton { position: absolute; top: 95px; left: 20px; z-index: 50; } #LocateButton { position: absolute; top: 140px; left: 20px; z-index: 50; } #clearGraphicsBtn { height:20px; width:20px; position:absolute; top:200px; left:20px; z-index:50; padding:5px 6px 5px 6px; background-color:Gray; border-radius:5px; } </style> <script src="http://js.arcgis.com/3.11/"></script> <script> var map; require(["esri/map", "esri/config", "esri/dijit/HomeButton", "esri/dijit/LocateButton", "esri/layers/ArcGISTiledMapServiceLayer", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/tasks/GeometryService", "dojo/dom", "dojo/on", "dojo/parser", "esri/geometry/Extent", "dojo/domReady!"], function (Map, esriConfig, HomeButton, LocateButton, ArgGISTiledMapServiceLayer, ArcGISDynamicMapServiceLayer, GeometryService, dom, on, parser, Extent ) { // set custom extent var initialExtent = new Extent({ "xmin": 777229.03, "ymin": 1133467.92, "xmax": 848340.14, "ymax": 1185634.58, "spatialReference": { "wkid": 3435} }); map = new Map("mapDiv", { showAttribution: false, sliderStyle: "small", extent: initialExtent }); // add imagery var tiled = new ArgGISTiledMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Aerial_2014_Tiled/MapServer"); map.addLayer(tiled); // add operational layer var operationalLayer = new ArcGISDynamicMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Public/InternetVector/MapServer", { "opacity": 0.5 }); map.addLayer(operationalLayer); // declare geometry service esriConfig.defaults.geometryService = new GeometryService("http://maps.decaturil.gov/arcgis/rest/services/Utilities/Geometry/GeometryServer"); // add home button to get full extent var home = new HomeButton({ map: map }, "HomeButton"); home.startup(); // add geolocate button to find the location of the current user geoLocate = new LocateButton({ map: map, highlightLocation: true }, "LocateButton"); geoLocate.startup(); }, // Clear all graphics from map function clearGraphics() { map.graphics.clear(); } ); </script> </head> <body class="soria"> <div id="mapDiv"> <div id="HomeButton"></div> <div id="LocateButton"></div> <div id="ClearGraphicsButton"> <input type="image" id="clearGraphicsBtn" src="images/nav_decline.png" onclick="clearGraphics()" alt="Clear Graphics" title="Clear Graphics" /> </div> </div> </body> </html>
... View more
11-17-2014
09:37 AM
|
0
|
11
|
6717
|
Title | Kudos | Posted |
---|---|---|
1 | 02-26-2015 12:31 PM | |
1 | 06-24-2015 06:06 AM | |
1 | 07-15-2015 12:34 PM | |
1 | 05-21-2015 02:27 PM | |
1 | 05-19-2015 11:52 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|