c# - Use GMap.Net with Spatial Data Layers on Map MouseDrag Issue -
i developing window form application gmap asset management, populate tile containing polygon , points on map , , update tile according position of assets (lat/long) on mouse zoom or mouse drag , issue want update layer spacial data having lat/long centered screen.. how can make sure when ever mouse dragged , updated center of screen , give me tile bounds x1,y1,x2,y2 tile in center always.view image, red area on map layer generated lat/long of polygon & points, on mouse dragged update data not center screen.
this function called when ever change zoom or drag mouse..
private void updatetilesinview() { int z = (int)this.zoom;//map zoom level double x1 = fromlocaltolatlng(0, 0).lng; double y1 = fromlocaltolatlng(0, 0).lat; double x2 = fromlocaltolatlng(width, height).lng; double y2 = fromlocaltolatlng(width, height).lat; tile tx1y1 = gettilebounds(x1, y1, z); tile tx2y1 = gettilebounds(x2, y1, z); tile tx1y2 = gettilebounds(x1, y2, z); tile tx2y2 = gettilebounds(x2, y2, z); } public tile gettilebounds(double lon, double lat, int z) { tile t = new tile(); t.x = (int)(math.floor((lon + 180.0) / 360.0 * math.pow(2.0, z))); t.y = (int)(math.floor((1.0 - math.log(math.tan(lat * math.pi / 180.0) + 1.0 / math.cos(lat * math.pi / 180.0)) / math.pi) / 2.0 * math.pow(2.0, z))); t.z = z; if (t.x % 2 == 0) t.x -= 1; if (t.y % 2 == 0) t.y -= 1; t.tile2latlong(); return t; }
Comments
Post a Comment