Quantcast
Channel: GMap.NET - Great Maps for Windows Forms & Presentation
Viewing all 3384 articles
Browse latest View live

New Post: Convert zipcodes to lat/lon?

$
0
0
Does GMap.Net have any built-in functionality for converting a zipcode to it's latitude & longitude cooridinates? I have a database of customers & I want to show their locations with markers, but we only store the customers adress. Any ideas on how to acheive? Thanks.

New Post: Marker BringToFront or SendToBack (zorder)

$
0
0
Is there a way to change a marker's zorder / SendToBack or BringToFront?

Thanks

New Post: Overlapping markers

$
0
0
Is there a way to prevent marker tooltips from displaying on top of each other for markers at the same location? I believe Googlemaps call it "declutter". Thanks...

New Post: Overlapping markers

$
0
0
I've been having this problem for a couple of years now. I've been hoping somebody better at coding than me would solve the problem. Here's my feeble attempt. It makes things a little better but doesn't fully solve the problem. If you implement it, you'll notice there are some bugs in it. I'm all ears if someone has a better solution. There's another post that may solve the problem better but I wasn't able to make heads or tales of how to incorporate it. Basically the routine puts all coordinates into a temp Table and loops thru the table moving the label offsets if there is a collision in rectangles. It works for a few hundred labels fast enough. Haven't tried with more points.


'Add tmep table for tooltip coordinates
            ds.Tables.Add("MapCoords")
            ds.Tables("MapCoords").Columns.Add("OffSetX")
            ds.Tables("MapCoords").Columns.Add("OffSetY")
            ds.Tables("MapCoords").Columns.Add("PointX")
            ds.Tables("MapCoords").Columns.Add("PointY")
            ds.Tables("MapCoords").Columns.Add("Top")
            ds.Tables("MapCoords").Columns.Add("Bottom")
            ds.Tables("MapCoords").Columns.Add("Left")
            ds.Tables("MapCoords").Columns.Add("Right")
'*********************************************
                    Dim Outside As Boolean = False
                    Dim X, X1, Y, Y1, A, B, A1, B1, i, OffsetY, OffSetX As Integer

                    A = overlayActive.Markers.Item(point).LocalArea.Left
                    B = overlayActive.Markers.Item(point).LocalArea.Right
                    A1 = overlayActive.Markers.Item(point).LocalArea.Bottom
                    B1 = overlayActive.Markers.Item(point).LocalArea.Top
                    Y = -34
'get current offsets
                    OffsetY = overlayActive.Markers.Item(point).ToolTip.Offset.Y
                    OffSetX = overlayActive.Markers.Item(point).ToolTip.Offset.X
                  
'Keep looping thru temp table until label/tooltip doesn't collide with anything
                    Do Until (Outside = True) Or (ds.Tables("MapCoords").Rows.Count = 0)
                        Outside = True
                        For i = 0 To ds.Tables("MapCoords").Rows.Count - 1
'Test if rectangles collide on any side
                            If (ds.Tables("MapCoords").Rows(i).Item("right") < A Or B < ds.Tables("MapCoords").Rows(i).Item("Left") Or A1 < ds.Tables("MapCoords").Rows(i).Item("Top") Or ds.Tables("MapCoords").Rows(i).Item("Bottom") < B1) Then

'If not, do nothing
                                Debug.Print("NO intersection")
                            Else
                                'intersection of rectangles so adjust position of offset
                                OffsetY = OffsetY + 10
                                '  OffSetX = OffSetX - 10
                                ' A = A - 10
                                ' B = B - 10
                                A1 = A1 - 10
                                B1 = B1 - 10

                                Outside = False
                            End If

                        Next

                    Loop
                    overlayActive.Markers.Item(point).ToolTip.Offset.Y = OffsetY
                    overlayActive.Markers.Item(point).ToolTip.Offset.Y = OffSetX


                    Dim NR As DataRow = ds.Tables("MapCoords").NewRow
                    ds.Tables("MapCoords").Rows.Add(overlayActive.Markers.Item(point).Offset.X.ToString, overlayActive.Markers.Item(point).Offset.Y.ToString, overlayActive.Markers.Item(point).ToolTipPosition.X.ToString, overlayActive.Markers.Item(point).ToolTipPosition.Y.ToString, overlayActive.Markers.Item(point).LocalArea.Top.ToString, overlayActive.Markers.Item(point).LocalArea.Bottom.ToString, overlayActive.Markers.Item(point).LocalArea.Left.ToString, overlayActive.Markers.Item(point).LocalArea.Right.ToString)
                    '******************************************************

New Post: Shapefile Usage in GMAPS

$
0
0
really i need this any idea to implement in c#

New Post: Radioman please add ALK Maps as a Map Provider

$
0
0
http://alkmaps.com/

