Select to view content in your preferred language

Difficulties combining other code with Find NearbyLocation example - error on parser?

973
7
10-19-2012 10:42 AM
TracySchloss
Honored Contributor
I am working through the Find Nearby example that uses the Yahoo search and geolocation, but with my own map service. I have an example someone shared with me, written at version 2.4. I thought I could just update the version numbers in the my code,  but any version over 2.7 generates an error that seems to be coming from dojox.mobile.parser.  It seem like I ought to be able to change my older code to have references to the higher API version.

This works:
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    
    <title>
      Find Nearby WIC Locations
    </title>
      <link type="text/css" rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.7/js/dojo/dojox/mobile/themes/iPhone/iPhone.css" /> 
    <link type="text/css" rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.7/js/dojo/dojox/mobile/themes/buttons.css" /> 
    <link rel="apple-touch-icon" href="apple-touch-icon.png" />
    <style type="text/css">
      html, body
      {
        height: 100%;
        margin: 0px;
        padding: 0px;
        width: 100%;
    }
    </style>
    <script type="text/javascript">
      var djConfig = {
        parseOnLoad: true
      };
    </script>
   <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.7compact"></script> 



Changing the references to 3.2 and added the newer esri.css references gives an error:
_a is undefined
at parse(Object, Object, Array) (http://serverapi.arcgisonline.com/jsapi/arcgis/3.2compact/js/dojo/dojox/mobile/parser.js:2)
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    
    <title>
      Find Nearby WIC Locations
    </title>
      <link type="text/css" rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dojox/mobile/themes/iPhone/iPhone.css" /> 
    <link type="text/css" rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dojox/mobile/themes/buttons.css" /> 
  
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css" /> 
    <link rel="apple-touch-icon" href="apple-touch-icon.png" />
    <style type="text/css">
      html, body
      {
        height: 100%;
        margin: 0px;
        padding: 0px;
        width: 100%;
    }
    </style>
    <script type="text/javascript">
      var djConfig = {
        parseOnLoad: true
      };
    </script>
   <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2compact"></script> 
0 Kudos
7 Replies
JohnGravois
Deactivated User
i would suggest comparing and contrasting the individual modules loaded using dojo.require statements in your own application with our working 3.2 sample because version 3.x can require the explicit mention of certain modules which were loaded automatically pre dojo 1.7.

dojo.require("esri.tasks.locator");
dojo.require("esri.tasks.route");

dojo.require("dojox.mobile.parser");
dojo.require("dojox.mobile");
dojo.require("dojox.mobile.Button");
dojo.requireIf(!dojo.isWebKit, "dojox.mobile.compat");


see the section "explicitly requiring modules" in the article below for more information
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/migration_30.htm
0 Kudos
TracySchloss
Honored Contributor
I added the dojo.require for dojox.mobile.Button, which I didn't have before.

I'm getting a file not found for http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dojox/mobile/themes/buttons.css.  I get this same error when using the original code from the resource center.  I can't help but think there is something wrong with this css and not something in my code.
0 Kudos
JohnGravois
Deactivated User
returning to your original question, if you aren't taking advantage of a new class, method or property there usually isn't a tremendous benefit to upgrading the version of the JavaScript API used by an application.

are you trying to take advantage of something in particular?  if so, it would probably be helpful to post some of the actual code to see if it is making a deprecated call.
0 Kudos
TracySchloss
Honored Contributor
No, I don't think I'm necessarily trying to use some new functionality, but everything I read encourages users to use the "latest and greatest".  I am concerned that the original sample code used as-is generates the same errors.    Doing an Internet search, I don't see hardly any references to the 3.2 compact build.  Just the ESRI references and this thread. 

Using Aptana Studio 2 and Firefox/Firebug, I'm getting these errors in the console using the original code from the Find Nearby Locations example

"NetworkError: 404 Not Found - http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dojox/mobile/themes/buttons.css"

and then because it can't find this css:
"NetworkError: 404 Not Found - http://127.0.0.1:8000/mobile_findNearby_ESRIsample/mblCheckOnButton"
mblCheckOnButton
"NetworkError: 404 Not Found - http://127.0.0.1:8000/mobile_findNearby_ESRIsample/mblCheckOffButton"

Following by:
NetworkError: 404 Not Found - http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dojox/mobile/themes/buttons-compat.css"

Is there some setting I need to make in Aptana or my browser?  Generally the ESRI sample work (until I start to modify them!)
0 Kudos
JohnGravois
Deactivated User
i didn't have any trouble running the sample you attached over HTTP on my test machine.  besides the 404 errors (which are reproducible in live published sample) what problems are you seeing in the actual app?
0 Kudos
TracySchloss
Honored Contributor
If I'm trying to modify the code for my own and it's already generating errors, then how am I supposed to keep track of which errors were there in the first place and which ones are my coding errors?
0 Kudos
JohnGravois
Deactivated User
i can let the JavaScript team know about the errors in the sample, but until the problem is fixed, you'll just have to keep track of the errors that were present when you started.

As for the "error" below, the behavior is entirely expected, because sampleserver1 doesn't support CORS yet.

XMLHttpRequest cannot load http://sampleserver1.arcgisonline.com/ArcGIS/rest/info?f=json. Origin http://help.arcgis.com is not allowed by Access-Control-Allow-Origin.


sorry for the unnecessary confusion!
0 Kudos