10 Replies Latest reply on Jul 3, 2012 8:42 AM by SOppmann-esristaff

    GPS locator not working for Election Polling Place ver 2.2

    vanhornsky
      Hello I am trying to get the GPS locator working on this application. I keep getting "You are currently outside the supported area" dialog box. Everything but this is working. Are their any settings that have to be set to use this functionality? Thanks for your help.

      Brandon
        • Re: GPS locator not working for Election Polling Place ver 2.2
          vanhornsky
          I figured it out. The GPS locater was returning the location value in latitude and longitude. Therefor the location value did not fall with in the full extent value. That is because the values that are being used for the full extent are in Web Mercator Projection. Any the code to fix this is below.

          Class: utls.js


          navigator.geolocation.getCurrentPosition(
            function (position) {
                ShowProgressIndicator();
                mapPoint = esri.geometry.geographicToWebMercator(new esri.geometry.Point(position.coords.longitude, position.coords.latitude, new esri.SpatialReference({ wkid: 4326 }))); //Changed this line to include "esri.geometry.geographicToWebMercator("
                var graphicCollection = new esri.geometry.Multipoint(new esri.SpatialReference({ wkid: 102100 })); //changed wkid: 102100 Web Mercator
                graphicCollection.addPoint(mapPoint); //graphicCollection.addPoint(mapPoint)
                geometryService.project([graphicCollection], map.spatialReference, function (newPointCollection) {
                    for (var bMap = 0; bMap < baseMapLayers.length; bMap++) {
                        if (map.getLayer(baseMapLayers[bMap].Key).visible) {
                            var bmap = baseMapLayers[bMap].Key;
                        }
                    }
                    if (!map.getLayer(bmap).fullExtent.contains(mapPoint)) {
                        map.infoWindow.hide();
                        selectedPollPoint = null;
                        pollPoint = null;
                        mapPoint = null;
                        ClearSelection();
                        map.getLayer(tempGraphicsLayerId).clear();
                        map.getLayer(precinctLayerId).clear();
                        map.getLayer(routeGraphicsLayerId).clear();
                        map.getLayer(highlightPollLayerId).clear();
                        HideProgressIndicator();
                        if (!isMobileDevice) {
                            var imgToggle = dojo.byId('imgToggleResults');
                            if (imgToggle.getAttribute("state") == "maximized") {
                                imgToggle.setAttribute("state", "minimized");
                                WipeOutResults();
                                dojo.byId('imgToggleResults').src = "images/up.png";
                            }
                        }
                        ShowInfoDetailsView();
                        alert(messages.getElementsByTagName("geoLocation")[0].childNodes[0].nodeValue);
                        return;
                    } else { //Added the else statement.
                        mapPoint = newPointCollection[0].getPoint(0);
                        LocateAddressOnMap(false);
                    }
                });
            },
            function (error) {
                HideProgressIndicator();
                switch (error.code) {
                    case error.TIMEOUT:
                        alert(messages.getElementsByTagName("geolocationTimeout")[0].childNodes[0].nodeValue);
                        break;
                    case error.POSITION_UNAVAILABLE:
                        alert(messages.getElementsByTagName("geolocationPositionUnavailable")[0].childNodes[0].nodeValue);
                        break;
                    case error.PERMISSION_DENIED:
                        alert(messages.getElementsByTagName("geolocationPermissionDenied")[0].childNodes[0].nodeValue);
                        break;
                    case error.UNKNOWN_ERROR:
                        alert(messages.getElementsByTagName("geolocationUnKnownError")[0].childNodes[0].nodeValue);
                        break;
                }
            }, { timeout: 10000 });
          }


          Hope this helps someone else out. Have a great day.

          Brandon
          • Re: GPS locator not working for Election Polling Place ver 2.2
            muisea
            Thank you for pointing this out, Brandon.

            We will definitely look into resolving this.

            -Allison Muise

            Product Engineer
            ArcGIS for Local Government
            • Re: GPS locator not working for Election Polling Place ver 2.2
              huntingtongis

                    mapPoint = esri.geometry.geographicToWebMercator(new esri.geometry.Point(position.coords.longitude, position.coords.latitude, new esri.SpatialReference({ wkid: 4326 }))); //Changed this line to include "esri.geometry.geographicToWebMercator("
              var graphicCollection = new esri.geometry.Multipoint(new esri.SpatialReference({ wkid: 102100 })); //changed wkid: 102100 Web Mercator
                   



              Thanks, these lines worked for me in the Park Finder app for the geolocation.
              • Re: GPS locator not working for Election Polling Place ver 2.2
                marauder57
                I have tried this method and while it does make the button work it seems to misplace the gps or computer location by half a mile or so from where one is actually located, any idea what could be causing this?
                • Re: GPS locator not working for Election Polling Place ver 2.2
                  vanhornsky
                  Are you using a GPS?
                  The GPS on the phone\ tablets usually work really well. Within some acceptable tolerances.

                  ..or are you trying to locate the computer?
                  From what I can figure is the computer location is based on where the IP address is registered. This usually gets you within a town\ city but not always.
                  Like a zip code

                  Information link on the different type of locations
                  http://mobile.tutsplus.com/tutorials/mobile-web-apps/html5-geolocation/

                  Good Luck,
                  Brandon
                  • Re: GPS locator not working for Election Polling Place ver 2.2
                    marauder57
                    The GPS on a phone had the greatest inaccuracy the computer just puts us across the street, the gps put us in another part of town.  Is your main data in the localgovernment.gdb in your local coordinate system or are you putting it into the web mercator projection?
                    • Re: GPS locator not working for Election Polling Place ver 2.2
                      vanhornsky
                      Well we have customized the code to use our SQL database. This is in WebMercator.
                      • Re: GPS locator not working for Election Polling Place ver 2.2
                        marauder57
                        All of our data in our sql database is in the State Plane system then all of our webmaps are in the Web Mercator Aux projection(the form the come in the templates).  So I don't know if the cause of the inaccuracy is because of this or if something else is going on.  Could also be a bad time of day for taking GPS, but I wouldn't expect the phone to throw us this far off.
                        • Re: GPS locator not working for Election Polling Place ver 2.2
                          vanhornsky
                          Sorry I don't know about that. I just checked my computer and my phone at the same site and I am experiencing the opposite of what you are. My GPS is approx 25- 50 feet away from my location. While my computer is 2-3 miles away. Our production database is in State Plane, then we reproject to WebM for our online database. Our services are pointing to the Web database. I don't think this has anything to do with it though. Sorry I cant help you more.
                          • Re: GPS locator not working for Election Polling Place ver 2.2
                            SOppmann-esristaff
                            We posted an update to the Polling Place app this week that resolves several issues with Geolocation.  Please check out the latest release.