POST
|
I did something similar with my feature layer. I created a new point for the TextSymbol and pushed that to an array of labels to be added on the map's graphics layer: var labels = []; ... var labelGeom = new esri.geometry.Point(eval(x + 0.00015), eval(y + 0.00007), map.spatialReference); var font = new esri.symbol.Font("12px", esri.symbol.Font.STYLE_NORMAL, esri.symbol.Font.VARIANT_NORMAL, esri.symbol.Font.WEIGHT_BOLD, "Arial"); var textSymbol = new esri.symbol.TextSymbol( label, font, new dojo.Color([0, 0, 0]) ); var labelGraphic = new esri.Graphic(labelGeom); labelGraphic.setSymbol(textSymbol); labels.push(labelGraphic); ... for (var n = 0, nl = labels.length; n < nl; n++) { map.graphics.add(labels ); } I also used a boolean in a config file to make it easy to turn labels off, as well as tracked the current scale to only show labels below a specific scale.
... View more
06-11-2012
10:11 AM
|
0
|
0
|
415
|
POST
|
I noticed that it seemed to work better this morning when I tried it again... that it seemed to work in IE. I played with the code and made a few changes, and it shows up in FF for me now without an error, but the Legend doesn't look the same (no tabs). I moved the script block for djConfig down into the body, and I put the legend code into an 'onLayersAddResult' event block, then added both of your dynamiclayer, dynamiclayer2 on the same line. No error now, but I'm not sure why the Legend isn't displaying correctly in FF (I am running 12.0); it might be due to the Dojo version that works with 2.6 (which is 1.6.1; see here: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_dojoversion.html). Here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title> </title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.6/js/dojo/dijit/themes/claro/claro.css" /> <link href="https://community.esri.com/styles/LiquidLayout.css" rel="stylesheet" type="text/css" /> <link href="https://community.esri.com/styles/Fonts.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6"> </script> <script type="text/javascript"> dojo.require("dijit.dijit"); // optimize: load dijit layer dojo.require("dijit.layout.TabContainer"); dojo.require("esri.map"); dojo.require("esri.tasks.query"); dojo.require("esri.tasks.geometry"); dojo.require("esri.layers.FeatureLayer"); dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.dijit.Legend"); var queryTask, query, map; var featureLayer; var gsvc = null; var parcelLayer; var bLayerAdded; var dynamicLayer; var dynamicLayer2; var visible = [0]; var legend; var bAddressSearch = false; function init() { //set up map: bLayerAdded = false; //create map var startExtent = new esri.geometry.Extent({ "xmin": -8926347.12, "ymin": 2985172.96, "xmax": -8925572.60, "ymax": 2985677.56, "spatialReference": { "wkid": 102113} }); //create map map = new esri.Map("mapDiv", { extent: startExtent }); //map = new esri.Map("mapDiv") map.isZoomSlider = true; //add background layer: var tiledLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"); map.addLayer(tiledLayer); //add the legend dojo.connect(map,'onLayersAddResult',function(results){ //add the legend legend = new esri.dijit.Legend({ map: map, layerInfos: [{ layer: dynamicLayer, title: "Zoning Map:" }, { layer: dynamicLayer2, title: "Map Legend"}], arrangement: esri.dijit.Legend.ALIGN_RIGHT }, "legendDiv"); legend.startup(); }); //define geometry service: gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); //create and add new layer dynamicLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://maps.northmiamifl.gov/ArcGIS_External/rest/services/ZoningMap/MapServer"); //make the boundary layer invisible: visible[0] = 8; dynamicLayer.setVisibleLayers(visible); dynamicLayer.imageFormat = "Png32"; dynamicLayer.setOpacity(0.5); //map.addLayers([dynamicLayer]); //add in second dynamic layer that will hold the static, immutable layers: dynamicLayer2 = new esri.layers.ArcGISDynamicMapServiceLayer("http://maps.northmiamifl.gov/ArcGIS_External/rest/services/ZoningMap/MapServer"); var visible2 = [2]; visible2[0] = 0; visible2[1] = 1; visible2[2] = 2; dynamicLayer2.setVisibleLayers(visible2); map.addLayers([dynamicLayer,dynamicLayer2]); //Listen for click event on the map, when the user clicks on the map call executeQueryTask function. dojo.connect(map, "onClick", querybyClick); //build query queryTask = new esri.tasks.QueryTask("http://maps.northmiamifl.gov/ArcGIS_External/rest/services/ZoningMap/MapServer/2"); //dojo.connect(queryTask, "onComplete", showResults); //build query filter query = new esri.tasks.Query(); query.returnGeometry = true; query.outFields = ["H_NUM", "FOLIO", "PRE_DIR", "SNAME", "STNAME", "Zoning", "ArtsD", "NRO", "CCD", "EntZ", "CRA", "use", "District_1", "MDDist", "FlHouseNum", "FlSenateID", "USHouseID", "BISCTRANS", "CDBG"]; } ... and so on ... </head> <body class="claro"> <script type="text/javascript"> var djConfig = { parseOnLoad: true }; </script> ... and so on...
... View more
06-07-2012
07:40 AM
|
0
|
0
|
525
|
POST
|
Because if you don't use a function like pointtoExtent the user has to click exactly on the point in order for the infoWindow to pop up. 🙂
... View more
06-07-2012
05:36 AM
|
0
|
0
|
205
|
POST
|
I'm not sure that I'd be much help with the Dojo layout... I have always used ExtJS, and then only add in the dijits that are needed. Can you post what your Dojo layout code looks like within your aspx page?
... View more
06-07-2012
05:26 AM
|
0
|
0
|
525
|
POST
|
You need to escape the single quotes that are inside your document.writeln statements and you also have an extra ' at the end of your last document.writeln statement. This works for me: <html> <head> <script type="text/javascript"> function init() { document.writeln('<TABLE border="1">'); document.writeln('<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor=\'gold\';" onMouseOut="this.bgColor=\'#FFFFFF\';">'); document.writeln('<TD>Mauritania</td><TD>21N</TD><TD>24N</TD><TD> </TD><TD> </TD> </TR>'); document.writeln('<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor=\'gold\';" onMouseOut="this.bgColor=\'#FFFFFF\';">'); document.writeln('<TD>Myanmar</td><TD> </TD><TD>M TBA</TD><TD>M TBA</TD><TD> </TD></TR>'); document.writeln('<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor=\'gold\';" onMouseOut="this.bgColor=\'#FFFFFF\';">'); document.writeln('<TD>Nepal</td><TD> </TD><TD> </TD><TD> </TD><TD>M TBA</TD></TR></TABLE>'); } </script> </head> <body onload="init()"> </body> </html>
... View more
06-07-2012
05:23 AM
|
0
|
0
|
199
|
POST
|
I am getting an error when I try it in IE 8.07601.x: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2; MS-RTC LM 😎 Timestamp: Wed, 6 Jun 2012 21:09:37 UTC Message: 'undefined' is null or not an object Line: 8 Char: 443 Code: 0 URI: http://serverapi.arcgisonline.com/jsapi/arcgis/2.6/js/dojo/dojo/DeferredList.xd.js It doesn't appear to be working correctly in FireFox either; I don't get a scrollbar on the Legend.
... View more
06-06-2012
01:15 PM
|
0
|
0
|
525
|
POST
|
I recently had to do a similar type of selection on a point layer using the user click. In my layer points could be on top of each other, and the client wanted to ensure that all points were selected, not just the one drawn on top. So I actually changed the point to an extent (buffered the click point by 3 pixels), and used that to do the selection. Below are code snippets of what I used: var query = new esri.tasks.Query(); query.geometry = pointToExtent(map, evt.mapPoint, 3); //buffers click point by number of pixels(3) ... function pointToExtent(map, point, toleranceInPixel) { var pixelWidth = map.extent.getWidth() / map.width; var toleraceInMapCoords = toleranceInPixel * pixelWidth; return new esri.geometry.Extent(point.x - toleraceInMapCoords, point.y - toleraceInMapCoords, point.x + toleraceInMapCoords, point.y + toleraceInMapCoords, map.spatialReference); } I played with a copy of your code a bit on JSFiddle here: http://jsfiddle.net/xV8bh/ and got it working. Note that I have some alerts included that you will want to remove or comment out.
... View more
06-06-2012
09:56 AM
|
0
|
0
|
541
|
POST
|
Which sample are you using? Your link points to the main samples page.
... View more
06-05-2012
12:16 PM
|
0
|
0
|
541
|
POST
|
Can you post some code that shows how you are trying to remove your feature layer? I use a feature layer that is populated by a web service using a feature collection/layer definition. I keep my featureLayer variable as a global and then am able to use removeLayer(featureLayer) to remove it from the map and re-add it as needed.
... View more
06-05-2012
12:12 PM
|
0
|
0
|
1041
|
POST
|
Any ideas on what might prevent my default zoom symbol from being shown in IE? It is not being drawn on the screen at all in IE, yet is working fine in Firefox and Chrome (shows the zoom box as gray fill with red border). Thanks!
... View more
05-31-2012
07:44 AM
|
0
|
0
|
496
|
POST
|
Thanks Derek! In my actual code I just needed to add the [] around the layerInfo variable and it works now. 🙂
... View more
05-21-2012
08:08 AM
|
0
|
0
|
438
|
POST
|
nliu's recommendation is the path you should take- create a feature layer from a feature collection and you'll be able to use that with the legend dijit. What would the layerInfo look like for a feature layer created from a feature collection - the layerInfo the Legend dijit expects. I am trying to use just the feature layer itself.. is this correct? Thanks! When I forked and updated your example on jsFiddle to include a legend (see http://jsfiddle.net/ynm6W/2/), the legend content is "No legend"... so how do you/would you use the legend dijit if the FeatureLayer is based on graphics? According to the documentation for the Legend dijit: "The legend supports the following layer types: ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, FeatureLayer and KMLLayer." However then according to the constructor detail the layerinfos are: "A layer to add to the legend. Valid layer types are: ArcGISTiledMapServiceLayer,ArcGISDynamicMapServiceLayer." So this means the FeatureLayer must be created from one of these two map service types to use the Legend dijit and a FeatureLayer from a feature collection would not be supported?
... View more
05-18-2012
01:21 PM
|
0
|
0
|
438
|
Online Status |
Offline
|
Date Last Visited |
12-10-2020
10:03 AM
|