locked
Google Map Polygon save in database RRS feed

  • Question

  • User-792764019 posted

    Hi,

           I am using Google Map in my application (asp.net and c#) and drawing Polygon on map, now i have to save this polygon in database.But i m not getting how can i get this polygon on my page .DB i m using sql server.

    Please can any body help me .

    Thanks

    VD

    Thursday, August 26, 2010 3:13 PM

All replies

  • User-1446685904 posted

    You need to store the latitude and longitude that you get from the polygon.  I had created such application to store the latitude and longitude and i need to produce a circle based on those values.  The below given function expalins this:


      function DrawCircle(point, center) {
                polySmallRadius = document.getElementById('ctl00_body_txtRadius').value;
                if (polySmallRadius == '' || polySmallRadius == null) {
                    alert('Please enter Radius');
                    return false;
                }
    
                if (center == 1)
                    map.setCenter(new GLatLng(point.y, point.x), polySmallRadius);
    
                var polyPoints = Array();
                var mapNormalProj = G_NORMAL_MAP.getProjection();
                var mapZoom = map.getZoom();
                var clickedPixel = mapNormalProj.fromLatLngToPixel(point, mapZoom);
    
                var polyNumSides = 10;
                var polySideLength = 360 / polyNumSides;
    
    
                polyNumSides = 20;
                polySideLength = 18;
    
                for (var a = 0; a < (polyNumSides + 1); a++) {
                    var aRad = polySideLength * a * (Math.PI / 180);
                    var polyRadius = polySmallRadius;
                    var pixelX = clickedPixel.x + polyRadius * Math.cos(aRad);
                    var pixelY = clickedPixel.y + polyRadius * Math.sin(aRad);
                    var polyPixel = new GPoint(pixelX, pixelY);
                    var polyPoint = mapNormalProj.fromPixelToLatLng(polyPixel, mapZoom);
                    polyPoints.push(polyPoint);
                }
                var polygon = new GPolygon(polyPoints, "#000000", 2, .5, "#00ff00", .5);
                map.addOverlay(polygon);
            }



    Monday, September 6, 2010 2:54 AM