|
POST
|
No server side config necessary, you can manually specify zoom levels for a map that doesn't use tiled services. But there's some work involved... Background info: the recommended, default way to use a JS API map is to create a map then add a tiled service. When you add a tiled service to a map, the map automatically uses the levels defined in that service as the levels for the map and sets the map's spatial reference to that of the tiled service. If you're not using a tiled service, the map doesn't know where to find zoom levels so, if you want specific zoom levels, you have to specify them when you create the map (as well as a spatial reference for the map). In my previous post in this thread, I linked to a post that has code that shows this. Here's a simplified version that creates a map, specifies three zoom levels and add a dynamic service. I've also specified sliderStyle: "large" so you can see a slider with ticks that represents the available zoom levels: http://jsbin.com/adesan/1 For you to do this, you need to figure out which scales you want available in your app, then generate an array of LODs (levels of detail) that you pass to the map constructor when you create your map. The smallest scale will be level zero. As scales get larger, level number goes up. Levels also require a value for resolution which is the number of map units per pixel. You can get this number with the following line of code:
map.extent.getWidth() / map.width
Using that line of code along with map.getScale(), you can piece together an array of LODs to give to the map constructor. If you want to specify a specific spatial reference, create an extent and pass that to the map constructor as the extent options. The feature layer in any projection sample is helpful for getting an extent in any spatial reference.
... View more
08-15-2013
02:18 PM
|
0
|
0
|
383
|
|
POST
|
rMap.map.disableScrollWheelZoom();
on(dom.byId(a),(!has("mozilla") ? "mousewheel" : "DOMMouseScroll"), function(e){ scroll(e) });
on(map,"zoom-end",function(){locked=false;applyZoom()});
on(map,"zoom-start",function(){locked=true;newScale=-1;});
var newScale = -1;
var locked = false;
var timer;
function scroll(e)
{ var s = e[(!has("mozilla") ? "wheelDelta" : "detail")] * (!has("mozilla") ? 1 : -1);
if( !locked )
{ rMap.map.onZoomStart();
newScale = rMap.map.getScale();
}
if(s>0) newScale = newScale*0.8;
else newScale = newScale*1.2;
clearTimeout(timer);
timer = setTimeout(function(){rMap.map.onZoomEnd();},1500);
}
function applyZoom()
{ rMap.map.setScale(newScale);
} This correctly queues the scale change up on the client and commits it to a server request as one transaction. The problem is that it does not provide user input that it is doing so (the default behavior of the map object uses a matrix transform on the image to show it zoom in or out.) If I submit a setScale() call with each mouse event, the user has to wait for the map to update before they can submit another. I guess what I want to know is if there's a way to call the function responsible for that transform in the map object, or duplicate it in a way that will not interfere with the map object and/or break on a framework update. There's not a public method to do map image scaling, that happens as part of the zoom process and isn't exposed in the API. Instead of overriding how the map zooms, why not define zoom levels for the map at the various scales you want your users to visit?
... View more
08-15-2013
08:50 AM
|
0
|
0
|
1891
|
|
POST
|
Hi Derek, Can you post your code showing what you have so far? Want to make sure we're on the same page...
... View more
08-14-2013
04:01 PM
|
0
|
0
|
1891
|
|
POST
|
featureSet.features is an array, not an object so doing for ... in isn't applicable. Instead use something like the showResults function from the page you linked to: function showResults(featureSet) { //remove all graphics on the maps graphics layer map.graphics.clear(); //Performance enhancer - assign featureSet array to a single variable. var resultFeatures = featureSet.features; //Loop through each feature returned for (var i=0, il=resultFeatures.length; i<il; i++) { //Get the current feature from the featureSet. //Feature is a graphic var graphic = resultFeatures; graphic.setSymbol(symbol); //Set the infoTemplate. graphic.setInfoTemplate(infoTemplate); //Add graphic to the map graphics layer. map.graphics.add(graphic); } } Also note that setSymbol() method is used rather than setting the symbol property directly.
... View more
08-09-2013
04:09 PM
|
0
|
0
|
636
|
|
POST
|
Using paths or packages is work-able. Do you see a request being made to Scripts/custom/ModTest.js?
... View more
08-09-2013
03:23 PM
|
0
|
0
|
1506
|
|
POST
|
The map's click event is triggered by a mouse click or a tap on a device with a touch screen. This code:
map.on("click", clickHandler);
Will cause the clickHandler function to run if the map is clicked or tapped.
... View more
08-08-2013
03:11 PM
|
0
|
0
|
421
|
|
POST
|
Are you using the API from the CDN or are you hosting it locally? If you're using the CDN, Dojo is looking for your template on the esri server. You should be able to see a request and a 404 when your page looks for Gauge2.html I would define your own namespace rather than putting your code in esri.dijit. Refer to the clustering sample as a way to set up your own namespace (in that sample it's called "extras").
... View more
08-05-2013
01:20 PM
|
0
|
0
|
980
|
|
POST
|
esri/geometry/Extent::contains take a point or extent. Per the docs: Input Parameters: <Geometry> geometry Required Can be a Point or Extent. https://developers.arcgis.com/en/javascript/jsapi/extent.html#contains You could use the extent of your line but not the line itself.
... View more
06-25-2013
02:36 PM
|
0
|
0
|
1176
|
|
POST
|
I would go with approach #1??? destroying and re-creating your map will be easier to manage than removing and then adding new layers to a map. As for your legend not updating, are you using map.addLayers (notice that layers is plural)? Using addLayers should fire onLayersAddResult. It would be helpful if you could post your code showing exactly what you're doing. Here's an example showing using legend.destroy() to get rid of a legend and then re-create it: http://jsfiddle.net/UKNrr/ Notice that the dom element for the legend is created as part of the call to the legend constructor.
... View more
06-24-2013
03:39 PM
|
0
|
0
|
750
|
|
POST
|
Take a look at our getting started page. Personally, I would encourage you to start building something. The best way to learn is by doing. If/when you get stuck, post specific, detailed questions (with broken code!) here or one of the places listed on our community page.
... View more
06-19-2013
06:31 PM
|
0
|
0
|
490
|
|
POST
|
The gas prices by state sample is a simple example that follows the conventions discussed in this thread. The JS API site itself is another example if you example the source.
... View more
06-19-2013
07:32 AM
|
0
|
0
|
1898
|
|
POST
|
We recommend using Dojo's tools for creating classes and modules to manage your code when you start building large apps. Our Dojo and AMD page is the best place to start. You'll find links to writing classes and widgets from there. Regarding MVVM, we don't typically recommend MVVM, MVC or any other flavor of MVW (model-view-whatever). You can use any MVW framework alongside our API, including Backbone, Angular, Ember...the list goes on. Here's a repo that Matt Driscoll and I put together for examples using Backbone, Angular and Knockout at the Esri Dev Summit earlier this year: https://github.com/driskull/framework-samples-js To your last point, about "single responsibility principle for the scope of require([])", I think the answer is yes, if I understand correctly. Typically, in things that I build, I create classes (one per AMD module) and then wire them up with a main.js or app.js file which contains a single require(). I don't typically put anything in the global namespace except when debugging. If I find myself with a huge list of dependencies for any require() or define() call, I take that as a sign that it's probably time to refactor and that I'm trying to do too much at one time.
... View more
06-18-2013
10:10 AM
|
0
|
0
|
1898
|
|
POST
|
What a great question. The meat of this question: /\/[^/]+$/ is a regular expression. In context, it looks at the path relative to the host and removes everything after the last slash so that an absolute path to a module can be given to the Dojo module loader. The original source for this is the Using Custom Modules with a CDN Dojo tutorial. Here's an explanation, piece by piece / Start a regular expression. \ Escape character. / Look for a slash. [^/] Negated character set to match all characters except slash. + Match one or more times. $ Match at the end of a string. / End of regular expression. The purpose of this regular expression is better demonstrated by example. When using custom modules, the Dojo module loader needs to know where to find them. You tell the loader about modules with dojoConfig.packages. Specifically, the location property. So...if your app is running at example.com/maps/usefulStuff.html, and your modules are in example.com/maps/extras, you can use: location.pathname.replace(/\/[^/]+$/, '') + "/extras" to correctly tell Dojo where to find your modules but not have to hardcode the full path to your modules.
... View more
06-14-2013
11:58 AM
|
0
|
0
|
606
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-23-2012 07:54 AM | |
| 1 | 05-28-2010 08:31 AM | |
| 1 | 11-12-2012 08:12 AM | |
| 3 | 02-23-2012 10:57 AM | |
| 1 | 06-27-2011 08:51 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|