Hi,
I can not find feature through a PointShape , My map GeographyUnit is in Meter and so convert it to Degree, For ex:
I have position ,After convert to Degree , it contains projected point (20000.9999998,20000.9999998), now it has lost some accuracy.
so,I can not find a Feature.
Controller code :
[MapActionFilter]
public string FindFeatureClick(Map map, GeoCollection args)
{
// X coordinate :args[0].ToString()
// Y coordinate :args[0].ToString()
// My map GeographyUnit is Meter so convert it to Deegree.
ManagedProj4Projection proj = new ManagedProj4Projection();
proj.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(3857);
proj.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);
proj.Open();
PointShape position = proj.ConvertToExternalProjection(new PointShape(Convert.ToDouble( args[0].ToString()), Convert.ToDouble( args[1].ToString()))) as PointShape;
LayerOverlay staticOverlay = (LayerOverlay)map.CustomOverlays[“ManageLayer”]; // through this layer i laod a .shp file .
ShapeFileFeatureLayer shapeFileLayer = (ShapeFileFeatureLayer)(staticOverlay.Layers[0]);
shapeFileLayer.Open();
Collection<Feature> selectedFeatures = shapeFileLayer.QueryTools.GetFeaturesContaining(position, new string[] { “FIELD2”, “PRIMARY_NA”, “NAME_32_DI” });
if (selectedFeatures.Count > 0)
{
//“succuess”;
}
return “”;
}
Clientside Code :
function mapClick(e) {
var infoPopup = Map1.popups[0];
infoPopup.lonlat = e.worldXY;
Map1.ajaxCallAction(’@ViewContext.RouteData.Values[“Controller”].ToString()’, ‘FindFeatureClick’, { x: e.worldXY.lon, y: e.worldXY.lat }, function (result) {
Map1.redrawLayer(“HightLightDynamicOverlay”);
infoPopup.setContentHTML(result.get_responseData());
infoPopup.show();
})
}
</script>
@{
Html.ThinkGeo().Map(“Map1”, new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), 500)
.MapBackground(new BackgroundLayer(new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"))))
.CurrentExtent(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962)
.MapUnit(GeographyUnit.Meter)
.CustomOverlays(overlays =>
{
GoogleMapsLayer googlelayer = new GoogleMapsLayer();
if (Session[“IsBaseOverlayOff”] != null && Convert.ToBoolean(Session[“IsBaseOverlayOff”]) == true)
overlays.LayerOverlay(“GoogleMap”).Layer(googlelayer).IsBaseOverlay(true).IsVisible(false);
else
overlays.LayerOverlay(“GoogleMap”).Layer(googlelayer).IsBaseOverlay(true);
OpenStreetMapLayer openstreetmap = new OpenStreetMapLayer();
overlays.LayerOverlay(“OpenStreetMap”).Layer(openstreetmap).IsBaseOverlay(true);
BingMapsLayer bingmap = new BingMapsLayer();
overlays.LayerOverlay(“BingMap”).Layer(bingmap).IsBaseOverlay(true);
WorldMapKitLayer wordmap = new WorldMapKitLayer();
wordmap.Projection = WorldMapKitProjection.SphericalMercator;
overlays.LayerOverlay(“WordMap”).Layer(wordmap).IsBaseOverlay(true);
overlays.LayerOverlay(“ManageLayer”).IsBaseOverlay(false).TileType(TileType.MultipleTile).IsVisibleInOverlaySwitcher(false);
}).OnClientClick(“mapClick”)
.Render();
please help for this issue.
Thanks,
Dinesh
Not find feature by PointShape
Hi Dinesh,
I guess using the GetFeaturesNearestTo instead of GetFeaturesContaining method in QueryTools might be useful.
If any questions, please feel free to let us know.
Thanks,
Johnny
Hi Johnny ,
I already try GetFeaturesContaining method for search , and it always returns a same point .
my code like this :
ManagedProj4Projection proj = new ManagedProj4Projection();
proj.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(3857);
proj.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);
proj.Open();
PointShape position = proj.ConvertToExternalProjection(new PointShape(Convert.ToDouble( args[0].ToString()), Convert.ToDouble( args[1].ToString()))) as PointShape;
LayerOverlay staticOverlay = (LayerOverlay)map.CustomOverlays["ManageLayer"]; // through this layer i laod a .shp file .
if (staticOverlay.Layers.Count <= 0)
return "error";
ShapeFileFeatureLayer shapeFileLayer = (ShapeFileFeatureLayer)(staticOverlay.Layers[staticOverlay.Layers.Count-1]);
shapeFileLayer.Open();
Collection<Feature> selectedFeatures = shapeFileLayer.QueryTools.GetFeaturesNearestTo(position, GeographyUnit.Meter, 1, new string[] { "FIELD2", "PRIMARY_NA", "NAME_32_DI", "LAT","LON" });
if (selectedFeatures.Count > 0)
{
//"succuess";
}
This is not work for me.
Thanks,
Dinesh
Hi Dinesh,
Would you please try to use the GeographyUnit.DecimalDegree
instead GeographyUnit.Meter in the GetFeaturesNearestTo method? As I notice
from the codes the position now is under decimal degree after the projection
and the shape file should also be under decimal degree. So I guess it might be
the reason we can’t find the feature when using this method.
Please let us know if any questions on this.
Best Regards,
Johnny
Hi Dinesh,
Would you please try to use the GeographyUnit.DecimalDegree instead GeographyUnit.Meter in the GetFeaturesNearestTo method? As I notice from the codes the position now is under decimal degree after the projection and the shape file should also be under decimal degree. So I guess it might be the reason we can’t find the feature when using this method.
Please let us know if any questions on this.
Best Regards,
Johnny
Hi Johnny,
I got a success to find a feature ,In my case i do not need to convert point , from decimal degree to meter , because when i clicked on point than it gives me point in meter.
Thanks for your support Johnny.
Thanks,
Dinesh
Dinesh,
Good to hear it was solved.
Any more questions, please feel free to let us know.
Thanks,
Johnny