ALK Maps are very clean and most useful for road maps I have found.

Not a lot of topography or colors. Makes it very easy to see markers and routes.

Thank you.

Image

New Post: Google Style Clustered Tooltips

$
0
0
mike_mankus wrote:
For anyone interested, this is how I solved the problem: private List<GMapMarker> mouseOveredMarkers = new List<GMapMarker>(); private void MainMap_OnMarkerEnter(GMapMarker item) { mouseOveredMarkers.Add(item); } private void MainMap_OnMarkerLeave(GMapMarker item) { mouseOveredMarkers.Remove(item); } void MainMap_OnMarkerClick(GMapMarker item, MouseEventArgs e) { if (mouseOveredMarkers.Contains(item)) { if (mouseOveredMarkers.Count >= 1) { ToolTipContents ttc = new ToolTipContents(mouseOveredMarkers); PoperContainer ttcContainer = new PoperContainer(ttc); GMap.NET.GPoint p = MainMap.FromLatLngToLocal(item.Position); p.Offset(0, (-1 * ttc.Height) - 34); ttcContainer.Show(this, new System.Drawing.Point(p.X, p.Y)); } } } So I have my tooltips setup to show on the OnMarkerClick event.  I utilized the SuperContextMenu control from CodeProject to serve as the tooltip rather than creating my own inherited tooltip.  I used SuperContextMenu because it allows you to setup a your own custom control which will act as a context menu.  For my purposes, a context menu worked great because when the use clicks on the marker, the context menu appears and will not dissapear until the user clicks elsewhere.  So my ToolTipContents control takes the list of markers that have been clicked on and then displays the information as I want it (like a tooltip).  I also have controls in it to move to the next or previous marker in the list. The SuperContextMenu can be found here:  http://www.codeproject.com/KB/menus/SuperContextMenu.aspx 
Thank you mike_mankus.

I simplified the "on marker click" part with a simple loop and a messagebox which fills my needs.

Notice I started the loop at 1 to skip the top most tooltip.
if (mouseOveredMarkers.Count > 1)
{
     for (int i = 1; i < mouseOveredMarkers.Count; ++i)
     {
          GMapMarker tt = mouseOveredMarkers[i];
          MessageBox.Show(tt.ToolTipText , " Hidden Text");
     }
}

New Post: How to load the program faster using small cashed file

$
0
0
Hi, is there any way to download gmdb data automatically for particular city by latitude and longitude.am really struct here. can you any one help me on this.Thanks in advance.

Commented Unassigned: GMAP.Net Google Satellite map error in C#? [16137]

$
0
0
Tried to use GMAP.NET in winform using C#, when I set map properties to GoogleSatelliteMapProvider it gives an error. Exception :The remote Server returned in error:(404) Not found.

I am using latest GMAP.Net version. 1.7.0.0
Comments: Hello, I notice this behaviour with the google satellite map too. Thought i had a problem/bug in my application, but it is also not working in the demo (Demo.WindowsPresentation.exe). Btw: no problem with the bing satellite map! greetz, ahold

Commented Unassigned: GMAP.Net Google Satellite map error in C#? [16137]

$
0
0
Tried to use GMAP.NET in winform using C#, when I set map properties to GoogleSatelliteMapProvider it gives an error. Exception :The remote Server returned in error:(404) Not found.

I am using latest GMAP.Net version. 1.7.0.0
Comments: I also tried the Demo.WindowsForms and it is working. Demo.WindowsPresentation still not wokring.

New Post: How to Automate Map download by Latitude and Longitude

$
0
0
Hi Everyone,
   Am trying to Automate the Map data download by giving latitude and Longitude values or by giving city name. is there any existing possible way to download the map data automatically for specific city or state.kindly help me over this.thanks in advance.

New Post: How to load the program faster using small cashed file

$
0
0
Hi,
 Congrats for your great effort.Am having little doubt about , is there any way to download gmdb data automatically for particular city by latitude and longitude.am really struct here. can you any one help me on this.Thanks in advance.

New Post: How to Automate Map download by Latitude and Longitude

New Post: Polygon with inner polygons

$
0
0
Oh, sorry, you have to change something more in GMapPolygon.cs:

Change

internal void UpdateGraphicsPath()
  {
...
}
to

public virtual void UpdateGraphicsPath()
  {
...
}

and

GraphicsPath graphicsPath;

to

protected GraphicsPath graphicsPath;


Then remove

private GraphicsPath graphicsPath = new GraphicsPath();

from the class GMapPolygonHole.cs

Then it should work!

New Post: Polygon with inner polygons

