POST
|
Hi, I cannot get a mouse over event to work when I pass the mouse over a KMLlayer. I have a basic piece of code that works with a graphics layer, but cannot get the KML layer recognized. Anyone have any thoughts ? I attached the code that works for a graphics layer. Then below that I attached what we started trying for the KML layer. Thank you. var graphicLayerIds = map.graphicsLayerIds; var layer1 = map.getLayer(graphicLayerIds[1]); var layer2 = map.getLayer(graphicLayerIds[2]); var layer3 = map.getLayer(graphicLayerIds[3]); var layer4 = map.getLayer(graphicLayerIds[4]); dojo.connect(layer1, "onMouseOver", myMouseOver); dojo.connect(layer2, "onMouseOver", myMouseOver); dojo.connect(layer3, "onMouseOver", myMouseOver); dojo.connect(layer4, "onMouseOver", myMouseOver); dojo.connect(layer1, "onMouseOut", myMouseOut); dojo.connect(layer2, "onMouseOut", myMouseOut); dojo.connect(layer3, "onMouseOut", myMouseOut); dojo.connect(layer4, "onMouseOut", myMouseOut); function myMouseOver() { map.setMapCursor("pointer"); } function myMouseOut() { map.setMapCursor("default"); } Adding KML Layers: var kmlUrl = getMapUrl(1); var kml = new esri.layers.KMLLayer(kmlUrl); map.addLayer(kml); kmlUrl = getMapUrl(2); kml = new esri.layers.KMLLayer(kmlUrl); map.addLayer(kml); var layerIds = map.layerIds; var kmlLayer1 = map.getLayer(layerIds[1]); var kmlLayer2 = map.getLayer(layerIds[2]);
... View more
04-22-2013
04:36 AM
|
0
|
0
|
1472
|
POST
|
I was speaking with an ESRI employee and he said the layers added this way are actually graphic objects... so he suggested a small change to our code... which works! Thanks so much. function mapLoaded() { var layerIds = map.graphicsLayerIds; console.log(layerIds.length); var layer; for (var i=0; i < layerIds.length; i++) { layer = map.getLayer(layerIds); console.log(layer.name); layer.hide(); } }
... View more
03-15-2013
10:02 AM
|
0
|
1
|
3229
|
POST
|
Would it be possible for you to post a complete working set of your code example. That might help me understand why we could not get the statement: "esri.arcgisonline.map.main.mapLayers[0].layer.hide()" to be recognized. Thanks again, Frank
... View more
03-15-2013
05:12 AM
|
0
|
0
|
645
|
POST
|
I also asked our developer to get a code snippet that would actually run, verbatim... He commented out the part that we tried to do the layer hiding. This should run as a html file for you if you wanted to try it. We could not get your statment ( esri.arcgisonline.map.main.mapLayers) to run. It through back the error we mentioned previously. Sorry for taking your time, but thanks again for your previous responses. This should as an html file... however we had to add a proxy line to our website config to get it to work. <html> <body> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/dojo/dijit/themes/tundra/tundra.css" /> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css" /> <link rel="stylesheet" type='text/css' href='http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/esri/dijit/css/Popup.css'/> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2"></script> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.arcgis.utils"); dojo.require("esri.dijit.Popup"); var map, mapIsLoaded, maxExtent, popup; function map_init() { esri.config.defaults.io.proxyUrl = "/proxy/proxy.ashx"; var lods = [{ "level": 7, "resolution": 1222.99245256249, "scale": 4622324.434309 }, { "level": 8, "resolution": 611.49622628138, "scale": 2311162.217155 }, { "level": 9, "resolution": 305.748113140558, "scale": 1155581.108577 }, { "level": 10, "resolution": 152.874056570411, "scale": 577790.554289 } ]; var webmap = "c5468a0851e14f529a4fa034d7a3b5b2"; maxExtent = new esri.geometry.Extent({ "xmin": -6850000, "ymin": 5820000, "xmax": -5630000, "ymax": 6554000, "spatialReference": { "wkid": 102100} }); popup = new esri.dijit.Popup({ fillSymbol: new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 255, 255]), 2), new dojo.Color([255, 0, 0, 0.1])) }, dojo.create("div")); mapDeferred = esri.arcgis.utils.createMap(webmap, "map", { mapOptions: { infoWindow: popup, extent: maxExtent, lods: lods, slider: true, sliderStyle: "small", nav: false, showAttribution: false, logo: false } }) mapDeferred.addCallback(function (response) { map = response.map; if (map.loaded) { mapLoaded(); } else { dojo.connect(map, "onLoad", mapLoaded); } }); } function mapLoaded() { //var layerIdsArr = esri.arcgisonline.map.main.mapLayers; //var layerIdsArr = map.layerIds; //var layer; //for (var i=0; i < layerIdsArr.length; i++) { // layer = map.getLayer(layerIdsArr); // console.log(layer.url); // layer.hide(); //} } window.onload = function() { map_init(); } </script> <div id="map" style="border:1px solid #000;width: 978px;height: 600px;"></div> </body> </html>
... View more
03-14-2013
09:19 AM
|
0
|
0
|
645
|
POST
|
Unfortunately no, because we don't add them through code. We add them directly on ArcGIS online using the add layer menu. But I was very hopeful when you mentioned you could turn them off through your code. I was wondering are you including something that we are not or is it the way we get the API to recognize our map? Thanks
... View more
03-14-2013
08:41 AM
|
0
|
0
|
2584
|
POST
|
LOL... I am glad you got it to work 🙂 Thank you for sticking with this. Your code statement returns an error for me. It maybe the way I have the map defined. I stripped out some code for you to have a look at. If I use the statement: arcgisonline, I see an error in firebug: TypeError: esri.arcgisonline is undefined var layerIdsArr = esri.arcgisonline.map.main.mapLayers; Here is some of our code: dojo.require("esri.map"); dojo.require("esri.arcgis.utils"); dojo.require("esri.dijit.Popup"); var map, mapIsLoaded, maxExtent, popup; function map_init() { esri.config.defaults.io.proxyUrl = "/proxy/proxy.ashx"; var lods = [{ "level": 7, "resolution": 1222.99245256249, "scale": 4622324.434309 }, { "level": 8, "resolution": 611.49622628138, "scale": 2311162.217155 }, { "level": 9, "resolution": 305.748113140558, "scale": 1155581.108577 }, { "level": 10, "resolution": 152.874056570411, "scale": 577790.554289 } ]; var webmap = "c5468a0851e14f529a4fa034d7a3b5b2"; maxExtent = new esri.geometry.Extent({ "xmin": -6850000, "ymin": 5820000, "xmax": -5630000, "ymax": 6554000, "spatialReference": { "wkid": 102100} }); popup = new esri.dijit.Popup({ fillSymbol: new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 255, 255]), 2), new dojo.Color([255, 0, 0, 0.1])) }, dojo.create("div")); mapDeferred = esri.arcgis.utils.createMap(webmap, "map", { mapOptions: { infoWindow: popup, extent: maxExtent, lods: lods, slider: true, sliderStyle: "small", nav: false, showAttribution: false, logo: false } }) mapDeferred.addCallback(function (response) { map = response.map; if (map.loaded) { mapLoaded(); } else { dojo.connect(map, "onLoad", mapLoaded); } }); } function mapLoaded() { //var layerIdsArr = esri.arcgisonline.map.main.mapLayers; var layerIdsArr = map.layerIds; var layer; for (var i=0; i < layerIdsArr.length; i++) { layer = map.getLayer(layerIdsArr); console.log(layer.url); layer.hide(); } } Thanks again
... View more
03-14-2013
07:34 AM
|
0
|
0
|
2584
|
POST
|
Hi, this is helpful, but we did something like that previously. When I use this code: var layerIdsArr = map.layerIds; var layer; for (var i=0; i < layerIdsArr.length; i++) { layer = map.getLayer(layerIdsArr); console.log(layer.url); layer.hide(); } We see on the console log http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer The basemap layer is easily turned off, (layer 0). However the 2 important layers are the Service Territory (highlighted in light blueon the example map) and the symbols that identify different types of power outages. For some reason, they are not recognized as layers? If I add another ESRI "default" layer such as Map Notes... same problem, the API does not recognize this layer. If I could get that layer recognized, I think I could have the answer to my problem. I am stumped on this one. The example map can be found at: http://bit.ly/W31ZTh Thank you very much for the help provided...
... View more
03-14-2013
05:02 AM
|
0
|
0
|
2584
|
POST
|
Thank you for the responses. Part of the problem maybe my lack of ArcGIS knowledge. I took a very simple approach, crated a map on ArcGIS Onlne, then from the menu bar, choose to add layer from web. I added a couple of layers, named them and then used JAVA SCript API to display the map by loading the generated map ID. I would like to be able to recognize these layers using the API, and then provide options for users to tuen these layers on and off. The problem is I cannot seem to get the API to recognize these layers. It does recognize the topographic layer but not the other layers "added from the web". If I turned on the default table of contents... I can then turn them on and off, but that is not acceptable as it does not present very well. Does this explanation help any? Would a subset of code help? Thanks
... View more
03-14-2013
03:40 AM
|
0
|
0
|
2584
|
POST
|
I am new to JavaScript API. I have a map with a number of feature layers added. I would like to be able to turn on and off these layers through the JavaScript API, yet I cannot seem to find a way to recognize the different layers on the map through the API. Any help would be appreciated. Thanks
... View more
03-13-2013
04:44 AM
|
1
|
13
|
10798
|
Title | Kudos | Posted |
---|---|---|
1 | 03-13-2013 04:44 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|