Select to view content in your preferred language

Problem with esri.layers.OpenStreetMapLayer() and "onUpdateEnd" Event

2022
4
Jump to solution
02-08-2012 01:12 PM
CesarRevilla
Regular Contributor
Hello,

now I experience a Problem with esri.layers.OpenStreetMapLayer() and "onUpdateEnd" Event.

The "onUpdateEnd" event is never dispatched.

Thanks for your support,
orzundher
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
I just ran a quick test and it works for me.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">  <html>    <head>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>      <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />      <!--The viewport meta tag is used to improve the presentation and behavior of the samples        on iOS devices-->     <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>     <title>OpenStreetMap- default options</title>      <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.6/js/dojo/dijit/themes/claro/claro.css">       <script type="text/javascript">       var djConfig = {         parseOnLoad: true       };     </script>     <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6"></script>          <script type="text/javascript">        dojo.require("esri.map");       dojo.require("esri.layers.osm");       var map, osmLayer;         function init() {         //setup the copyright text http://www.openstreetmap.org/copyright         var copyrightText= '&#169; <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> contributors, '                     + '<a href="http://creativecommons.org/licenses/by-sa/2.0/" target="_blank">CC-BY-SA</a>';          dojo.byId('osmCopy').innerHTML = copyrightText;         var extent = new esri.geometry.Extent({"xmin":-10023722.578230502,"ymin":3498675.6586681586,"xmax":-9996969.618330726,"ymax":3517784.9157394273,"spatialReference":{"wkid":102100}});         map = new esri.Map("map",{extent:extent,logo:false});                  osmLayer = new esri.layers.OpenStreetMapLayer();                  dojo.connect(osmLayer,'onUpdateEnd',function(){             console.log('update end');         });                  map.addLayer(osmLayer);          var details = "";         details = "loaded: " + osmLayer.loaded + "<br />";         details += "initialExtent: " + dojo.toJson(osmLayer.initialExtent.toJson()) + "<br />";         details += "fullExtent: " + dojo.toJson(osmLayer.fullExtent.toJson()) + "<br />";         details += "spatialReference: " + dojo.toJson(osmLayer.spatialReference.toJson())+ "<br />";         dojo.byId("info").innerHTML = details;       }        dojo.addOnLoad(init);     </script>    </head>       <body class="claro" style="font-size: small; font-family: Arial Unicode MS,Arial,sans-serif;">      <div id="map" style="position:relative;width:700px; height:500px; border:1px solid #000;">       <div id="osmCopy" style="position:absolute; color:black;font-weight:bold;right:10px; bottom:10px; z-Index:999;"></div>     </div>       <div id="info" style="padding:5px; margin:5px; background-color:#eee;"></div>    </body>  </html>   

View solution in original post

0 Kudos
4 Replies
KellyHutchins
Esri Frequent Contributor
I just ran a quick test and it works for me.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">  <html>    <head>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>      <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />      <!--The viewport meta tag is used to improve the presentation and behavior of the samples        on iOS devices-->     <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>     <title>OpenStreetMap- default options</title>      <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.6/js/dojo/dijit/themes/claro/claro.css">       <script type="text/javascript">       var djConfig = {         parseOnLoad: true       };     </script>     <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6"></script>          <script type="text/javascript">        dojo.require("esri.map");       dojo.require("esri.layers.osm");       var map, osmLayer;         function init() {         //setup the copyright text http://www.openstreetmap.org/copyright         var copyrightText= '&#169; <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> contributors, '                     + '<a href="http://creativecommons.org/licenses/by-sa/2.0/" target="_blank">CC-BY-SA</a>';          dojo.byId('osmCopy').innerHTML = copyrightText;         var extent = new esri.geometry.Extent({"xmin":-10023722.578230502,"ymin":3498675.6586681586,"xmax":-9996969.618330726,"ymax":3517784.9157394273,"spatialReference":{"wkid":102100}});         map = new esri.Map("map",{extent:extent,logo:false});                  osmLayer = new esri.layers.OpenStreetMapLayer();                  dojo.connect(osmLayer,'onUpdateEnd',function(){             console.log('update end');         });                  map.addLayer(osmLayer);          var details = "";         details = "loaded: " + osmLayer.loaded + "<br />";         details += "initialExtent: " + dojo.toJson(osmLayer.initialExtent.toJson()) + "<br />";         details += "fullExtent: " + dojo.toJson(osmLayer.fullExtent.toJson()) + "<br />";         details += "spatialReference: " + dojo.toJson(osmLayer.spatialReference.toJson())+ "<br />";         dojo.byId("info").innerHTML = details;       }        dojo.addOnLoad(init);     </script>    </head>       <body class="claro" style="font-size: small; font-family: Arial Unicode MS,Arial,sans-serif;">      <div id="map" style="position:relative;width:700px; height:500px; border:1px solid #000;">       <div id="osmCopy" style="position:absolute; color:black;font-weight:bold;right:10px; bottom:10px; z-Index:999;"></div>     </div>       <div id="info" style="padding:5px; margin:5px; background-color:#eee;"></div>    </body>  </html>   
0 Kudos
CesarRevilla
Regular Contributor
Yes, in this case works fine. I try it one more time!
Thankyou!
0 Kudos
CesarRevilla
Regular Contributor
Ok, it works not in case dojo.connect(osmLayer,'onUpdateEnd',function() runs after dojo.connect(map,'onLoad',function(){...

Using ArcGISTiledMapServiceLayer instead OpenStreetMapLayer works good after map, "onLoad" event.

Thank you!
orzundher
0 Kudos
CesarRevilla
Regular Contributor
Sorry, it works too in your code. I need to look my code.
0 Kudos