|
POST
|
Jeff is right, it's not a bug. KMLLayer loads the charting modules. Why would you dojo.require it if you're not using it? We had a brief discussion about the deprecation warnings on twitter this when we first added the KMLLayer: https://twitter.com/#!/derekswingley/status/89451030831575041
... View more
11-16-2011
08:47 AM
|
0
|
0
|
2308
|
|
POST
|
I recommend using esri.request to get your layer's info, including all the field info, and then building your UI. There's an example of grabbing info for a layer in this post: http://forums.arcgis.com/threads/7793-Identify-How-to-show-Alias-filed-instead-of-Field-Name?p=24158&viewfull=1#post24158
... View more
11-16-2011
07:12 AM
|
0
|
0
|
1018
|
|
POST
|
Just curious...how were you connecting the data from your database to Google Maps?
... View more
11-15-2011
02:29 PM
|
0
|
0
|
1035
|
|
POST
|
The easiest way to do this will be to use ArcGIS Server to publish your data as a map service. Depending on the number of points you're displaying, you can display your data using a dynamic map service layer or a feature layer. If you were previously using google, then you'll probably be able to use a feature layer. Do you have ArcGIS Server? There's also the possibility of using ArcGIS Online, but that won't talk directly to your SQL database.
... View more
11-15-2011
01:39 PM
|
0
|
0
|
1035
|
|
POST
|
Looking forward to see what you come up with. This service has several layers with coded value domains: http://sampleserver5.arcgisonline.com/ArcGIS/rest/services/Energy/Geology/MapServer
... View more
11-15-2011
01:25 PM
|
0
|
0
|
3183
|
|
POST
|
The general workflow would be: use esri.request() to get your layer's metadata keep track of fields with domains build an object for each field with a domain to map coded values to actual values execute a query when processing the query results, map the coded values from the attributes to actual values
... View more
11-15-2011
12:11 PM
|
0
|
0
|
3183
|
|
POST
|
Gladly. Please post back and let us know what you find.
... View more
11-15-2011
09:15 AM
|
0
|
0
|
1194
|
|
POST
|
Thanks for the clarification. When I say "public API functions to interact with your layers" I'm talking about using the methods and properties documented in the official docs, not just the JS/CSS files hosted on Esri servers. The finer points of the markup generated by the API isn't something we document and therefore is subject to change. That being said, I tried to repro this using the URL you posted but I'm still seeing the layer's ID show up in the main div for a layer and in the img tag that inserts the map image into the map. Here's some of the markup generated from the code at the end of this post:
<div id="map_layers" class="layersDiv">
<div id="map_layer0" style="position: absolute; left: 0px; top: 0px; width: 1354px; height: 521px; overflow: visible; display: block;">
<div id="map_dynamic" style="position: absolute; left: 0px; top: 0px; width: 1354px; height: 521px; overflow: visible; opacity: 1; display: block;">
<img id="map_dynamic_1321381345553" style="position: absolute; left: 0px; top: 0px; width: 1354px; height: 521px;" src="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/export?dpi=96&transparent=true&format=png8&bbox=-9181020.983518625%2C3176890.519266467%2C-9168084.016481375%2C3181868.480733533&bboxSR=102100&imageSR=102100&size=1354%2C521&f=image">
</div>
<div id="map_anno" style="position: absolute; left: 0px; top: 0px; width: 1354px; height: 521px; overflow: visible; opacity: 1; display: block;">
<img id="map_anno_1321381345556" style="position: absolute; left: 0px; top: 0px; width: 1354px; height: 521px;" src="http://www.mymanatee.org/arcgis/rest/services/common-operational/streetnames-for-aerials/MapServer/export?dpi=96&transparent=true&format=png8&bbox=-9181020.983518625%2C3176890.519266467%2C-9168084.016481375%2C3181868.480733533&bboxSR=102100&imageSR=102100&size=1354%2C521&f=image">
...<snip>...
layer0 is a tiled basemap layer, dynamic is a dynamic map service hosted on sampleserver1 and anno is your map service. Here's the full page:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title></title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/esri/dijit/css/Popup.css">
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map{ margin: 0; padding: 0; }
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
var map;
function init() {
var initExtent = new esri.geometry.Extent({"xmin":-9177466,"ymin":3177315,"xmax":-9171639,"ymax":3181444,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{extent:initExtent});
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
var dyn = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer", {
"id": "dynamic"
});
map.addLayer(dyn);
var anno = new esri.layers.ArcGISDynamicMapServiceLayer("http://www.mymanatee.org/arcgis/rest/services/common-operational/streetnames-for-aerials/MapServer", {
"id": "anno"
});
map.addLayer(anno);
dojo.connect(map, 'onLoad', function() {
dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
});
}
dojo.ready(init);
</script>
</head>
<body class="tundra">
<div data-dojo-type="dijit.layout.BorderContainer"
data-dojo-props="design:'headline',gutters:false"
style="width: 100%; height: 100%; margin: 0;">
<div id="map"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region:'center'">
</div>
</div>
</body>
</html>
... View more
11-15-2011
08:31 AM
|
0
|
0
|
1194
|
|
POST
|
It seems like you've got too many things going on to successfully troubleshoot this via a forum thread. I have a feeling there are some bigger app development issues but I'll try to help where I can. Here are the things that jump out at me:
//Measure button click handler.
function MeasureBtnClickHandler()
{
doIdentify = false;
if (dijit.byId('dFloatingPane02').open==false)
{
createMeasure();
this.navToolbar.deactivate(); //I am calling this method as you mentioned
}
}
...<snip>...
Just calling navToolbar.deactivate() was doing nothing.So, I am calling disable methods on map (as mentioned in my earlier post). The navigation toolbar's deactivate method works so you should address this before moving on. I have a feeling it's a scope related issue and that this.navToolbar isn't actually pointing to your navigation toolbar. If you put a console.log(this.navToolbar); statement just before your deactivate call, what does it show?
measurement = new esri.dijit.Measurement({
map: map
}, dojo.create('measure'));
dojo.create('measure') does not create valid markup. You probably want dojo.create('div'). Instead of continuously creating/destroying the measurement widget, have you tried re-using the same instance of the widget?
... View more
11-15-2011
07:53 AM
|
0
|
0
|
2862
|
|
POST
|
What are you trying to do? We would normally recommend that you stick to using public API functions to interact with your layers. What is the API missing?
... View more
11-15-2011
07:40 AM
|
0
|
0
|
1194
|
|
POST
|
Having one feature or three shouldn't make a difference with the code I posted. The way the KMLLayer works internally is that points, lines and polygons each get their own feature layer. This code gets the polygon feature layer:
var polygons = dojo.filter(lyrs, function(lyr) {
if ( lyr.geometryType == "esriGeometryPolygon" ) {
return lyr;
}
})[0];
And this code creates the HTML and adds event listeners to for each polygon feature:
dojo.byId("info").innerHTML = "";
dojo.forEach(polygons.graphics, function(g) {
// hide the graphic by default
g.hide();
var node = dojo.create('div', {
id: g.attributes.id,
innerHTML: g.attributes.name
}, dojo.byId("info"));
// set up an event handlers to show the feature
dojo.connect(node, "onmouseover", function() {
g.show();
});
dojo.connect(node, "onmouseout", function() {
g.hide();
});
});
... View more
11-14-2011
09:46 AM
|
0
|
0
|
3422
|
|
POST
|
I understand, thanks for posting more info. This is definitely possible, but I'm skeptical of the user experience. I say this because once you mouseover a feature name, it shows up on the map but as you mouse out, it disappears. How is a user supposed to get more info about a feature? I guess if you just need to show the feature but don't need to let the user interact with it, this would be a valid workflow. Here's a simple implementation:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title></title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/esri/dijit/css/Popup.css"/>
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map { margin: 0; padding: 0; }
#meta {
position: absolute;
left: 20px;
bottom: 20px;
width: 300px;
height: 100px;
z-index: 40;
background: #fff;
color: #777;
padding: 5px;
border: 5px solid #777;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
font-family: arial;
font-size: 0.9em;
}
#meta h3 {
color: #000;
font-size: 1.1em;
padding: 0px;
margin: 0px;
display: inline-block;
}
#loading {
float: right;
}
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.layers.KMLLayer");
var map;
function init() {
var initExtent = new esri.geometry.Extent({"xmin":-13787751,"ymin":4476990,"xmax":-10404954,"ymax":6049759,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{ extent: initExtent });
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
var kmlUrl = 'http://dl.dropbox.com/u/2654618/kml/Wyoming.kml';
var kml = new esri.layers.KMLLayer(kmlUrl, { visible: false });
map.addLayer(kml);
dojo.connect(kml, 'onLoad', configureMouseOver);
dojo.connect(map, 'onLoad', function() {
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
});
}
function configureMouseOver(kml) {
// get layers
var lyrs = kml.getLayers();
var polygons = dojo.filter(lyrs, function(lyr) {
if ( lyr.geometryType == "esriGeometryPolygon" ) {
return lyr;
}
})[0];
console.log('polygons: ', polygons);
dojo.byId("info").innerHTML = "";
dojo.forEach(polygons.graphics, function(g) {
// hide the graphic by default
g.hide();
var node = dojo.create('div', {
id: g.attributes.id,
innerHTML: g.attributes.name
}, dojo.byId("info"));
// set up an event handlers to show the feature
dojo.connect(node, "onmouseover", function() {
g.show();
});
dojo.connect(node, "onmouseout", function() {
g.hide();
});
});
// turn the layer on but no graphics will
// show because they were previously hidden
kml.show();
}
dojo.ready(init);
</script>
</head>
<body class="tundra">
<div data-dojo-type="dijit.layout.BorderContainer"
data-dojo-props="design:'headline',gutters:false"
style="width: 100%; height: 100%; margin: 0;">
<div id="map"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region:'center'">
<div id="meta">
<h3>Display KML Using a <a href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/kmllayer.htm">KMLLayer</a></h3>
<div id="info">The map displays a simple KML file that was created using Google Earth and
is hosted on an Esri server. Symbology and attributes are honored.</div>
<div>
</div>
</div>
</body>
</html>
JSFiddle: http://jsfiddle.net/swingley/jPTPL/
... View more
11-14-2011
08:06 AM
|
0
|
0
|
3422
|
|
POST
|
I think the unique value renderer sample is exactly what you're looking for. That sample uses a feature layer to grab the state shapes from an ArcGIS Server map service and then uses a renderer to symbolize the states based on their attribute named SUB_REGION.
... View more
11-14-2011
07:07 AM
|
0
|
0
|
539
|
|
POST
|
As an app developer, it's up to you to manage the state of the various controls you're using in your app. That being said, I'd like to try to help as much as possible. One thing that is confusing is that you talk about a nav toolbar but then mention navigation methods on the map itself. If I understand correctly, you should be calling navigationToolbar.deactivate() when your measurement widget is activated. Then call navigationToolbar.activate() when onMeasureEnd fires. How are you activating the measurement widget?
... View more
11-14-2011
06:47 AM
|
0
|
0
|
2862
|
|
POST
|
Another option is to calculate a new extent from the map's current extent and use that to zoom. It's similar to the original code that was posted in this thread but instead of using a hard coded value, the value used to pad the point is calculated on the fly. Something like this:
var tolerance = 5,
pxWidth = map.extent.getWidth() / map.width,
padding = tolerance * pxWidth,
newExtent = new esri.geometry.Extent({
'xmin': evt.mapPoint.x - padding,
'ymin': evt.mapPoint.y - padding,
'xmax': evt.mapPoint.x + padding,
'ymax': evt.mapPoint.y + padding,
'spatialReference': evt.mapPoint.spatialReference
});
map.setExtent(newExtent);
... View more
11-14-2011
06:34 AM
|
0
|
0
|
963
|
| 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
|