Select to view content in your preferred language

Not zoomig to geocoded address first time

590
4
Jump to solution
08-04-2023 10:47 PM
ADITYAKUMAR1
Occasional Contributor III

HI,

  I am using geocode services to geocode and zoom to the address. When I use world geocoding it works fine but when I use my custom geocoding it geocodes well but doesnt zoom to the first time. from second geocode it works as expected. I get the below error fist time.

ADITYAKUMAR1_0-1691214249329.png

I am not sure if its a problem with custom geocode or any other issue is there. Has anyone faced similar issue?

 

Thanks
Aditya Kumar

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ADITYAKUMAR1
Occasional Contributor III

@JoelBennett I managed to resolve it from the server side. Earlier i was using the data from the sql server but now i created a geodatabase. Imported the layer inside it. Created a locator and assigned Auto into the performance tab under properties section. Published it and its working as expected.

 

Thanks

View solution in original post

0 Kudos
4 Replies
JoelBennett
MVP Regular Contributor

This error indicates the client-side projection engine is being used before it's fully loaded.  Unlike other modules which you can immediately use after bringing them in via require, define, or declare, the projection engine must be explicitly loaded as well.  Loading this module is asynchronous, so is not immediately available upon calling load.  You must wait until the promise returned by the load function resolves before it can be used.

At a minimum, you would need something like this:

require(["esri/geometry/projection"], function(projectionEngine) {
	projectionEngine.load().then(function() {
		//do geocoding logic
	});
});

 

However, it would probably be better to move the importing and loading of this module into your application startup code.

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

@JoelBennett Thnaks for the response. But I am confused why this happens only with custom geocoding services and not with World geocoding services. And the projection Engine has problem just at  the first search.

0 Kudos
JoelBennett
MVP Regular Contributor

Without knowing the details of the workflow, it's impossible for me to say.  What is plainly evident, though, is that your custom workflow is using the client-side projection engine, whether explicitly or behind the scenes.  Perhaps it is because the service is returning results in a different coordinate system than the map, thus making projection necessary.

Whatever the case, it has a problem with the first search because it hasn't loaded yet.  It seems to be that by the time the second search is attempted, the projection module has fully loaded, and therefore works after that.  The solution is for you to load it yourself prior to any searching taking place.  Perhaps the best way to do that would be to load it before instantiating your Map control, when your application is starting up:

require(["esri/map", "esri/geometry/projection", "other/modules"], function(Map, projectionEngine, otherModules) {
	projectionEngine.load().then(function() {
		var map = new Map({
			//etc
		});
	});
});

 

ADITYAKUMAR1
Occasional Contributor III

@JoelBennett I managed to resolve it from the server side. Earlier i was using the data from the sql server but now i created a geodatabase. Imported the layer inside it. Created a locator and assigned Auto into the performance tab under properties section. Published it and its working as expected.

 

Thanks

0 Kudos