POST
|
Hello All, I'm trying to register a onMouseOver event on a FeatureLayer, like the following: var featureLayer = new FeatureLayer('http://maps.ngdc.noaa.gov/arcgis/rest/services/web_mercator/ufn/MapServer/5', {
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"]
});
map.addLayer(featureLayer);
//Error: Target must be an event emitter
on(featureLayer, "onMouseOver", function(evt) {
console.log('inside onMouseOver');
}); and it fails with an: "Error: Target must be an event emitter". The code above is wrapped in a ready(). Strangely a similar non-AMD sample works fine:
var featureLayer = new esri.layers.FeatureLayer('http://maps.ngdc.noaa.gov/arcgis/rest/services/web_mercator/ufn/MapServer/5', {
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["*"]
});
map.addLayer(featureLayer);
dojo.connect(featureLayer, "onMouseOver", function(evt) {
console.log('inside onMouseOver');
});
Any ideas on what I'm doing wrong in the first case? Thanks! --john
... View more
04-08-2013
08:00 PM
|
0
|
6
|
931
|
POST
|
Thanks Kelly. I finally realized the MID for Map is different in the 3.4amd version and 3.4 - "esri/Map" and "esri/map" respectively. It was causing a strange "multipleDefine" error. In any case, I can no longer reproduce the problem in my BorderContainer example. --john
... View more
04-08-2013
07:15 PM
|
0
|
0
|
681
|
POST
|
Thanks Rene, good suggestion and that does help. I'm intentionally not parsing on load and still trying to verify differences between browsers when using AMD JSAPI. --john
... View more
04-08-2013
11:48 AM
|
0
|
0
|
681
|
POST
|
Thanks for your reply Kelly. One thing I notice is that you're using http://serverapi.arcgisonline.com/jsapi/arcgis/3.4amd/ to load the API and I was using http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/ I'm not familiar w/ the former - should I be using that instead? Can you point me to any pure AMD examples other than portal_getgroupamd.html? I cannot reproduce the problem using the sample you provided, but can do so in Chrome using the code below. Note that FireFox does not exhibit the problem. Thanks again for your help! --john
<!DOCTYPE html>
<html>
<head>
<title>BorderContainer Example</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4amd/js/esri/css/esri.css">
<style>
html,body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#mainWindow {
width:100%;
height:100%;
}
#header {
height: 75px;
background-color: blue;
}
#leftPane {
width: 100px;
background-color: green;
}
#footer {
height: 25px;
background-color: red;
}
#featureInfo {
height: 50px;
background-color:rgb(194,188,155);
}
</style>
<script>
dojoConfig= {
parseOnLoad: false,
async: true
};
</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4amd/"></script>
<script>
require(
[
"dijit/layout/BorderContainer", "dijit/layout/ContentPane",
"esri/Map", "dojo/parser", "dojo/ready", "dojo/domReady!"
],
function(BorderContainer, ContentPane, Map, parser, ready) {
ready(function(){
parser.parse();
});
var map = new Map("map",{
basemap:"oceans",
center:[-102,40], //long, lat
zoom:5
});
}
);
</script>
</head>
<body class="claro">
<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline', gutters:false">
<div id="header" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
HEADER
</div>
<div id="leftPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'left'">
LEFT PANEL
</div>
<div id="centerPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">
<div id="mapContainer" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline', gutters:false">
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">
</div>
<div id="featureInfo" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'">
FEATUREINFO
</div>
</div>
</div> <!-- end centerPane BorderContainer -->
<div id="footer" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'">
</div>
</div> <!-- end mainWindow BorderContainer -->
</body>
</html>
... View more
04-05-2013
07:28 PM
|
0
|
0
|
681
|
POST
|
Thanks for the suggestion Shad, that makes sense and it does appear to address the problem with the Map's "center" property. However, I still have to explicitly call map.resize() where I didn't with the old-style loader. Of course I can work around this, but would like to understand what's going on. Thanks again for your help! --john
... View more
04-03-2013
07:12 AM
|
0
|
0
|
679
|
POST
|
Hello All, I'm using v3.4 and finding some differences in the Map behavior when using the older "require" style module loading and the newer AMD style. I'm using a BorderContainer with the map in the center panel and finding that w/ AMD, I have to explicitly call map.resize() to get it to fill the panel. Also, w/ AMD the "center" property of a Map doesn't seem to have any effect. Listed below are two examples that I'd expected to provide identical results, but don't. I assume it has something to do w/ the timing of the module load, but I'm not clear on what to do differently. Thanks for any help! --john //works OK
function initMap() {
map = new esri.Map("map", {
basemap: "oceans",
center: [-102, 40],
zoom: 5
});
require(["esri/map"],
function(Map) {
var map = new Map("map", {
basemap: "oceans",
center: [-102, 40], //does not seem to be respected
zoom: 5});
//not sure why this seems to be required w/ AMD loaded module
map.resize();
});
... View more
04-02-2013
05:01 PM
|
0
|
10
|
1230
|
POST
|
Hello All, I'm having problems creating a simple AMD-widget using the "esri/tasks/identify" module. Given a module that looks like: define(["dojo/_base/declare", "dijit/_WidgetBase", "dijit/_TemplatedMixin", "esri/tasks/identify", "dojo/text!./templates/MyDijit.html"],
function(declare, _WidgetBase, _TemplatedMixin, identify, template ){
return declare([_WidgetBase, _TemplatedMixin], {
templateString: template,
constructor: function() {
}
});
});
and loading it like: require(["ngdc/MyDijit"], function(MyDijit){
var myDijit = new MyDijit();
}); I get the error "Uncaught TypeError: Cannot read property 'defaults' of undefined". This only occurs once I add in the identify module. Can someone please point out what I'm doing wrong? Thanks! --john
... View more
07-13-2012
09:50 PM
|
0
|
0
|
373
|
POST
|
Thanks Kelly. I was looking for the test suite that you all use for the API and didn't see it in either the sdk or api downloads. Am I overlooking it or is it available separately? I'm interested in more unit test examples as well as what changes need to be made for Derek's test sample (http://blogs.esri.com/esri/arcgis/2012/05/21/writing-unit-tests-for-your-arcgis-api-for-javascript-apps/) to work with 3.0. --john
... View more
06-24-2012
08:01 AM
|
0
|
0
|
408
|
POST
|
Thanks Derek, I had not seen Kelly's message on this topic. I'm surprised though that http://enable-cors.org/ reports that sservices.arcgisonline.com is a CORS-enabled site. --john
... View more
06-20-2012
08:04 AM
|
0
|
0
|
557
|
POST
|
Hello All, I'm finding that when using 3.0, I get the following error: XMLHttpRequest cannot load http://server.arcgisonline.com/ArcGIS/rest/info?f=json. Origin http://localhost is not allowed by Access-Control-Allow-Origin. Simply switching the API back to 2.8 eliminates the problem. I've tried configuring both CORS and the proxyUrl, but neither helps. Can someone please provide me some guidance here? Thanks! --john
... View more
06-19-2012
08:19 PM
|
0
|
4
|
5355
|
POST
|
I add that package in a test app real quick and used a dojo.require "help_panel.HelpPanel" and the js file was downloaded in my app. I don't know what it does or how to use it, but it downloaded. The only thing different in my dojoConfig is I have async: true, but I don't know if that would make a difference in this case. Thanks for your reply Rene. Adding async: true to my dojoConfig causes the error: Uncaught TypeError: Object #<Object> has no method 'require' I'm assuming that I need a different require statement and not simply dojo.require('help_panel.HelpPanel'); when using async. --john
... View more
06-17-2012
08:58 PM
|
0
|
0
|
493
|
POST
|
Add a slash to the end of the location for help_panel? For your help_panel package, what are the URLs you're seeing generated for your module(s) from your app? Thanks for your reply Derek. Adding the trailing slash doesn't seem to make any difference. If the "dojo.require("help_panel.HelpPanel" line is reached, the page doesn't draw. The URL for the HelpPanel (http://maps.ngdc.noaa.gov/viewers/dijits/help_panel/1.1//HelpPanel.js) is resolving OK. --john
... View more
06-17-2012
08:55 PM
|
0
|
0
|
493
|
POST
|
Hello All, I'm using both local and remote custom modules. In 2.x, my dojoConfig was like:
var dojoConfig = {
parseOnLoad: true,
baseUrl: './',
modulePaths: {
'help_panel': 'http://maps.ngdc.noaa.gov/viewers/dijits/help_panel/1.1',
'nos_hydro': './src/dijits/nos_hydro'
}
};
Attempting to convert to 3.0, I changed to:
var dojoConfig = {
parseOnLoad: true,
modulePaths: {
'help_panel': 'http://maps.ngdc.noaa.gov/viewers/dijits/help_panel/1.1'
},
packages: [{
"name": "nos_hydro",
"location": location.pathname.replace(/\/[^/]+$/, "") + "/src/dijits/nos_hydro"
}]
};
which works for the local module but not the remote. I also tried
var dojoConfig = {
parseOnLoad: true,
packages: [{
"name": "nos_hydro",
"location": location.pathname.replace(/\/[^/]+$/, "") + "/src/dijits/nos_hydro"
},
{
"name": "help_panel",
"location": "http://maps.ngdc.noaa.gov/viewers/dijits/help_panel/1.1"
}]
};
but that didn't work either. I've tried both the remote module as a Dojo 1.6 CDN build and as plain JS. Can someone please provide me some guidance here? Thanks! --john
... View more
06-17-2012
03:54 PM
|
0
|
4
|
985
|
POST
|
Hi John, We put together a blog post and example on how to use DOH with the JS API: http://blogs.esri.com/esri/arcgis/2012/05/21/writing-unit-tests-for-your-arcgis-api-for-javascript-apps/ Thanks Derek, this is great - just what I was looking for! --john
... View more
05-21-2012
06:42 PM
|
0
|
0
|
412
|
POST
|
Hello All, I'm looking to extend esri.InfoWindowBase and would like the resulting custom dijit to be able to move it around on the map. Can someone please tell me what Dojo class it extends or suggest an approach for a movable, resizable InfoWindow? Thanks! --john
... View more
05-13-2012
01:55 PM
|
0
|
0
|
666
|
Title | Kudos | Posted |
---|---|---|
1 | 01-21-2016 10:24 AM | |
6 | 01-04-2016 01:54 PM | |
5 | 08-17-2010 11:34 AM | |
18 | 07-27-2010 01:59 PM |
Online Status |
Offline
|
Date Last Visited |
03-07-2023
04:48 PM
|