$
0
0
Updated it now butt still only main polly shows. :(

My version of youre class looks like this now:
using GMap.NET;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test1
{
    public class GMapPolygonHole : GMap.NET.WindowsForms.GMapPolygon
    {
        protected GraphicsPath graphicsPath;
        /// <summary>
        /// How many holes does the Polygon have
        /// </summary>
        public int NumberOfHoles
        {
            get
            {
                return LstPointHoles.Count;
            }
        }

        /// <summary>
        /// The Minimum latitude
        /// </summary>
        public double MinLat { get; private set; }

        /// <summary>
        /// The Maximum latitude
        /// </summary>
        public double MaxLat { get; private set; }

        /// <summary>
        /// The Minimum longitude
        /// </summary>
        public double MinLng { get; private set; }

        /// <summary>
        /// The Maximum longitude
        /// </summary>
        public double MaxLng { get; private set; }

        /// <summary>
        /// The List with the coordinates of all the Holes
        /// </summary>
        public List<List<PointLatLng>> LstPointHoles = new List<List<PointLatLng>>();


        /// <summary>
        /// The List with the local coordinates of all the Holes
        /// </summary>
        public List<List<GPoint>> LstPointsLocalHoles = new List<List<GPoint>>();


        /// <summary>
        /// Constructor
        /// </summary>
        public GMapPolygonHole(List<GMap.NET.PointLatLng> outerPoints, string name)
            : base(outerPoints, name)
        {
            CalcBoundingBox();
        }

        /// <summary>
        /// Calculate the Min and Max X and y (lat/Long) values
        /// </summary>
        public void CalcBoundingBox()
        {
            if (this.Points.Count == 0)
            {
                return;
            }
            MinLat = this.Points.Min(x => x.Lat);
            MaxLat = this.Points.Max(x => x.Lat);

            MinLng = this.Points.Min(x => x.Lng);
            MaxLng = this.Points.Max(x => x.Lng);
        }


        /// <summary>
        /// Set the Color for the polygon and its Border
        /// </summary>
        /// <param name="col"></param>
        public void SetPolygonColor(Color colFill, Color colBorder)
        {
            this.Stroke.Color = colBorder;
            ((SolidBrush)this.Fill).Color = colFill;
        }

        /// <summary>
        /// Update the Graphics path
        /// </summary>
        public virtual void UpdateGraphicsPath()
        {

            if (graphicsPath == null)
            {
                graphicsPath = new GraphicsPath();
            }
            else
            {
                graphicsPath.Reset();
            }
            //Add Main Polygon first:
            Point[] pnts = new Point[LocalPoints.Count];
            for (int i = 0; i < LocalPoints.Count; i++)
            {
                Point p2 = new Point((int)LocalPoints[i].X, (int)LocalPoints[i].Y);
                pnts[pnts.Length - 1 - i] = p2;
            }

            if (pnts.Length > 2)
            {
                graphicsPath.AddPolygon(pnts);

                //Add All Holes:
                foreach (var holeLocalPoints in LstPointsLocalHoles)
                {
                    pnts = new Point[holeLocalPoints.Count];
                    for (int i = 0; i < holeLocalPoints.Count; i++)
                    {
                        Point p2 = new Point((int)holeLocalPoints[i].X, (int)holeLocalPoints[i].Y);
                        pnts[pnts.Length - 1 - i] = p2;
                    }
                    if (pnts.Length > 2)
                    {
                        graphicsPath.AddPolygon(pnts);
                    }
                }
            }
            else if (pnts.Length > 0)
            {
                graphicsPath.AddLines(pnts);
            }
        }




        /// <summary>
        /// Add a hole 
        /// </summary>
        /// <param name="holePoly"></param>
        public void AddNormalHole(GMap.NET.WindowsForms.GMapPolygon holePoly)
        {
            this.LstPointHoles.Add(holePoly.Points);
        }


        /// <summary>
        /// Add a hole 
        /// </summary>
        /// <param name="holePoly"></param>
        public void AddNormalHole(List<PointLatLng> points)
        {
            this.LstPointHoles.Add(points);
        }


        /// <summary>
        /// Returns true if the point is Inside of the Polygon, also considers Holes!
        /// </summary>
        /// <param name="p">Point to check</param>
        /// <returns>True if Point is inside, false otherwise</returns>
        public bool IsPointInsidePolygon(PointLatLng p, bool borderIsPartOfPolygon)
        {
            //Border belongs to Polygon!
            if (borderIsPartOfPolygon && Points.Contains(p))
            {
                return true;
            }

            //Check if point is within the Bounding Box
            if (p.Lng < MinLng || p.Lng > MaxLng || p.Lat < MinLat || p.Lng > MaxLat)
            {
                // Definitely not within the polygon!
                return false;
            }

            //Ray-cast algorithm is here onward
            int k, j = Points.Count - 1;
            bool oddNodes = false; //to check whether number of intersections is odd
            for (k = 0; k < Points.Count; k++)
            {
                //fetch adjacent points of the polygon
                PointLatLng polyK = Points[k];
                PointLatLng polyJ = Points[j];

                //check the intersections
                if (polyJ.Lat < p.Lat && polyK.Lat >= p.Lat || polyK.Lat < p.Lat && polyJ.Lat >= p.Lat)
                {
                    if (polyJ.Lng + (p.Lat - polyJ.Lat) / (polyK.Lat - polyJ.Lat) * (polyK.Lng - polyJ.Lng) < p.Lng)
                    {
                        oddNodes = !oddNodes;
                    }
                }

                j = k;
            }

            //Now Test all Holes:
            foreach (var hole in this.LstPointHoles)
            {
                j = hole.Count - 1;
                for (k = 0; k < hole.Count; k++)
                {
                    //fetch adjacent points of the polygon
                    PointLatLng polyK = hole[k];
                    PointLatLng polyJ = hole[j];

                    //check the intersections
                    if (polyJ.Lat < p.Lat && polyK.Lat >= p.Lat || polyK.Lat < p.Lat && polyJ.Lat >= p.Lat)
                    {
                        if (polyJ.Lng + (p.Lat - polyJ.Lat) / (polyK.Lat - polyJ.Lat) * (polyK.Lng - polyJ.Lng) < p.Lng)
                        {
                            oddNodes = !oddNodes;
                        }
                    }
                    j = k;
                }
            }

            return oddNodes;
        }
    }
}


New Post: Polygon with inner polygons

$
0
0
I realized, that I made a LOT of changes to the original source-code...

1) Remove "protected GraphicsPath graphicsPath;" from GMapPolygonHole
2) In GMapControl replace UpdatePolygonLocalPosition
with this code:
public void UpdatePolygonLocalPosition(GMapPolygon poly)
        {
            if (poly is GMapPolygonHole)
            {           

                GMapPolygonHole polyHole = (GMapPolygonHole)poly;
                //Clear ALL Points (including Holes)!
                polyHole.LocalPoints.Clear();

            foreach (GMap.NET.PointLatLng pg in polyHole.Points)
            {
            GPoint p = FromLatLngToLocal(pg);
            p.OffsetNegative(Core.renderOffset);
            polyHole.LocalPoints.Add(p);
            }

                polyHole.LstPointsLocalHoles.Clear();

                foreach (var holePoints in polyHole.LstPointHoles)
                {
            foreach (GMap.NET.PointLatLng pg in holePoints)
            {
                GPoint p = FromLatLngToLocal(pg);
                p.OffsetNegative(Core.renderOffset);
                localPoints.Add(p);
            }

                    polyHole.LstPointsLocalHoles.Add(localPoints);
                }

                polyHole.UpdateGraphicsPath();
            }
            else
            {
                polygon.LocalPoints.Clear();
        
                  for (int i = 0; i < polygon.Points.Count; i++)
                  {
                        GPoint p = FromLatLngToLocal(polygon.Points[i]);
        #if !PocketPC
                        if (!MobileMode)
                        {
                            p.OffsetNegative(Core.renderOffset);
                        }
        #endif
                        polygon.LocalPoints.Add(p);
                    }
        #if !PocketPC
                    polygon.UpdateGraphicsPath();
        #endif
            }
        }
