I'm working on JavaFX desktop application and using the ArcGIS SDK v100.7.0. There is a scenario in my code, where i need to create a Polyline from a Geometry object. I'm getting this geometry from the SketchEditor using sketchEditor.getGeometry(). I actually want to add a Point to the sketchEditor geometry when in Polyline creation mode using the point Lat Long inserted by the user and not by mouse click on map. How do i get the sketch geometry into a PointCollecion, add my new Point into the collection, create Polygon from this collection and then pass this polygon back to the sketchEditor.start() method. How do i achieve this?
I solved my problem after going through the classes and documentation, i figured out how i can get a Polyline from a Geometry object. The approach was:
PointCollection pc = new PointCollection(SpatialReferences.getWgs84());
PolylineBuilder pb = new PolylineBuilder(pc, SpatialReferences.getWgs84());
pb.replaceGeometry(sketchEditor.getGeometry());
pb.addPoint(new Point(Double.parseDouble(longField.getText()),Double.parseDouble(latField.getText()), SpatialReferences.getWgs84()));
sketchEditor.start(pb.toGeometry(), SketchCreationMode.POLYLINE);
I created a new PointCollection object, passed it into a new PolylineBuilder object. To pass the given Geometry into the PointBuilder, i used its replaceGeometry() method so that it can have the updated geometry. Now i was able to manipulate it and add Point to it, which is what i was trying to do.
Related
I would like to add 3D object in Windows 10 UWP map control.
This object would be "polygon with height", e.g. simple representation of a house - cuboid or cube.
Illustration image:
I know that I can add Xaml control (and inside it 3D object e.g. Cube) but then this Cube is not 'map object', only pinned to a certain Lat/Lon.
Any idea how to implement this?
Microsoft has added MapElement3D in Windows 10 Insider Preview v10.0.16257.0. - that's the falls creators update. It allows you to add objects, turn them, control their size, and direction. You can make them move too!
Example
How-To
Represents a 3D element displayed on a MapControl.
It's usage appears to be very similar to other MapElements, such as MapIcons and MapBillboards.
map3dSphereStreamReference = RandomAccessStreamReference.CreateFromUri
(new Uri("ms-appx:///Assets/trainengine.3mf"));
var myModel = await MapModel3D.CreateFrom3MFAsync(map3dSphereStreamReference,
MapModel3DShadingOption.Smooth);
var my3DElement = new MapElement3D();
my3DElement.Location = myMap.Center;
my3DElement.Model = myModel;
myMap.MapElements.Add(my3DElement);
Beware of two undocumented issues:
Attempting to add the same 3DMapElement to two different MapControls will result in System.AccessViolationException. This can happen if you cached the 3D model but not the page with the map control.
HResult=-2147467261 Message=Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
Attempting to call MapModel3D.CreateFrom3MFAsync() from a non-Ui thread will cause a crash. This must be called from a UI thread.
When using the "draw polygon" tool from DrawManager, where is the polygon stored once the drawing is completed and it is displayed on the map?
For example, how can I delete this just drawn polygon from the map without creating my own overlay layer and inserting such polygon?
The objects created by the DrawingManager aren't stored somewhere where you may access them.
The only way to access them is the {overlay}complete-event of the DrawingManager.
e.g. for a polygon:
google.maps.event.addListener(drawingManager, 'polygoncomplete', function(event) {
//event.overlay
//is a reference to the polygon,
//store it somewhere
});
I need to pan and zoom map using map.fitBounds() with a bounds object of a GeoJSON multipolygon without first adding it to the map.
I can determine a mapped feature's bounds by using map.data.addGeoson() to add geoJSON multipolygon to map, then grabbing feature w/ map.data.getFeatureById() and using processPoints() from this example https://developers.google.com/maps/documentation/javascript/examples/layer-data-dragndrop.
But, like I said, I want to pan and zoom to the multipolygon without first mapping it. I'm trying to frame markers contained within the multipolygon to provide user with more context without immediately pan/zoom to the marker bounds, which could be to a zoom level that does not provide a user enough context. See http://brookfieldlogisticsproperties.com/available-properties. Compare using select filters to drill into state of Utah vs. drilling through the map.
One approach would be to iterate over a GeoJSON MultiPolygon coordinates with the constructors for google.maps.Data.MultiPolygon, google.maps.Data.Polygon, etc. This seems rather unpleasant.
A Data-layer must not be drawn on a map.
map.data is a built-in Data-layer that will be drawn on a map, to create a Data-Layer without drawing anything simply use
new google.maps.Data()
So the workflow would be:
var
//create a map
map = new google.maps.Map(someNode,options),
//create bounds
bounds = new google.maps.LatLngBounds(),
//create data-layer
data = new google.maps.Data();
//add geoJson to the data-layer
data.addGeoJson(yourGeoJson);
//process the points via the linked function
processPoints(data.getFeatureById('idOfTheFeature').getGeometry(),
bounds.extend,
bounds);
//set the bounds of the map
map.fitBounds(bounds);
I want to be able to show movement in a google maps just like in this example
http://www.labnol.org/internet/live-flight-tracking-google-maps/12308/
I am starting, and followed an example to load markers from mysql and put them in a map. But this is all static. If I keep track of a moving object in my database, how can I display them in real time?
Thank you
Assuming marker is your Marker instance, you should use some Ajax call to get new coordinates, depending how you return them, lets say your script will return an Object of lat and long and assign it to variable new_location. Now you need to change marker position to new coordinates:
function change_pos(new_location) {
var LatLong = new google.maps.LatLng(new_location.lat, new_location.long);
marker.setPosition(LatLong);
}
Just call this function everytime you got replay from Ajax.
And thats it.
I have a Shapefile map of Maryland separated by zipcode. What I'd like to do is color each area based on a value I'm looking up in a database. Currently, I'm using ASP.NET with the SharpMap package. The basic questions are:
1) How do I associate a shape with its zipcode? I can generate the list of zipcodes using SharpMap's ExecuteIntersectionQuery with the BoundingBox set as the extent of the map, but I have no idea how to then connect each row of the resulting table with the shape it represents.
2) Once I have access to an individual shape and know what color I want, how do I assign the color to the shape? In SharpMap, I can color a VectorLayer, but a VectorLayer is generated from a source .shp file, not a shape.
I'm open to using other free map packages besides SharpMap (so no ArcGIS), but for legal reasons I can't use GoogleMaps.
I feel like this should be relatively simple, but trying to find any decent resource for SharpMap is pretty difficult.
EDIT: Alright, I've made a lot of process just by reading over what documentation there is. By setting the FilterDelegate of ShapeFile, I can make a layer consist of only the rows where the zip code matches a certain value. Now my only problem is making the delegate filter look for a different zip code each time. Can I pass another parameter besides the FeatureDataRow? Should I resort to a global variable?
You'll need to use thematics to do this.
I'll assume you already have some code that configures your map and it's layers. Your shapefile is a VectorLayer.
VectorLayer shapefileLayer = GetMyShapefileLayer();
shapefileLayer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(GetStyleForShape);
Then, method GetStyleForShape is called every time the map needs a style for rendering. It looks like this:-
private SharpMap.Styles.VectorStyle GetStyleForShape(SharpMap.Data.FeatureDataRow row, SharpMap.Layers.Layer layer)
{
}
In the method, you create and return a VectorStyle. The table data associated with the feature it's trying to render is passed as a parameter to this method.
So you can use the row parameter to get your zip code, do whatever logic you need to do to calculate it's style, configure that style and return it.
This method (potentially) gets called a lot, so consider storing the styles and reusing them, rather than recreating them every time.
Hope this helps.