POST
|
@NathanCastle1 This is just a small snippet example of what I'm doing. The MapPoint has the format in meters. Another issue I face when using the coordinate Formatter is all the methods either take a string as an argument or return a string. I have a MapPoint which needs converting to a MapPoint with a different format. using coordinateformatter and it returns a string then I loose the ability to access the lat/long properties of the MapPoint. private void MainMapView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Point p = e.GetPosition(MainMapView);
MapPoint mp = MainMapView.ScreenToLocation(e.GetPosition(MainMapView));
Trace.WriteLine(mp.X + " " + mp.Y);
}
... View more
06-23-2021
09:26 AM
|
0
|
1
|
3253
|
POST
|
Hello, I'm getting a point from a mouse click on the map. I use that point to create a MapPoint and use screen to location on that point. This allows MapPoint to have x/y properties. When I do this the x and y properties that MapPoint has are the meter measurements. However, I need the measurements of x/y ->lat/long to be in the degree and minutes format with the range of =-90 and =-180 degrees. Example: 45º,-94º lat/lon is about -10503190m, 5653794m x/y. I know there is the CoordinateFormatter to convert to lat/long, but this does not get it with the range of =-90 and =-180. It remains in terms of meters. I may have missed something and would love to be pointed in the right direction, but is there any converter out there that will do this for me?
... View more
06-22-2021
04:35 PM
|
0
|
3
|
3335
|
POST
|
@NathanCastle1 Thank you for your explanation. It was very clear and helpful. I was following the template project while trying to look things up that it did not explain (the InitializeComponent method being one of those things).
... View more
06-22-2021
03:31 PM
|
0
|
0
|
4061
|
POST
|
@JoeHershman //MainWindow.xaml.cs
public partial class MainWindow : Window
{
private MapViewModel mvm;
public MainWindow()
{
InitializeComponent();
mvm = new MapViewModel();
MapPoint mapCenterPoint = new MapPoint(-117.6709, 35.6225, SpatialReferences.Wgs84);
MainMapView.SetViewpoint(new Viewpoint(mapCenterPoint, 100000));
}
private void MainMapView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Point p = e.GetPosition(MainMapView);
MapPoint mp = MainMapView.ScreenToLocation(e.GetPosition(MainMapView));
mvm.createPoint(mp);
}
}
//MapViewModel.cs
class MapViewModel : INotifyPropertyChanged
{
public MapViewModel()
{
SetupMap();
}
private void SetupMap()
{
// Create a new map with a 'topographic vector' basemap.
Map = new Map(BasemapStyle.ArcGISTopographic);
}
... View more
06-22-2021
10:52 AM
|
0
|
1
|
4073
|
POST
|
@NathanCastle1 Thank you for those suggestions. Most of it is clear and makes sense as to why they would be better practice/necessary changes to be made. Is there anything I need to do to call update to the view after creating this point? Or once I add it to the graphics overlay with graphicsOverlay.Graphics.Add(pointGraphic); will it automatically update the view? Another thing, I have the two classes MainWindow.xaml/MW.xaml.cs and MapViewModel.cs. MainWindow in it's constructor calls InitializeComponent(); which in turns eventually calls the constructor of MapViewModel as part of setup. And then when I create an object of MapViewModel so that I can access the createPoint() method I call the constructor of MapViewModel again which will call setup() which just assigns the basemap type again. Would that mess this up? I can include code snippets of this if needed.
... View more
06-22-2021
08:39 AM
|
0
|
5
|
4085
|
POST
|
Hello, I want to be able to register a mouse click event and then plot a point graphic at that location. Right now I get the mouse click, get the location of that mouse click and then use those coordinates to create a graphic. After doing all this the point still does not display onto the map.. //MainWindow.xaml.cs
private void MainMapView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
MapViewModel mvm = new MapViewModel();
Point p = e.GetPosition(MainMapView);
MapPoint mp = MainMapView.ScreenToLocation(e.GetPosition(MainMapView));
mvm.createPoint(mp);
}
//MapViewModel.cs
public void createPoint(MapPoint point)
{
// Create a new graphics overlay to contain a variety of graphics.
var graphicsOverlay = new GraphicsOverlay();
// Add the overlay to a graphics overlay collection.
GraphicsOverlayCollection overlays = new GraphicsOverlayCollection
{
graphicsOverlay
};
// Set the view model's "GraphicsOverlays" property (will be consumed by the map view).
this.GraphicsOverlays = overlays;
var mapPoint = new MapPoint(point.X, point.Y, SpatialReferences.Wgs84);
// Create a symbol to define how the point is displayed.
var pointSymbol = new SimpleMarkerSymbol
{
Style = SimpleMarkerSymbolStyle.X,
Color = System.Drawing.Color.Red,
Size = 10.0
};
// Add an outline to the symbol.
pointSymbol.Outline = new SimpleLineSymbol
{
Style = SimpleLineSymbolStyle.Solid,
Color = System.Drawing.Color.Red,
Width = 2.0
};
// Create a point graphic with the geometry and symbol.
var pointGraphic = new Graphic(mapPoint, pointSymbol);
// Add the point graphic to graphics overlay.
graphicsOverlay.Graphics.Add(pointGraphic);
}
... View more
06-21-2021
03:20 PM
|
0
|
11
|
4376
|
POST
|
@Nicholas-FurnessThat makes a lot of sense thanks! So when I use the built in screenToLocation method it returns a MapPoint value that has X/Y attributes in the form of meters not lat/long with ranges of +-90 and =-180 (Assuming because my basemap is webMercator or because that is always the return value type). Is there a way to convert this to a lat/long form?
... View more
06-21-2021
12:31 PM
|
0
|
1
|
1193
|
POST
|
Hello, I have followed the tutorials that first display a map and then the second to display a point, polyline and polygraph. When they create a point they use the spatial reference of SpatialReferences.Wgs84. I read that the maps have a default of webMercator. So if I change the spatial references to webMercator, then every time I run the program my startup view point go to just off the coats of Africa. I have tried changing those starting coordinates and no matter what i use the starting center viewpoint never changes. I know why i would get a different location using a different spatial reference, but i don't understand why the location does not change at all when the coordinates change.
... View more
06-21-2021
10:13 AM
|
0
|
3
|
1241
|
POST
|
@JaredCaccamo That makes sense with it going out of scope and will be an easy fix.
... View more
06-14-2021
09:40 AM
|
0
|
0
|
1250
|
POST
|
@JaredCaccamo I appreciate it. I have tried to do the same thing I just did with the Point graphic, but with the Polyline and it is not displaying. I have made sure the spatial reference was correct too. void Display_a_map::mapClickHandler(QMouseEvent &event)
{
Point clickedPoint = m_mapView->screenToLocation(event.x(), event.y());
GraphicsOverlay* overlay = new GraphicsOverlay(this);
if(event.button() == Qt::LeftButton)
{
createPoint(overlay, clickedPoint.x(), clickedPoint.y());
}
else if( event.button() == Qt::RightButton)
{
createPolyline(overlay, clickedPoint.x(), clickedPoint.y());
}
m_mapView->graphicsOverlays()->append(overlay);
}
void Display_a_map::createPolyline(GraphicsOverlay* overlay, double pointX, double pointY)
{
const Point clickedPoint(pointX, pointY);
PolylineBuilder* polyline_builder = new PolylineBuilder(SpatialReference::webMercator());
polyline_builder->addPoint(clickedPoint);
// Create a symbol for the line
SimpleLineSymbol* line_symbol = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor(Qt::blue), 10, this);
// Create a graphic to display the line with its symbology
Graphic* polyline_graphic = new Graphic(polyline_builder->toPolyline(), line_symbol, this);
// Add line graphic to the graphics overlay
overlay->graphics()->append(polyline_graphic);
}
... View more
06-10-2021
03:06 PM
|
0
|
2
|
1303
|
POST
|
Yeah that worked thanks. Out of curiosity then, why in those tutorials do the use a spatial refence of WGS84?
... View more
06-10-2021
12:41 PM
|
0
|
4
|
1312
|
POST
|
I have been following the the two very beginning tutorials, the first being display a map and the second being add a point, line and polyline. I tweaked just a little so that rather than hard coding the points in from the start I allow for a mouse click which would add a new graphic point at that location. I have the mouse event and the location recognized and have created a graphic symbol (a point) at that location. What I'm stuck on is now having that point display on the map. I'm not quite sure what notifier I need to use so that the map can know there was a change and then display that change. display_a_map.cpp
void Display_a_map::mapClickHandler(QMouseEvent &event)
{
Point clickedPoint = m_mapView->screenToLocation(event.x(), event.y());
GraphicsOverlay* overlay = new GraphicsOverlay(this);
createGraphics(overlay, clickedPoint.x(), clickedPoint.y());
m_mapView->graphicsOverlays()->append(overlay);
//Point graphic created. Now needs to be displayed
}
void Display_a_map::createGraphics(GraphicsOverlay *overlay)
{
const Point dume_beach(-118.80657463861, 34.0005930608889, SpatialReference::wgs84());
//const Point dume_beach(pointX, pointY, SpatialReference::wgs84());
// Create symbols for the point
SimpleLineSymbol* point_outline = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor(Qt::blue), 3, this);
SimpleMarkerSymbol* point_symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Circle, QColor(Qt::blue), 10, this);
point_symbol->setOutline(point_outline);
// Create a graphic to display the point with its symbology
Graphic* point_graphic = new Graphic(dume_beach, point_symbol, this);
// Add point graphic to the graphics overlay
overlay->graphics()->append(point_graphic);
}
... View more
06-10-2021
11:06 AM
|
0
|
6
|
1334
|
POST
|
I'm developing in Qt with C++. I have displayed a map and want to be able to register when the mouse clicks on a location on the map. in my class .cpp file I have tried including the mouseClicked(QMouseEvent *event), but this is never called when I click. Display_a_map.cpp
void Display_a_map::mouseClicked(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
qDebug() << "testing";
}
}
... View more
06-09-2021
03:40 PM
|
0
|
2
|
1169
|
POST
|
Wow. Yeah... I was definitely a little confused, but it makes a lot more sense now! I appreciate your time and help with all of this!
... View more
07-22-2020
03:01 PM
|
1
|
0
|
967
|
Title | Kudos | Posted |
---|---|---|
1 | 07-22-2020 03:01 PM | |
1 | 07-13-2020 10:11 AM |