Locating results not display with my geocoder with WKID 2278 in Google map

656
3
04-22-2011 01:32 PM
XiujuZhou
New Contributor III
I am coding a Javascript application with ArcGIS Google Map Extension. I have my own geocoder which has spatial reference WKID 2278, not 4326. Results don't display in Google map. it works good for silverlight application by convert result to 4326 when display and online service test successful. but I don't know what should be done in this case. Please help!
0 Kudos
3 Replies
HemingZhu
Occasional Contributor III
I am coding a Javascript application with ArcGIS Google Map Extension. I have my own geocoder which has spatial reference WKID 2278, not 4326. Results don't display in Google map. it works good for silverlight application by convert result to 4326 when display and online service test successful. but I don't know what should be done in this case. Please help!


If you looked at Google Map API, Point or location -GLatLng is specified with lon/lat even though the Google Map is in WKID 102100. I would suggest that you covert your locator layer to WKID 4326. Otherwise you will have to do some covertion from State Plane feet to lon/lat before adding your result to the Google Map.
0 Kudos
XiujuZhou
New Contributor III
If you looked at Google Map API, Point or location -GLatLng is specified with lon/lat even though the Google Map is in WKID 102100. I would suggest that you covert your locator layer to WKID 4326. Otherwise you will have to do some covertion from State Plane feet to lon/lat before adding your result to the Google Map.


Thanks for your help. How to the conversion from State Plane feet to lon/lat before adding your result to the Google Map?
0 Kudos
HemingZhu
Occasional Contributor III
Thanks for your help. How to the conversion from State Plane feet to lon/lat before adding your result to the Google Map?


Like i said the best solution is convert your geocode reference layer to 4326. then publish your locator service and problem solved. If this solution is not feasible, Then you can do the following:
1. Access you actual address locator through Arcatalog->Address Locator Properties. Check X and Y coordinates under Output Fields. 2. Refresh your locator service. 3. In your code, after you do the geocode, reproject your addressCandidate to SR 4326. Here is the code snippets on top your code just give you some ideas:

var gOverlays = null;
var geometry;

function initialize() {
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(29.76, -95.36),12); // Redlands (Point)
mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);

geometry = new esri.arcgis.gmaps.Geometry("http://sampleserver1.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer");
locator = new esri.arcgis.gmaps.Locator("http://gisapps.houstongims.org/ArcGIS/rest/services/Address_Locator_Zip_Appr_HCAD_Parcel2009/Geocode...");
}

function findAddress() {
mapExtension.removeFromMap(gOverlays);

var address = new Object();
address.Street="611 Walker";
address.Zone= "77002";
var outFields = ["Street", "X", "Y"];
locator.addressToLocations(address, outFields, false, mycallback);
}
function mycallback(addressResults) {
var address = addressResults.addressCandidates[0];
var params = new esri.arcgis.gmaps.ProjectParameters();
params.geometries = [ { x: address.attributes.X, y: address.attributes.Y } ];
params.inSpatialReference = 2278;
params.outSpatialReference = 4326;
params.geometryType = "esriGeometryPoint";

geometry.project(params, function(projectResults) {
// marker will be your geocoded point
var marker = projectResults.geometries[0][0];
..... then add it the map or do something.
});

}

Hop it will help
0 Kudos