Using British National Grid Data with ArcGIS Server Google Maps Extension

1471
4
Jump to solution
02-24-2013 11:31 PM
DarrylHilton
New Contributor III
Hi

I am pretty new to this end of things. I have created some code using various sources to create a map window which uses the Google maps extension to plot data from my ArcGIS Server within the view window, and then allow users to click on a record and retirieve attributes of each record.

My problem is the data is mis-aligned (varies slightly but is approx 120 metres off) which I am assuming id down to the chane between projection systems for each. (As I am in the UK we use British National Grid, and google maps uses WGS1984).

Googlemaps is the preferred background, so is there any way to ensure the data line up as it should? See code below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html debug=true>   <head>     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />     <title>DH Test - Return Data from ArcGIS Server</title>      <script src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyC2qROCcqJ_yZbBRaojMmNSgc-cIByJrac"type="text/javascript"></script>      <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>      <script type="text/javascript">        var gmap = null;       var qtask = null;       var query = null;       var mapExtension = null;       var gOverlays = null;        function initialize() {         // GMap construction         gmap = new GMap2(document.getElementById('gmap'));         gmap.addMapType(G_NORMAL_MAP);         gmap.addMapType(G_SATELLITE_MAP);         gmap.addControl(new GLargeMapControl());         gmap.addControl(new GMapTypeControl());         gmap.setCenter(new GLatLng(53.5167, -1.1333), 10);         gmap.enableScrollWheelZoom();           //Create MapExtension utility class         mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);           // Query Task         qtask = new esri.arcgis.gmaps.QueryTask("http://gisfusinternet/ArcGIS/rest/services/GoogleTest/MapServer/0");          // You can execute a task and listen for the complete event or use the callback to get the results         GEvent.addListener(qtask, "executecomplete", function() {           //console.debug("'query task complete' event fired!!!");         });          // Query         query = new esri.arcgis.gmaps.Query();       }        function executeQuery() {         var bounds = gmap.getBounds();          // clear map overlays and event listeners using MapExtension removeFromMap         mapExtension.removeFromMap(gOverlays);          // set query parameters         query.queryGeometry = bounds;         query.returnGeometry = true;   query.outFields = ["SYMLINK", "UNITNO"];          // execute query task         qtask.execute(query, false, mycallback);        }        function mycallback(fset) {         //JS literal class esri.arcgis.gmaps.OverlayOptions         var overlayOptions = {           strokeColor:"#FF0000",           strokeWeight:3,           strokeOpacity:0.75,           fillColor:"#000066",           fillOpacity:0.4         };          //JS literal class esri.arcgis.gmaps.InfoWindowOptions without tabs         var infoWindowOptions = {           content:"<p>UNITID = <b>{SYMLINK}</b></br>Column Number = <b>{UNITNO}</b></p>"         };          gOverlays = mapExtension.addToMap(fset,overlayOptions,infoWindowOptions);       }      </script>    </head>    <body onload="initialize();" onunload="GUnload();">   <table width="100%" height="100%">     <tr>       <td align="center">          <table>           <tr align="left">             <td>               <input type="button" value="Execute Query" onclick="executeQuery();" />                 <input type="button" value="Clear Map Overlays" onclick="mapExtension.removeFromMap(gOverlays);" />             </td>           </tr>            <tr align="left" valign="top">             <td>               <div id="gmap" style="width: 500px; height:500px;"></div>             </td>           </tr>           </table>        </td>     </tr>   </table>   </body> </html> 






Alternatively, how would I do the same using background maps on my own server if this is not possible?
0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Frequent Contributor
0 Kudos
4 Replies
AnthonyGiles
Frequent Contributor
0 Kudos
DarrylHilton
New Contributor III
Thanks thats has sorted me perfectly.

While I am here, but may need another thread as it's not strictly speaknig the same issue:

On this same map, I currently have the attribute data I require coming up as a pop up witin the googlemap frame. I ideally could with those values, as well as the coordinates, writing to a box outside the map view (the end goal being to populate an external database using Web Services)
0 Kudos
AnthonyGiles
Frequent Contributor
Darryl,

It would be probably be better to start a new thread under the appropiate api you are using as the answer will differ depending on which language you are using (flex,silverlight,javascript).

Then you can mark this thread as answered 😮

Regards

Anthony
0 Kudos
DarrylHilton
New Contributor III

Then you can mark this thread as answered 😮

Regards

Anthony


Thanks...now for my daft question

How do I mark it as answered?:confused:
0 Kudos