Having Issue on Implementing MVVM with ArcGIS Runtime Local Server
I am trying to setup a ESRI Local Server for displaying .mpk
. I have a Model like
public class Model
{
private string basemapLayerUri = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
private string mapPackage = "D:\App\Data\Canada.mpk";
public Model() { }
public string BasemapLayerUri
{
get { return this.basemapLayerUri; }
set
{
if (value != this.basemapLayerUri)
{
this.basemapLayerUri = value;
}
}
}
public string MapPackage
{
get { return this.mapPackage; }
set
{
if (value != this.mapPackage)
{
this.mapPackage = value;
}
}
}
}
in ViewModel.cs
Class I have
public class ViewModel : INotifyPropertyChanged
{
public Model myModel { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public ViewModel()
{
myModel = new Model();
this.CreateLocalServiceAndDynamicLayer();
}
public string BasemapUri
{
get { return myModel.BasemapLayerUri; }
set
{
this.myModel.BasemapLayerUri = value;
OnPropertyChanged("BasemapUri");
}
}
public async void CreateLocalServiceAndDynamicLayer()
{
LocalMapService localMapService = new LocalMapService(this.MAPKMap);
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
//myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
}
public string MAPKMap
{
get { return myModel.MapPackage; }
set
{
this.myModel.MapPackage = value;
OnPropertyChanged("MAPKMap");
}
}
protected void OnPropertyChanged([CallerMemberName] string member = "")
{
var eventHandler = PropertyChanged;
if (eventHandler != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
}
As you can see I am trying to implement the local server and dynamic layer in ViewModel.cs
like
public async void CreateLocalServiceAndDynamicLayer()
{
LocalMapService localMapService = new LocalMapService(this.MAPKMap);
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
//myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
}
but I do not know how to bind this service to the Model
? I tried
myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
but as you know the myModel
doesn't have any Map object.
Update
using M_PK2.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Esri.ArcGISRuntime.LocalServices;
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Layers;
namespace M_PK2.ViewModels
{
class ViewModel : ViewModelBase
{
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel()
{
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args)
{
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
OnPropertyChanged(nameof(Layers)); //Notify UI
}
public LayerCollection Layers
{
get
{
return layers;
}
}
}
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "")
{
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
}
c# mvvm arcgis-runtime arcgis-runtime-net
add a comment |
I am trying to setup a ESRI Local Server for displaying .mpk
. I have a Model like
public class Model
{
private string basemapLayerUri = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
private string mapPackage = "D:\App\Data\Canada.mpk";
public Model() { }
public string BasemapLayerUri
{
get { return this.basemapLayerUri; }
set
{
if (value != this.basemapLayerUri)
{
this.basemapLayerUri = value;
}
}
}
public string MapPackage
{
get { return this.mapPackage; }
set
{
if (value != this.mapPackage)
{
this.mapPackage = value;
}
}
}
}
in ViewModel.cs
Class I have
public class ViewModel : INotifyPropertyChanged
{
public Model myModel { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public ViewModel()
{
myModel = new Model();
this.CreateLocalServiceAndDynamicLayer();
}
public string BasemapUri
{
get { return myModel.BasemapLayerUri; }
set
{
this.myModel.BasemapLayerUri = value;
OnPropertyChanged("BasemapUri");
}
}
public async void CreateLocalServiceAndDynamicLayer()
{
LocalMapService localMapService = new LocalMapService(this.MAPKMap);
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
//myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
}
public string MAPKMap
{
get { return myModel.MapPackage; }
set
{
this.myModel.MapPackage = value;
OnPropertyChanged("MAPKMap");
}
}
protected void OnPropertyChanged([CallerMemberName] string member = "")
{
var eventHandler = PropertyChanged;
if (eventHandler != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
}
As you can see I am trying to implement the local server and dynamic layer in ViewModel.cs
like
public async void CreateLocalServiceAndDynamicLayer()
{
LocalMapService localMapService = new LocalMapService(this.MAPKMap);
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
//myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
}
but I do not know how to bind this service to the Model
? I tried
myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
but as you know the myModel
doesn't have any Map object.
Update
using M_PK2.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Esri.ArcGISRuntime.LocalServices;
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Layers;
namespace M_PK2.ViewModels
{
class ViewModel : ViewModelBase
{
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel()
{
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args)
{
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
OnPropertyChanged(nameof(Layers)); //Notify UI
}
public LayerCollection Layers
{
get
{
return layers;
}
}
}
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "")
{
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
}
c# mvvm arcgis-runtime arcgis-runtime-net
Looking at the code example and the docs tells usArcGISDynamicMapServiceLayer
is a UI component and belongs in the view. OnlyID
andServiceUri
should be provided by the viewmodel.
– Funk
Dec 5 '18 at 20:07
Thanks Funk but this is more about loading theArcGISDynamicMapServiceLayer
not the service layer by itself! the problem is where to populate this dervice in Model or viewmodel without breaking the MVVM roles
– Mona Coder
Dec 5 '18 at 21:09
add a comment |
I am trying to setup a ESRI Local Server for displaying .mpk
. I have a Model like
public class Model
{
private string basemapLayerUri = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
private string mapPackage = "D:\App\Data\Canada.mpk";
public Model() { }
public string BasemapLayerUri
{
get { return this.basemapLayerUri; }
set
{
if (value != this.basemapLayerUri)
{
this.basemapLayerUri = value;
}
}
}
public string MapPackage
{
get { return this.mapPackage; }
set
{
if (value != this.mapPackage)
{
this.mapPackage = value;
}
}
}
}
in ViewModel.cs
Class I have
public class ViewModel : INotifyPropertyChanged
{
public Model myModel { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public ViewModel()
{
myModel = new Model();
this.CreateLocalServiceAndDynamicLayer();
}
public string BasemapUri
{
get { return myModel.BasemapLayerUri; }
set
{
this.myModel.BasemapLayerUri = value;
OnPropertyChanged("BasemapUri");
}
}
public async void CreateLocalServiceAndDynamicLayer()
{
LocalMapService localMapService = new LocalMapService(this.MAPKMap);
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
//myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
}
public string MAPKMap
{
get { return myModel.MapPackage; }
set
{
this.myModel.MapPackage = value;
OnPropertyChanged("MAPKMap");
}
}
protected void OnPropertyChanged([CallerMemberName] string member = "")
{
var eventHandler = PropertyChanged;
if (eventHandler != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
}
As you can see I am trying to implement the local server and dynamic layer in ViewModel.cs
like
public async void CreateLocalServiceAndDynamicLayer()
{
LocalMapService localMapService = new LocalMapService(this.MAPKMap);
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
//myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
}
but I do not know how to bind this service to the Model
? I tried
myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
but as you know the myModel
doesn't have any Map object.
Update
using M_PK2.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Esri.ArcGISRuntime.LocalServices;
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Layers;
namespace M_PK2.ViewModels
{
class ViewModel : ViewModelBase
{
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel()
{
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args)
{
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
OnPropertyChanged(nameof(Layers)); //Notify UI
}
public LayerCollection Layers
{
get
{
return layers;
}
}
}
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "")
{
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
}
c# mvvm arcgis-runtime arcgis-runtime-net
I am trying to setup a ESRI Local Server for displaying .mpk
. I have a Model like
public class Model
{
private string basemapLayerUri = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
private string mapPackage = "D:\App\Data\Canada.mpk";
public Model() { }
public string BasemapLayerUri
{
get { return this.basemapLayerUri; }
set
{
if (value != this.basemapLayerUri)
{
this.basemapLayerUri = value;
}
}
}
public string MapPackage
{
get { return this.mapPackage; }
set
{
if (value != this.mapPackage)
{
this.mapPackage = value;
}
}
}
}
in ViewModel.cs
Class I have
public class ViewModel : INotifyPropertyChanged
{
public Model myModel { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public ViewModel()
{
myModel = new Model();
this.CreateLocalServiceAndDynamicLayer();
}
public string BasemapUri
{
get { return myModel.BasemapLayerUri; }
set
{
this.myModel.BasemapLayerUri = value;
OnPropertyChanged("BasemapUri");
}
}
public async void CreateLocalServiceAndDynamicLayer()
{
LocalMapService localMapService = new LocalMapService(this.MAPKMap);
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
//myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
}
public string MAPKMap
{
get { return myModel.MapPackage; }
set
{
this.myModel.MapPackage = value;
OnPropertyChanged("MAPKMap");
}
}
protected void OnPropertyChanged([CallerMemberName] string member = "")
{
var eventHandler = PropertyChanged;
if (eventHandler != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
}
As you can see I am trying to implement the local server and dynamic layer in ViewModel.cs
like
public async void CreateLocalServiceAndDynamicLayer()
{
LocalMapService localMapService = new LocalMapService(this.MAPKMap);
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
//myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
}
but I do not know how to bind this service to the Model
? I tried
myModel.Map.Layers.Add(arcGISDynamicMapServiceLayer);
but as you know the myModel
doesn't have any Map object.
Update
using M_PK2.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Esri.ArcGISRuntime.LocalServices;
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Layers;
namespace M_PK2.ViewModels
{
class ViewModel : ViewModelBase
{
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel()
{
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args)
{
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer()
{
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
OnPropertyChanged(nameof(Layers)); //Notify UI
}
public LayerCollection Layers
{
get
{
return layers;
}
}
}
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "")
{
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
}
c# mvvm arcgis-runtime arcgis-runtime-net
c# mvvm arcgis-runtime arcgis-runtime-net
edited Dec 8 '18 at 0:03
Mona Coder
asked Nov 21 '18 at 20:14


Mona CoderMona Coder
2,445134086
2,445134086
Looking at the code example and the docs tells usArcGISDynamicMapServiceLayer
is a UI component and belongs in the view. OnlyID
andServiceUri
should be provided by the viewmodel.
– Funk
Dec 5 '18 at 20:07
Thanks Funk but this is more about loading theArcGISDynamicMapServiceLayer
not the service layer by itself! the problem is where to populate this dervice in Model or viewmodel without breaking the MVVM roles
– Mona Coder
Dec 5 '18 at 21:09
add a comment |
Looking at the code example and the docs tells usArcGISDynamicMapServiceLayer
is a UI component and belongs in the view. OnlyID
andServiceUri
should be provided by the viewmodel.
– Funk
Dec 5 '18 at 20:07
Thanks Funk but this is more about loading theArcGISDynamicMapServiceLayer
not the service layer by itself! the problem is where to populate this dervice in Model or viewmodel without breaking the MVVM roles
– Mona Coder
Dec 5 '18 at 21:09
Looking at the code example and the docs tells us
ArcGISDynamicMapServiceLayer
is a UI component and belongs in the view. Only ID
and ServiceUri
should be provided by the viewmodel.– Funk
Dec 5 '18 at 20:07
Looking at the code example and the docs tells us
ArcGISDynamicMapServiceLayer
is a UI component and belongs in the view. Only ID
and ServiceUri
should be provided by the viewmodel.– Funk
Dec 5 '18 at 20:07
Thanks Funk but this is more about loading the
ArcGISDynamicMapServiceLayer
not the service layer by itself! the problem is where to populate this dervice in Model or viewmodel without breaking the MVVM roles– Mona Coder
Dec 5 '18 at 21:09
Thanks Funk but this is more about loading the
ArcGISDynamicMapServiceLayer
not the service layer by itself! the problem is where to populate this dervice in Model or viewmodel without breaking the MVVM roles– Mona Coder
Dec 5 '18 at 21:09
add a comment |
2 Answers
2
active
oldest
votes
Avoid using async void
except for event handlers,
Reference Async/Await - Best Practices in Asynchronous Programming
In your case you are mixing UI concerns that belong in view. The view model should expose what the view needs in order to perform its function.
Because of the async nature of the used dependency LocalMapService
, you should create an async event handler to manage getting the service URI and notify the UI when that task is completed via a bound property change event.
For example
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private string serviceUri;
public ViewModel() {
myModel = new Model();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
ServiceUri = localMapService.UrlMapService; //notifies UI
}
public string ServiceUri {
get { return serviceUri; }
set {
serviceUri = value;
OnPropertyChanged();
}
}
}
public class ViewModelBase : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "") {
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
That way after the async starting of the service, the UI will get notified of the change.
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. -->
<esriControls:Map>
<!-- Add an ArcGISDynamicMapServiceLayer via XAML. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="mpklayer"
ServiceUri="{Bind ServiceUri}"/>
</esriControls:Map>
</esriControls:MapView>
If the goal is to be able to manipulate multiple layers then I would suggest binding to the Map.Layers Property to be able to have direct access to the layers collection in the view model.
The view model could end up looking like
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel() {
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer() {
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
}
public LayerCollection Layers {
get {
return layers;
}
}
}
And the view
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. with layers via binding-->
<esriControls:Map Layers="{Bind Layers, Mode=OneWay}" />
</esriControls:MapView>
You can now manipulate layers via code as needed
Thanks Nkosi, I like you idea withLayerCollection
but looks like this is not adding anything to the map! looks like theasync void onStarting()
is not hitting at all because when I try to debug it nothing is happening on putting breakpoint there
– Mona Coder
Dec 7 '18 at 19:00
I updated the view to<esriControls:Map Layers="{Binding Source={StaticResource VM}, Path=Layers}"/>
and it is working now
– Mona Coder
Dec 8 '18 at 0:13
Thanks but one more question what thestarting += onStarting; starting(this, EventArgs.Empty);
is doing exactly?
– Mona Coder
Dec 8 '18 at 0:14
starting += onStarting;
subscribes the event to the event handler.starting(this, EventArgs.Empty);
is actually raising the event.
– Nkosi
Dec 8 '18 at 0:15
@MonaCoder all of that as I indicated in the answer is to allow you to properly invoke the async API of theLocalMapService
– Nkosi
Dec 8 '18 at 0:20
add a comment |
I don't have SDK available to try, but following code should work:
View Model:
private readonly LocalMapService localMapService;
// initialize localMapService instance in the constructor
public string UrlMapService
{
get { return localMapService.UrlMapService; }
}
XAML:
<!-- A Map ControlView to display various GIS layers. -->
<esriControls:MapView x:Name="MapView1" Width="448" Height="480" VerticalAlignment="Top" Margin="2,2,2,2">
<!-- A Map. -->
<esriControls:Map x:Name="Map1" >
<!-- Add an ArcGISDynamicMapServiceLayer via Xaml. Set the ID and ImageFormat properties. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="serviceLayer" ImageFormat="PNG24"
ServiceUri="{Binding UrlMapService, Mode=OneWay}"/>
</esriControls:Map>
</esriControls:MapView>
Thanks Dipen I am able to see the ` localMapService.UrlMapService;` in the debugging mode but still getting empty white page on map on runtime. No error
– Mona Coder
Dec 5 '18 at 22:59
@MonaCoder make sure to calllocalMapService.StartAsync()
. You can either call it manually on the vm in code behind r can bind a command to window loaded event.
– Dipen Shah
Dec 5 '18 at 23:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419823%2fhaving-issue-on-implementing-mvvm-with-arcgis-runtime-local-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Avoid using async void
except for event handlers,
Reference Async/Await - Best Practices in Asynchronous Programming
In your case you are mixing UI concerns that belong in view. The view model should expose what the view needs in order to perform its function.
Because of the async nature of the used dependency LocalMapService
, you should create an async event handler to manage getting the service URI and notify the UI when that task is completed via a bound property change event.
For example
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private string serviceUri;
public ViewModel() {
myModel = new Model();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
ServiceUri = localMapService.UrlMapService; //notifies UI
}
public string ServiceUri {
get { return serviceUri; }
set {
serviceUri = value;
OnPropertyChanged();
}
}
}
public class ViewModelBase : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "") {
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
That way after the async starting of the service, the UI will get notified of the change.
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. -->
<esriControls:Map>
<!-- Add an ArcGISDynamicMapServiceLayer via XAML. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="mpklayer"
ServiceUri="{Bind ServiceUri}"/>
</esriControls:Map>
</esriControls:MapView>
If the goal is to be able to manipulate multiple layers then I would suggest binding to the Map.Layers Property to be able to have direct access to the layers collection in the view model.
The view model could end up looking like
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel() {
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer() {
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
}
public LayerCollection Layers {
get {
return layers;
}
}
}
And the view
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. with layers via binding-->
<esriControls:Map Layers="{Bind Layers, Mode=OneWay}" />
</esriControls:MapView>
You can now manipulate layers via code as needed
Thanks Nkosi, I like you idea withLayerCollection
but looks like this is not adding anything to the map! looks like theasync void onStarting()
is not hitting at all because when I try to debug it nothing is happening on putting breakpoint there
– Mona Coder
Dec 7 '18 at 19:00
I updated the view to<esriControls:Map Layers="{Binding Source={StaticResource VM}, Path=Layers}"/>
and it is working now
– Mona Coder
Dec 8 '18 at 0:13
Thanks but one more question what thestarting += onStarting; starting(this, EventArgs.Empty);
is doing exactly?
– Mona Coder
Dec 8 '18 at 0:14
starting += onStarting;
subscribes the event to the event handler.starting(this, EventArgs.Empty);
is actually raising the event.
– Nkosi
Dec 8 '18 at 0:15
@MonaCoder all of that as I indicated in the answer is to allow you to properly invoke the async API of theLocalMapService
– Nkosi
Dec 8 '18 at 0:20
add a comment |
Avoid using async void
except for event handlers,
Reference Async/Await - Best Practices in Asynchronous Programming
In your case you are mixing UI concerns that belong in view. The view model should expose what the view needs in order to perform its function.
Because of the async nature of the used dependency LocalMapService
, you should create an async event handler to manage getting the service URI and notify the UI when that task is completed via a bound property change event.
For example
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private string serviceUri;
public ViewModel() {
myModel = new Model();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
ServiceUri = localMapService.UrlMapService; //notifies UI
}
public string ServiceUri {
get { return serviceUri; }
set {
serviceUri = value;
OnPropertyChanged();
}
}
}
public class ViewModelBase : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "") {
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
That way after the async starting of the service, the UI will get notified of the change.
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. -->
<esriControls:Map>
<!-- Add an ArcGISDynamicMapServiceLayer via XAML. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="mpklayer"
ServiceUri="{Bind ServiceUri}"/>
</esriControls:Map>
</esriControls:MapView>
If the goal is to be able to manipulate multiple layers then I would suggest binding to the Map.Layers Property to be able to have direct access to the layers collection in the view model.
The view model could end up looking like
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel() {
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer() {
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
}
public LayerCollection Layers {
get {
return layers;
}
}
}
And the view
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. with layers via binding-->
<esriControls:Map Layers="{Bind Layers, Mode=OneWay}" />
</esriControls:MapView>
You can now manipulate layers via code as needed
Thanks Nkosi, I like you idea withLayerCollection
but looks like this is not adding anything to the map! looks like theasync void onStarting()
is not hitting at all because when I try to debug it nothing is happening on putting breakpoint there
– Mona Coder
Dec 7 '18 at 19:00
I updated the view to<esriControls:Map Layers="{Binding Source={StaticResource VM}, Path=Layers}"/>
and it is working now
– Mona Coder
Dec 8 '18 at 0:13
Thanks but one more question what thestarting += onStarting; starting(this, EventArgs.Empty);
is doing exactly?
– Mona Coder
Dec 8 '18 at 0:14
starting += onStarting;
subscribes the event to the event handler.starting(this, EventArgs.Empty);
is actually raising the event.
– Nkosi
Dec 8 '18 at 0:15
@MonaCoder all of that as I indicated in the answer is to allow you to properly invoke the async API of theLocalMapService
– Nkosi
Dec 8 '18 at 0:20
add a comment |
Avoid using async void
except for event handlers,
Reference Async/Await - Best Practices in Asynchronous Programming
In your case you are mixing UI concerns that belong in view. The view model should expose what the view needs in order to perform its function.
Because of the async nature of the used dependency LocalMapService
, you should create an async event handler to manage getting the service URI and notify the UI when that task is completed via a bound property change event.
For example
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private string serviceUri;
public ViewModel() {
myModel = new Model();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
ServiceUri = localMapService.UrlMapService; //notifies UI
}
public string ServiceUri {
get { return serviceUri; }
set {
serviceUri = value;
OnPropertyChanged();
}
}
}
public class ViewModelBase : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "") {
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
That way after the async starting of the service, the UI will get notified of the change.
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. -->
<esriControls:Map>
<!-- Add an ArcGISDynamicMapServiceLayer via XAML. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="mpklayer"
ServiceUri="{Bind ServiceUri}"/>
</esriControls:Map>
</esriControls:MapView>
If the goal is to be able to manipulate multiple layers then I would suggest binding to the Map.Layers Property to be able to have direct access to the layers collection in the view model.
The view model could end up looking like
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel() {
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer() {
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
}
public LayerCollection Layers {
get {
return layers;
}
}
}
And the view
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. with layers via binding-->
<esriControls:Map Layers="{Bind Layers, Mode=OneWay}" />
</esriControls:MapView>
You can now manipulate layers via code as needed
Avoid using async void
except for event handlers,
Reference Async/Await - Best Practices in Asynchronous Programming
In your case you are mixing UI concerns that belong in view. The view model should expose what the view needs in order to perform its function.
Because of the async nature of the used dependency LocalMapService
, you should create an async event handler to manage getting the service URI and notify the UI when that task is completed via a bound property change event.
For example
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private string serviceUri;
public ViewModel() {
myModel = new Model();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
ServiceUri = localMapService.UrlMapService; //notifies UI
}
public string ServiceUri {
get { return serviceUri; }
set {
serviceUri = value;
OnPropertyChanged();
}
}
}
public class ViewModelBase : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged([CallerMemberName] string member = "") {
PropertyChanged(this, new PropertyChangedEventArgs(member));
}
}
That way after the async starting of the service, the UI will get notified of the change.
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. -->
<esriControls:Map>
<!-- Add an ArcGISDynamicMapServiceLayer via XAML. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="mpklayer"
ServiceUri="{Bind ServiceUri}"/>
</esriControls:Map>
</esriControls:MapView>
If the goal is to be able to manipulate multiple layers then I would suggest binding to the Map.Layers Property to be able to have direct access to the layers collection in the view model.
The view model could end up looking like
public class ViewModel : ViewModelBase {
private readonly LocalMapService localMapService;
private readonly Model myModel;
private LayerCollection layers;
public ViewModel() {
myModel = new Model();
layers = new LayerCollection();
localMapService = new LocalMapService(myModel.MapPackage);
starting += onStarting;
starting(this, EventArgs.Empty);
}
private event EventHandler starting = delegate { };
private async void onStarting(object sender, EventArgs args) {
starting -= onStarting; //optional
// the following runs on background thread
await localMapService.StartAsync();
// returned to the UI thread
var serviceLayer = new ArcGISDynamicMapServiceLayer() {
ID = "mpklayer",
ServiceUri = localMapService.UrlMapService,
};
Layers.Add(serviceLayer);
}
public LayerCollection Layers {
get {
return layers;
}
}
}
And the view
<!-- Add a MapView Control. -->
<esriControls:MapView x:Name="MapView1">
<!-- Add a Map. with layers via binding-->
<esriControls:Map Layers="{Bind Layers, Mode=OneWay}" />
</esriControls:MapView>
You can now manipulate layers via code as needed
edited Dec 8 '18 at 0:21
answered Dec 7 '18 at 10:34


NkosiNkosi
116k16129193
116k16129193
Thanks Nkosi, I like you idea withLayerCollection
but looks like this is not adding anything to the map! looks like theasync void onStarting()
is not hitting at all because when I try to debug it nothing is happening on putting breakpoint there
– Mona Coder
Dec 7 '18 at 19:00
I updated the view to<esriControls:Map Layers="{Binding Source={StaticResource VM}, Path=Layers}"/>
and it is working now
– Mona Coder
Dec 8 '18 at 0:13
Thanks but one more question what thestarting += onStarting; starting(this, EventArgs.Empty);
is doing exactly?
– Mona Coder
Dec 8 '18 at 0:14
starting += onStarting;
subscribes the event to the event handler.starting(this, EventArgs.Empty);
is actually raising the event.
– Nkosi
Dec 8 '18 at 0:15
@MonaCoder all of that as I indicated in the answer is to allow you to properly invoke the async API of theLocalMapService
– Nkosi
Dec 8 '18 at 0:20
add a comment |
Thanks Nkosi, I like you idea withLayerCollection
but looks like this is not adding anything to the map! looks like theasync void onStarting()
is not hitting at all because when I try to debug it nothing is happening on putting breakpoint there
– Mona Coder
Dec 7 '18 at 19:00
I updated the view to<esriControls:Map Layers="{Binding Source={StaticResource VM}, Path=Layers}"/>
and it is working now
– Mona Coder
Dec 8 '18 at 0:13
Thanks but one more question what thestarting += onStarting; starting(this, EventArgs.Empty);
is doing exactly?
– Mona Coder
Dec 8 '18 at 0:14
starting += onStarting;
subscribes the event to the event handler.starting(this, EventArgs.Empty);
is actually raising the event.
– Nkosi
Dec 8 '18 at 0:15
@MonaCoder all of that as I indicated in the answer is to allow you to properly invoke the async API of theLocalMapService
– Nkosi
Dec 8 '18 at 0:20
Thanks Nkosi, I like you idea with
LayerCollection
but looks like this is not adding anything to the map! looks like the async void onStarting()
is not hitting at all because when I try to debug it nothing is happening on putting breakpoint there– Mona Coder
Dec 7 '18 at 19:00
Thanks Nkosi, I like you idea with
LayerCollection
but looks like this is not adding anything to the map! looks like the async void onStarting()
is not hitting at all because when I try to debug it nothing is happening on putting breakpoint there– Mona Coder
Dec 7 '18 at 19:00
I updated the view to
<esriControls:Map Layers="{Binding Source={StaticResource VM}, Path=Layers}"/>
and it is working now– Mona Coder
Dec 8 '18 at 0:13
I updated the view to
<esriControls:Map Layers="{Binding Source={StaticResource VM}, Path=Layers}"/>
and it is working now– Mona Coder
Dec 8 '18 at 0:13
Thanks but one more question what the
starting += onStarting; starting(this, EventArgs.Empty);
is doing exactly?– Mona Coder
Dec 8 '18 at 0:14
Thanks but one more question what the
starting += onStarting; starting(this, EventArgs.Empty);
is doing exactly?– Mona Coder
Dec 8 '18 at 0:14
starting += onStarting;
subscribes the event to the event handler. starting(this, EventArgs.Empty);
is actually raising the event.– Nkosi
Dec 8 '18 at 0:15
starting += onStarting;
subscribes the event to the event handler. starting(this, EventArgs.Empty);
is actually raising the event.– Nkosi
Dec 8 '18 at 0:15
@MonaCoder all of that as I indicated in the answer is to allow you to properly invoke the async API of the
LocalMapService
– Nkosi
Dec 8 '18 at 0:20
@MonaCoder all of that as I indicated in the answer is to allow you to properly invoke the async API of the
LocalMapService
– Nkosi
Dec 8 '18 at 0:20
add a comment |
I don't have SDK available to try, but following code should work:
View Model:
private readonly LocalMapService localMapService;
// initialize localMapService instance in the constructor
public string UrlMapService
{
get { return localMapService.UrlMapService; }
}
XAML:
<!-- A Map ControlView to display various GIS layers. -->
<esriControls:MapView x:Name="MapView1" Width="448" Height="480" VerticalAlignment="Top" Margin="2,2,2,2">
<!-- A Map. -->
<esriControls:Map x:Name="Map1" >
<!-- Add an ArcGISDynamicMapServiceLayer via Xaml. Set the ID and ImageFormat properties. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="serviceLayer" ImageFormat="PNG24"
ServiceUri="{Binding UrlMapService, Mode=OneWay}"/>
</esriControls:Map>
</esriControls:MapView>
Thanks Dipen I am able to see the ` localMapService.UrlMapService;` in the debugging mode but still getting empty white page on map on runtime. No error
– Mona Coder
Dec 5 '18 at 22:59
@MonaCoder make sure to calllocalMapService.StartAsync()
. You can either call it manually on the vm in code behind r can bind a command to window loaded event.
– Dipen Shah
Dec 5 '18 at 23:26
add a comment |
I don't have SDK available to try, but following code should work:
View Model:
private readonly LocalMapService localMapService;
// initialize localMapService instance in the constructor
public string UrlMapService
{
get { return localMapService.UrlMapService; }
}
XAML:
<!-- A Map ControlView to display various GIS layers. -->
<esriControls:MapView x:Name="MapView1" Width="448" Height="480" VerticalAlignment="Top" Margin="2,2,2,2">
<!-- A Map. -->
<esriControls:Map x:Name="Map1" >
<!-- Add an ArcGISDynamicMapServiceLayer via Xaml. Set the ID and ImageFormat properties. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="serviceLayer" ImageFormat="PNG24"
ServiceUri="{Binding UrlMapService, Mode=OneWay}"/>
</esriControls:Map>
</esriControls:MapView>
Thanks Dipen I am able to see the ` localMapService.UrlMapService;` in the debugging mode but still getting empty white page on map on runtime. No error
– Mona Coder
Dec 5 '18 at 22:59
@MonaCoder make sure to calllocalMapService.StartAsync()
. You can either call it manually on the vm in code behind r can bind a command to window loaded event.
– Dipen Shah
Dec 5 '18 at 23:26
add a comment |
I don't have SDK available to try, but following code should work:
View Model:
private readonly LocalMapService localMapService;
// initialize localMapService instance in the constructor
public string UrlMapService
{
get { return localMapService.UrlMapService; }
}
XAML:
<!-- A Map ControlView to display various GIS layers. -->
<esriControls:MapView x:Name="MapView1" Width="448" Height="480" VerticalAlignment="Top" Margin="2,2,2,2">
<!-- A Map. -->
<esriControls:Map x:Name="Map1" >
<!-- Add an ArcGISDynamicMapServiceLayer via Xaml. Set the ID and ImageFormat properties. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="serviceLayer" ImageFormat="PNG24"
ServiceUri="{Binding UrlMapService, Mode=OneWay}"/>
</esriControls:Map>
</esriControls:MapView>
I don't have SDK available to try, but following code should work:
View Model:
private readonly LocalMapService localMapService;
// initialize localMapService instance in the constructor
public string UrlMapService
{
get { return localMapService.UrlMapService; }
}
XAML:
<!-- A Map ControlView to display various GIS layers. -->
<esriControls:MapView x:Name="MapView1" Width="448" Height="480" VerticalAlignment="Top" Margin="2,2,2,2">
<!-- A Map. -->
<esriControls:Map x:Name="Map1" >
<!-- Add an ArcGISDynamicMapServiceLayer via Xaml. Set the ID and ImageFormat properties. -->
<esriLayers:ArcGISDynamicMapServiceLayer ID="serviceLayer" ImageFormat="PNG24"
ServiceUri="{Binding UrlMapService, Mode=OneWay}"/>
</esriControls:Map>
</esriControls:MapView>
answered Dec 5 '18 at 21:49


Dipen ShahDipen Shah
7,18011529
7,18011529
Thanks Dipen I am able to see the ` localMapService.UrlMapService;` in the debugging mode but still getting empty white page on map on runtime. No error
– Mona Coder
Dec 5 '18 at 22:59
@MonaCoder make sure to calllocalMapService.StartAsync()
. You can either call it manually on the vm in code behind r can bind a command to window loaded event.
– Dipen Shah
Dec 5 '18 at 23:26
add a comment |
Thanks Dipen I am able to see the ` localMapService.UrlMapService;` in the debugging mode but still getting empty white page on map on runtime. No error
– Mona Coder
Dec 5 '18 at 22:59
@MonaCoder make sure to calllocalMapService.StartAsync()
. You can either call it manually on the vm in code behind r can bind a command to window loaded event.
– Dipen Shah
Dec 5 '18 at 23:26
Thanks Dipen I am able to see the ` localMapService.UrlMapService;` in the debugging mode but still getting empty white page on map on runtime. No error
– Mona Coder
Dec 5 '18 at 22:59
Thanks Dipen I am able to see the ` localMapService.UrlMapService;` in the debugging mode but still getting empty white page on map on runtime. No error
– Mona Coder
Dec 5 '18 at 22:59
@MonaCoder make sure to call
localMapService.StartAsync()
. You can either call it manually on the vm in code behind r can bind a command to window loaded event.– Dipen Shah
Dec 5 '18 at 23:26
@MonaCoder make sure to call
localMapService.StartAsync()
. You can either call it manually on the vm in code behind r can bind a command to window loaded event.– Dipen Shah
Dec 5 '18 at 23:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419823%2fhaving-issue-on-implementing-mvvm-with-arcgis-runtime-local-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Looking at the code example and the docs tells us
ArcGISDynamicMapServiceLayer
is a UI component and belongs in the view. OnlyID
andServiceUri
should be provided by the viewmodel.– Funk
Dec 5 '18 at 20:07
Thanks Funk but this is more about loading the
ArcGISDynamicMapServiceLayer
not the service layer by itself! the problem is where to populate this dervice in Model or viewmodel without breaking the MVVM roles– Mona Coder
Dec 5 '18 at 21:09