I'm using silverlight maps control from ESRI. Currently showing 2 layers (allowing users to switch) between
if (this.RoadRadioButton.IsChecked.HasValue && this.RoadRadioButton.IsChecked.Value)
{
arcgisLayer.Url = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
}
else if (this.AerialRadioButton.IsChecked.HasValue && this.AerialRadioButton.IsChecked.Value)
{
arcgisLayer.Url = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer";
}
My users would like to have
1. On street view - highway exit numbers
2. On imagery - street names, similar how Bing does it.
Is it possible, is there way to merge layers or something like this?
Browse the services directory for more layer types here: http://services.arcgisonline.com/
Especially look at the service in the References folder:
http://services.arcgisonline.com/arcgis/rest/services/Reference
You can use these as overlays on top of other layers.
On a side-note, don't ever change the URL of a running layer - You can get into a LOT of trouble doing that. Instead use two layers, and flip the visibility. That will also make the combo of multiple layers easier. Just put the aerial and the reference layer in a group layer and toggle the group layer. Even better you can bind the Visible parameter of your layer straight to your radio button so you don't need any code behind. Ie
<GroupLayer Visible="{Binding IsChecked.Value, ElementName=AerialRadioButton}">
<!-- add your composite set of layers here -->
</GroupLayer>
Related
In my design page, the user will be creating/drawing new shapes, in addition to adding image overlays. I'm finding that any shapes drawn using the drawing manager are rendering underneath any image overlays added to the map, see below:
I'd like to know how to achieve a couple of tasks:
1 - How to set the drawing manager so any shape (rectangle/point/circle etc be default is always added as an upper/top layer when the drawingcomplete event has fired, that way the shapes will always appear above any images added to the map.
2 - How to programatically change the order of the various layers created during design, given the user may want to adjust the z-index of the various layers to suit their own endering requirements.
The MS docs here is not really helping me understand how to achieve the above, but also doesnt mention anything about shapes/layers that currently reside within the drawing manager.
Partial answer but along the right tracks...
We can retrieve the shapes (drawing manager layers) from the drawing manager so we have a reference to them.
When i add an image overlay, before actually adding/rendering it to the map, i would first get the shape layers from the drawing manager, then remove them from the map.
Next we add the image overlay to the map and add the shape layers back in as well, its the order that we add/remove the layers that seems to be relevant here.
Once i had added all layers back to the map in the chosen order, i was still able to put the drawing manager into edit mode and select the shape for editing, so i beleive this will work as my solution going forwards.
// Create the image layer
var imageLayer = new atlas.layer.ImageLayer({
url: 'myImageUrl,
coordinates: coordinates
})
// Then get the existing shapes (layers) from the DM
var layers = drawingManager.getLayers();
console.log(layers);
// Remove the shapes.
map.layers.remove(layers.polygonLayer); // polygonLayer as an example...
// Add new image overlay, then the shapes
map.layers.add([imageLayer, layers.polygonLayer]);
I have an app that can be rotated, so I need to deal with portrait and landscape orientations. Additionally, users will be allowed to use pinch gestures to change the scale of views. Here is the basic hierarchy of the views.
mainView is a subview of self.view (from the context of the main view controller). It is a UIImageView, although the image part of it is relatively unimportant. In any case, this is the view within which the rest of the views in this discussion are placed as subviews.
The first is what I call the board. It is the view on which items are assembled by the user. These items are themselves image views.
Additionally, there are what I call palettes. These are simply views that can be resized and scaled by the user. Additionally, the image views just mentioned can be dragged from one palette to another or to the board. The palettes can be thought of as work space for the user. When they are finished their work, they place their assembly onto the board.
So far, I've been working with the app where the board is part of autolayout but the palettes are created programatically as needed. This is good because when the user rotates the device, autolayout automatically places the board appropriately. At least it did until I wanted to add pinch scaling to it.
Autolayout has the following constraints set to it in interface builder:
Leading, top, trailing, and bottom all set to superview default.
When the user scales the view, the result is that it sort of sticks to the upper-left corner of the screen. I'd rather have it retain the center.
I tried changing this programmatically by adding the following code to the pinch gesture recognizer for this view:
if (self.pinchView.tag == TAGBOARD) {
[NSLayoutConstraint constraintWithItem:self.pinchView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.mainView
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0];
}
but this seemed to do nothing. I'm guessing it's because it conflicts with the IB constraints. Is there something else I can do to make this work with autolayout? Or should I just do it all programmatically like I do with the other views?
In this code example, self.pinchView is the view on which the pinch gesture is applied to. For the sake of this discussion, it is what I've called the board. The self.mainView view is its superview.
The part we're not seeing in the code is something like
[self.pinchView addConstraint:yourNewConstraint];
I can see where you create the constraint, but not add it to the view. If you want your constraint to win you'll need to remove the other views or make sure the new constraint has a higher priority.
If your view should be centered, try adjusting the constraints in the storyboard to pin the width and height to the default and then aligning horizontally in the center. That should satisfy autolayout and replicate what you're trying to add, then in your pinch recognizer you can change the constant of the width and height. Be sure to drag your width and height constraints into your controller to create an outlet so that you can adjust them during the pinch gesture.
we want to make application like silverlight showcase Mapview
where we can search by different category on left hand side panel or people can select country or region on map. can anyone suggest some sample or guidelines to implement this?
Thanks
Given the complexity and obvious expense, I would be really impressed if anything like that was released as a sample (Microsoft are you listening?). It requires a lot of data to drive it.
I have been involved in creating a Xaml World map from scratch (below) and that alone took nearly a day for a stylised polygon version (no fine detail)....
Quoting myself: "You import a map as a background image and use the pen tool to dot-to-dot trace around the country. Combine all those path segments into a single path. Then create a separate poly-path for each state (close them to allow for a fill)."
Once you create them you can name the individual country polygons and connect up mouse logic to make them all glow on mouse over or change colour on press etc.
Basically all the other stuff on that screen are user controls and custom controls. Work out the behaviour you want and create controls to suit your own needs.
I've been working with bing maps in Silverlight recently and have things at a good working order. One quirk that I would like to resolve is that all of my shapes that are drawn on the page get rendered on top of the road layer and even worse, the city names. So if my shapes are opaque, you can't read them. I'm figuring that there must be some z-index type property involved but I'm having a hard time finding any information about it.
Does anyone know how to set the stack order of the layers provided? Is there a particular index of the existing layers (roads, street names, city names and so on)?
Don't think so. The base Bing map layers (map, aerial, aerial with labels) are just prebuilt tiled images. Shapes added will be on top of those images.
I want to build some GUI where an image is presented, and the user should pick nd/or adjust some points (ellipses) according to the image. Basically, like a map control, when we want to mark some points or make a route, but instead of a map, a picture must be presented. The final locations will be used for image processing. Is there a built-in silverlight functionality to do this? How should be the best way?
regards
for the Drag & Drop part, there is no built-in functionality in Silverlight so far (at least not for UIElements). But there are many implementations out there that provide this functionality, e.g. the DragDropManager on Codeplex:
http://silverlightdragdrop.codeplex.com/
These "workarounds" usually use mouse events and CaptureMouse/ReleaseMouseCapture to implement Drag & Drop behavior on UIElements.
Once you have Drag & Drop in your app, the rest should not be too hard. I'd place the image inside a Canvas and then move the markers around on that Canvas using the functionality provided by e.g. the Codeplex Drag & Drop implementation. Basically, all you have to do is set Canvas.Top/Canvas.Left for a marker based on where the mouse is.
Cheers, Alex