将Near Me移植到本地内网时,由于Near Me的setting.js文件中的setConfig函数中
var helperServices = portalUtils.getportal(this.appconfig.portalUrl);
读取的都是portal默认的esri的一些路径,如几何服务、搜索服务等,因此需要手动更改几个地方。
1、search.js文件:
112行:
array.forEach(geocoders, lang.hitch(this, function (geocoder) {
if (geocoder.url) {
if (geocoder.url.indexOf(".arcgis.com/arcgis/rest/services/World/GeocodeServer") > -1) {
geocoder.hasEsri = true;
geocoder.locator = new Locator(geocoder.url);
geocoder.placefinding = true;
geocoder.singleLineFieldName = "SingleLine";
geocoder.name = geocoder.name ||
"Esri World Geocoder";
//set place holder with geocoder name if it is not configured
geocoder.placeholder = geocoder.placeholder || geocoder.name;
if (this.config.searchExtent) {
geocoder.searchExtent = this.map.extent;
geocoder.localSearchOptions = {
minScale: 300000,
distance: 50000
};
}
geocoder.suggest = true;
defaultSources.push(geocoder);
} else if (esriLang.isDefined(geocoder.singleLineFieldName)) {
//Add geocoders with a singleLineFieldName defined
geocoder.locator = new Locator(geocoder.url);
geocoder.suggest = true;
defaultSources.push(geocoder);
}
}
}));
改成:
// if (geocoder.url.indexOf(".arcgis.com/arcgis/rest/services/World/GeocodeServer") > -1) {
<span style="color:#ff0000;">geocoder.url="自己的检索服务";</span>
geocoder.hasEsri = true;
geocoder.locator = new Locator(geocoder.url);
geocoder.placefinding = true;
geocoder.singleLineFieldName = "SingleLine";
geocoder.name = geocoder.name ||
"Esri World Geocoder";
//set place holder with geocoder name if it is not configured
<span style="color:#ff6666;">geocoder.placeholder = "zj";</span>
if (this.config.searchExtent) {
geocoder.searchExtent = this.map.extent;
geocoder.localSearchOptions = {
minScale: 300000,
distance: 50000
};
}
geocoder.suggest = true;
defaultSources.push(geocoder);
// } else if (esriLang.isDefined(geocoder.singleLineFieldName)) {
// //Add geocoders with a singleLineFieldName defined
// geocoder.locator = new Locator(geocoder.url);
// geocoder.suggest = true;
// defaultSources.push(geocoder);
// }
2、Widget.js:
308行:
_initReverseGeocoder: function () {
//By default if no geocoding service available in org then ArcGis online GeocodeServer will be used for reverse geocoding.
var geocodeURL =
"https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer";
if (this.config.helperServices && this.config.helperServices.geocode &&
this.config.helperServices.geocode[0] && this.config.helperServices
.geocode[0].url) {
geocodeURL = this.config.helperServices.geocode[0].url;
}
//create the locator instance to reverse geocode the address
this._locatorInstance = new Locator(geocodeURL);
this._locatorInstance.on("location-to-address-complete", lang.hitch(
this, this._onLocationToAddressComplete));
},
改成:
_initReverseGeocoder: function () {
//By default if no geocoding service available in org then ArcGis online GeocodeServer will be used for reverse geocoding.
<span style="color:#ff0000;">var geocodeURL ="自己的检索服务";</span>
//if (this.config.helperServices && this.config.helperServices.geocode &&
// this.config.helperServices.geocode[0] && this.config.helperServices
// .geocode[0].url) {
// geocodeURL = this.config.helperServices.geocode[0].url;
//}
//create the locator instance to reverse geocode the address
this._locatorInstance = new Locator(geocodeURL);
this._locatorInstance.on("location-to-address-complete", lang.hitch(
this, this._onLocationToAddressComplete));
},
544行:
_createBuffer: function () {
var params, geometryService;
geometryService = new GeometryService(this.config.helperServices.geometry.url);
改成:
_createBuffer: function () {
var params, geometryService;
<span style="color:#ff0000;">geometryService = new GeometryService(“自己的几何服务”);</span>
3、总配置文件config.json
更改geometryService:""的值。