I hope it works...

New Post: Polygon with inner polygons

$
0
0
Thanks and sorry for all the work I am crating for you!

I do not know if this was correct way but I crated MyGMapConstrol that extends GMapControle and then created an override function called UpdatePolygonLocalPosition.
When I did this I get some unknown variables in the UpdatePolygonLocalPosition:
Core.renderOffset
localPoints
polygon

New Post: Polygon with inner polygons

$
0
0
Hi again

I downloaded GMap source code and change the GMapControl as above and added GMapPolygonHole to it. It was missing localPoints in GMapControl ->UpdatePolygonLocalPosition so I added a list of GPoints like this:
                List<GPoint> localPoints = new List<GPoint>();

                foreach (var holePoints in polyHole.LstPointHoles)
                {

                    

                    foreach (GMap.NET.PointLatLng pg in holePoints)
                    {
                        GPoint p = FromLatLngToLocal(pg);
                        p.OffsetNegative(Core.renderOffset);
                        localPoints.Add(p);
                    }

                    polyHole.LstPointsLocalHoles.Add(localPoints);
                }
But no luck the main ploy is only shown. :(

New Post: Polygon with inner polygons

$
0
0
Many thanks Xandolph for all the information got it to work now!

New Post: Polygon with inner polygons

$
0
0
Cool, sorry that I didn't have the time to reply anymore...
You can do some pretty neat stuff with those holes in the polygons:

Image
Viewing all 3384 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>