|
POST
|
Welcome to the forum pavan.adiga. A couple of things: 1) Dojo and the jsapi have moved to AMD style coding. In the interest of creating better apps and getting help here, you should switch as soon as possible. 2) Please wrap your code in code tags. Select your code and click the code button (# sign). 3) You identified the problem as inside your init function, but you didn't post it. 4) insertBefore is very general. This is a javascript method and a method found throughout the dojo (and jsapi) framework. Something in your code is trying to insert a dom node in a parent node doesn't exist. Identifying your issue is going to require posting more code. Hope this helps.
... View more
01-27-2014
08:52 AM
|
0
|
0
|
458
|
|
POST
|
Thanks Roberto. That works. It's just curious that all other symbol types and their respective set methods work in that manner but these two don't.
... View more
01-22-2014
03:16 PM
|
0
|
0
|
786
|
|
POST
|
Polygon outline setStyle() and setWidth() are not updating the graphic in the map but the object is updating. These are the only two that aren't working for all symbol types and settings. A fiddle to demonstrate. The functions in question: updateLineType: function (value, graphic) { switch (graphic._type) { case 'polyline': graphic.symbol.setStyle(value); break; case 'polygon': //what is wrong with setting polygon outline style????? graphic.symbol.outline.setStyle(value); break; } graphic.getLayer().refresh(); }, updateLineWidth: function (value, graphic) { switch (graphic._type) { case 'polyline': graphic.symbol.setWidth(value); break; case 'polygon': //what is wrong with setting polygon outline width????? graphic.symbol.outline.setWidth(value); break; } graphic.getLayer().refresh(); },
... View more
01-21-2014
05:30 PM
|
0
|
3
|
1264
|
|
POST
|
Why is the layerName empty when you do an identify on a raster layer?? The layerId is populated correctly. Not 100% sure about this, but...I think it's because AGS is generating and returning a point independent of the raster for the result, unlike an identify on a point layer, which is returning an actual point. displayField is empty because it doesn't exist in a raster. layerName is empty because the point doesn't belong to the dataset so to speak. The layerId is populated simply to identify which layer the return point was generated from. The REST API could probably be enhanced to include layerName, but from my standpoint it's unnecessary.
... View more
01-10-2014
12:02 PM
|
0
|
0
|
2867
|
|
POST
|
Is there a simple way to just reset esriBundle? After reassigning values, and after say the draw operation is complete, I reset with a helper function like: var s = esriBundle.toolbars.draw;
s.addPoint = "Click to add a point";
s.freehand = "Press down to start and let go to finish";
//and so on Because esri/nls/jsapi isn't a constructor it can't just be recreated. So is there an easier way? Side note to Derek Swingley: Perhaps the Default API Configurations and Default API Strings docs can also added to the reference. I see why they're in Working with the API, but at the same time both are of reference in nature.
... View more
01-10-2014
08:36 AM
|
0
|
0
|
450
|
|
POST
|
The legend widget doesn't like token appended urls. When you load a layer with a token, it is stored elsewhere in the layer object and can be accessed via layer._getToken(). This is what esri widgets use. If you look at the legend request you'll see a malformed url. Reset the layer.url object after adding layer: var url = 'http://server/arcgis/rest/services/beer/MapServer'; var token = 'my_token'; var layer = new ArcGISDynamicMapServiceLayer(url + '?token=" + token, { id: 'some_layer' }); map.addLayer(layer); layer.url = url;
... View more
01-03-2014
01:46 PM
|
0
|
0
|
677
|
|
POST
|
I posted an idea here, which suggests enableSnapping() check for an existing instance of snapping manager and use its options when recreating the snapping manager. enableSnapping() with custom options works great when called after all layers are added; however in a scenario where the user will load feature layers and add graphic layers all the options are lost when calling enableSnapping() to include the newly added layer, unless the options are created and passed again. Because the layers are being added by custom classes/widgets, the move away from globals, and the nature of AMD, I found myself passing an object of the options all over the place. I've since added my own method to my extended map class which does just this, but having enableSnapping() check for and reuse the options seems like something the api should do.
... View more
01-02-2014
01:32 PM
|
0
|
0
|
576
|
|
POST
|
The hatch patterns cannot be altered via the api because they are images. Only STYLE_SOLID will use the color provided. STYLE_SOLID and STYLE_NULL are the only "pure" esri/symbol/SimpleFillSymbol(s). All the other fill options like STYLE_BACKWARD_DIAGONAL, are actually esri/symbol/PictureFillSymbol(s), which use images that are included in the api http://js.arcgis.com/3.7/js/esri/images/symbol/sfs/vertical.png. The solution, work-around or what have you is to use esri/symbol/PictureFillSymbol with your own custom images.
... View more
01-02-2014
07:11 AM
|
1
|
0
|
3137
|
|
POST
|
Despite the map being display:none on load, set the map's width and height with css. Create the map with your init function, but don't add layers. Then use whatever function you're using to set the map's display to block to add the layers and graphics after the map's display has been changed.
... View more
12-11-2013
09:39 AM
|
0
|
0
|
1143
|
|
POST
|
Sure:
var connects = [];
function reset() {
dojo.forEach(connects, dojo.disconnect);
connects = [];
};
//elsewhere
reset();
var mapClick = dojo.connect(map, 'onClick', function(evt) {
dojo.disconnect(mapClick);
//do stuff
});
connects.push(mapClick); And not to push AMD on you, but it's the way to go. 😉
... View more
12-11-2013
09:31 AM
|
0
|
0
|
1446
|
|
POST
|
Create the map as you were and add the graphics after the map's display has been changed.
... View more
12-11-2013
05:05 AM
|
0
|
0
|
1143
|
|
POST
|
In general a map dislikes being hidden/display:none when loaded. One solution might be to load the map when the target dom node becomes visible. If your intent is some kind of loading screen you can use dojo/dom-construct destroy() to 'kill' the loading screen. This is what I use for full-page apps. [HTML]<!-- really doesn't matter where this goes: after opening body tag or right before closing body tag --> <div id="loading" style="position:absolute;top:0;right:0;bottom:0;left:0;z-index:9999;background:#FFF;"> <h1>Hold on a second...</h1> <h2>your map is loading.</h2> </div>[/HTML] //at the end of the loading script
//a short timeout just to give basemap tiles a couple seconds to finish loading
setTimeout(function() {
domConstruct.destroy('loading');
}, 2000); I'm not sure if the Problem parsing d="Z" (in svg.js:64) has to do with the map being hidden initially or not. Based on the svg.js and the post you linked, I'd say this is being cased by a feature layer or graphics layer. I can see where loading a feature layer, and while the requests are in progress, the map's visibility or width/height changes might cause an rendering error. Are you loading a feature layer or adding graphics as part of you loading script, prior to and along with the map resize? If none of the above, share a little more on why the map div is hidden on load or the app's loading progression (map creation, layers added, etc).
... View more
12-10-2013
03:56 PM
|
0
|
0
|
1143
|
|
POST
|
Are you using firebug or some other development tools to debug in the browser? Using such allows you to view the actual request and the response from the server. Instead of using alert(), try using console.log(idResults). Then you'll see the response in the console. Here's the response from an identify of a raster layer: [ATTACH=CONFIG]29726[/ATTACH] Notice the raster values are returned in the attributes object just like a vector data identify of query. The reason your alert is undefined is because idResults[0]['pixel value'] is undefined. Try idResults[0].attributes['Pixel Value']. You'll also notice there is a space in the attribute keys. This is unique in attributes returned from AGS. In a shp or gdb feature class attributes you can't have spaces. Normally you would be able to access a specific attribute like results[0].attributes.parcelId, but this is not possible with the space. results[0].attributes.Pixel Value will return an error so you do need to use results[0].attributes['Pixel Value'].
... View more
12-10-2013
07:00 AM
|
0
|
0
|
2867
|
|
POST
|
The map on the client is a rectangle with dimensions in pixels. Most of the time as developers, and certainly for users, we think in terms of the coordinate system and its units, however in regard to displaying layers, graphics, info window, etc in the map, the api thinks in terms of pixels. So what we end with is a grid in pixels (integers) say 600 x 400 representing thousands, if not millions of map units, which are not integers. The values the api uses (10 -11 ) in web mercator and as shown in your fiddle are less than a nanometer. When the api creates a map, the spatial reference of the map is set by the first layer added to the map, unless otherwise specified. And if it's a tiled layer the map sets its levels of detail (LODS) based on the layer's LODS, unless otherwise specified. So when using the basemap option when creating the map, the map is set to web mercator and the standard web map LODS. When the map's LODS are set, the map will only use those specific LODS. Here's 2 standard web mercator LODS: { level: 14, resolution: 9.55462853563415, scale: 36111.909643 },
{ level: 15, resolution: 4.77731426794937, scale: 18055.954822 } With the map's LODS set, any action which changes the extent will use the LODS to the nearest available scale: map.setScale(18000);
console.log(map.getScale()); //returns 18055.954822
map.setScale(27082);
console.log(map.getScale()); //returns 18055.954822
map.setScale(27084);
console.log(map.getScale()); //returns 36111.909643 For level 14 we have a scale, for which an inch measured on the screen, theoretically represents 36111.909643 inches on the ground, just like a paper map. The resolution represents the number of meters per pixel. Here we have 14 decimal places, which is important when representing the projected data in our pixel grid. If we have 2 point graphics of a feature layer, and the map scale is 36111.909643, unless the points are more that 9.55462853563415 meters apart in both x and y coordinates, they will have the same x,y screen point. As you know using extent.expand() expands the extent by the factor provided. The map.setExtent method takes an extent as it's first argument and a boolean as an optional second argument telling the api whether or not to fit the extent in the map. The fit option really only comes into play when the map's LODS are set. If the LODS are not set, the resulting map extent will fit the extent in x or y, whichever is larger in the extent in map units. When expanding the map's extent in this case, no matter what the expand factor is or the map's dimensions in pixels, the resulting map extent and the extent should be the same. Although I suspect you may find some small differences beyond 4 or 5 decimal places none the less. When the LODS are set, as shown above, the map is confined to the nearest scale. This is where the fit option comes into play. If set to true, and the nearest scale doesn't fit the extent in either the x or y, the map goes to the next LOD. In a web mercator map with standards LODS: if your map was square (400x400 pixels) and you expand by integers you should end up with a map extent which pretty closely matches the extent you set.
... View more
12-07-2013
01:32 PM
|
0
|
0
|
1760
|
|
POST
|
If you're initiating identify with map onClick you can use dojo/on once. on.once(map, 'click', function(evt) {
//do stuff
}); To manage the event outside itself. var clickTheMap = on(map, 'click', function(evt) {
//remove event when fired (equivalent to on.once)
clickTheMap.remove();
clickTheMap = null;
//do stuff
});
on(myCancelButton, 'click', function() {
if(clickTheMap) {
clickTheMap.remove();
}
}); If you have a lot of map events consider a helper class to manage said events. Here's the relevant parts of mine. Keep in mind I just copy/pasted this as an example to illustrate to concept. Will probably take some adaptation to implement in your app. /* map event handling */
// primarily used for map 'click' events
// however any on-style event can be added
// does not support connect events
eventAdd: function (event) {
this.eventOns.push(event);
},
eventBegin: function () {
this.infoWindow.hide();
this.infoWindow.clearFeatures();
this.setMapCursor('default');
this.eventMouseEventsDisable();
arrayUtils.forEach(this.eventOns, function (o) {
o.remove();
});
this.eventOns = [];
if (this.drawToolbar._geometryType != null) {
this.drawToolbar.deactivate();
}
var s = esriBundle.toolbars.draw;
s.addPoint = 'Click to add a point';
s.freehand = 'Press down to start and let go to finish';
s.start = 'Click to start drawing';
s.resume = 'Click to continue drawing';
s.complete = 'Double-click to finish';
},
eventEnd: function () {
this.setMapCursor('default');
this.eventMouseEventsEnable();
this.toaster.hide();
},
eventReset: function () {
this.eventBegin();
this.eventEnd();
},
eventMouseEventsEnable: function () {
arrayUtils.forEach(this.graphicsLayerIds, function (layer) {
this.getLayer(layer).enableMouseEvents();
}, this);
},
eventMouseEventsDisable: function () {
arrayUtils.forEach(this.graphicsLayerIds, function (layer) {
this.getLayer(layer).disableMouseEvents();
}, this);
}, Used like this. this.map.eventBegin();
this.map.setMapCursor('crosshair');
this.map.drawToolbar.activate('point');
var o = on.once(this.map.drawToolbar, 'draw-end', lang.hitch(this, function (result) {
this.map.eventEnd();
//do stuff
}));
this.map.eventAdd(o);
... View more
12-06-2013
09:41 AM
|
0
|
0
|
1446
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-18-2013 06:56 AM | |
| 1 | 06-30-2015 09:17 AM | |
| 1 | 10-12-2013 07:14 AM | |
| 1 | 02-05-2014 11:05 AM | |
| 1 | 05-28-2015 11:41 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|