Zoom Error?

Jul 31, 2009 at 5:48 PM

I have this problem when I used the control.

The zoom value keep on changing back to 0 even though I had changed the zoom value to 10

Screenshot below..

[IMG]http://i28.tinypic.com/30vhoo9.png[/IMG]

When I deploy my application the map was not zoomed in..

So I try to zoom into the map by code when the form loads

  Private Sub frmGMap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim g1 As GMap.NET.PointLatLng = New PointLatLng(1.3044493872729939, 103.83293509483337)
MainMap.CurrentPosition = g1


MainMap.Zoom = 10
MainMap.MapType = MapType.GoogleMap

MainMap.ReloadMap()
End Sub

Screenshot below

[IMG]http://i32.tinypic.com/atu3oz.png[/IMG]

Is there any wrong with my code?

How come I see a non zoom in version even though I changed the zoom value?

The strange thing was I did a breakpoint, I found out that the zoom value return to 0

Screenshot as below..

[IMG]http://i29.tinypic.com/2ajnbyc.png[/IMG]

Can anyone help me? :)

  

Coordinator
Jul 31, 2009 at 6:16 PM

  MainMap.MapType = MapType.ArcGIS_MapsLT_Map;
  MainMap.MaxZoom = 12;
  MainMap.MinZoom = 3;

  MainMap.Zoom = MainMap.MinZoom;
  MainMap.CurrentPosition = new PointLatLng(54.6961334816182, 25.2985095977783);

These are important ones ;}

Coordinator
Jul 31, 2009 at 6:17 PM

p.s. do not use MainMap.ReloadMap() ;} it's quite unneeeded

Aug 1, 2009 at 3:49 AM

OMG Dude..

It worked! Thanks alot..

 

Coordinator
Aug 1, 2009 at 12:05 PM

;}

Aug 1, 2009 at 12:20 PM

Sorry to trouble you again..

How do I like draw a route between 2 points?

Example : A route from g1 to g2

Dim g1 As GMap.NET.PointLatLng = New PointLatLng(txtLat.Text, txtLong.Text)

Dim g2 As GMap.NET.PointLatLng = New PointLatLng(txtLat1.Text, txtLong1.Text)

I tried using GMaps.Instance.GetRouteBetweenPoints(g1, g2, True, 5) and nothing happen?

Can you show me how to do it?

I take a look at your demos in the trunk..

However they are in c# and I have no experience with them.
I am familiar with VB.Net. Do you have any VB.Net examples?

Coordinator
Aug 1, 2009 at 12:24 PM

// add test route
      private void button3_Click(object sender, EventArgs e)
      {
         MapRoute route = GMaps.Instance.GetRouteBetweenPoints(start, end, false, MainMap.Zoom);
if(route != null)
         {
// add route
            GMapRoute r = new GMapRoute(route.Points, route.Name);
            r.Color = Color.Blue;
            routes.Routes.Add(r);
// add route start/end marks
            GMapMarker m1 = new GMapMarkerGoogleRed(start);
            m1.ToolTipText = "Start: " + route.Name;
            m1.TooltipMode = MarkerTooltipMode.Always;

            GMapMarker m2 = new GMapMarkerGoogleGreen(end);
            m2.ToolTipText = "End: " + end.ToString();
            m2.TooltipMode = MarkerTooltipMode.Always;

            objects.Markers.Add(m1);
            objects.Markers.Add(m2);

            MainMap.ZoomAndCenterRoute(r);
// testing kml support
            KmlType info = GMaps.Instance.GetRouteBetweenPointsKml(start, end, false);
if(info != null)
            {

            }
         }
      }

Coordinator
Aug 1, 2009 at 12:26 PM

p.s.

GMapOverlay routes = new GMapOverlay(MainMap, "routes");
MainMap.Overlays.Add(routes);

Aug 1, 2009 at 12:52 PM
Edited Aug 1, 2009 at 12:53 PM
radioman wrote:

 

// add test route
      private void button3_Click(object sender, EventArgs e)
{
MapRoute route = GMaps.Instance.GetRouteBetweenPoints(start, end, false, MainMap.Zoom);
if(route != null)
{
// add route GMapRoute r = new GMapRoute(route.Points, route.Name);
r.Color = Color.Blue;
routes.Routes.Add(r);

 

Let start with one by one
Your code is in C# so I converted them to VB.Net

In the button click event

Dim g1 As GMap.NET.PointLatLng = New PointLatLng(txtLat.Text, txtLong.Text)
        MainMap.CurrentPosition = g1
        Dim g2 As GMap.NET.PointLatLng = New PointLatLng(txtLat1.Text, txtLong1.Text)
        'Dim route As MapRoute
        Dim route As MapRoute
        Dim r As GMapRoute
        Dim routes As GMapOverlay
        route = GMaps.Instance.GetRouteBetweenPoints(g1, g2, False, MainMap.Zoom)

        r = New GMapRoute(route.Points, route.Name)
        r.Color = Color.Blue
        routes = New GMapOverlay(MainMap, "routes")
        MainMap.Overlays.Add(routes)

Is there anything wrong with the codes?
I click on the button and nothing happen?
Coordinator
Aug 1, 2009 at 12:58 PM

add to form load event or constructor:

GMapOverlay routes = New GMapOverlay(MainMap, "routes")
MainMap.Overlays.Add(routes)
-----

and in button event you miss:  routes.Routes.Add(r);

Aug 1, 2009 at 1:10 PM
radioman wrote:

 

 
// add route start/end marks
GMapMarker m1 = new GMapMarkerGoogleRed(start);
m1.ToolTipText = "Start: " + route.Name;
m1.TooltipMode = MarkerTooltipMode.Always;

GMapMarker m2 = new GMapMarkerGoogleGreen(end);
m2.ToolTipText = "End: " + end.ToString();
m2.TooltipMode = MarkerTooltipMode.Always;

objects.Markers.Add(m1);
objects.Markers.Add(m2);

MainMap.ZoomAndCenterRoute(r);
 

 

        Ok. Thanks alot. I managed to get the route part working..

Now for the marker part..

I converted your code to VB.Net

Dim m1 As GMapMarkerGoogleRed
        Dim m2 As GMapMarkerGoogleGreen

        m1.ToolTipText = "Start: " + route.Name
        m1.TooltipMode = MarkerTooltipMode.Always

        m2.ToolTipText = "End: " + g2.ToString()
        m2.TooltipMode = MarkerTooltipMode.Always


        objects.Markers.Add(m1)
        objects.Markers.Add(m2)

        MainMap.ZoomAndCenterRoute(r)

 

I got this error which is objects is not declare..

How should I declare the objects?

Coordinator
Aug 1, 2009 at 1:30 PM

the same as route layer,

GMapOverlay objects = new GMapOverlay(MainMap, "objects");
MainMap.Overlays.Add(objects);

Aug 1, 2009 at 1:42 PM
radioman wrote:

 

             KmlType info = GMaps.Instance.GetRouteBetweenPointsKml(start, end, false);
 

 

OMG.. Dude thanks it worked..

I have 1 question

m1.ToolTipText = "Start: " + route.Name

what does the route.Name contains?

The following display at the starting marker

Start: (5.1/x26#160;km/9mins)

What does the bold part means?

Mind explaining it to me?

For the last part on the directions..

I converted ur code to VB.Net and I got this

Dim info As KmlType
        info = GMaps.Instance.GetRouteBetweenPointsKml(g1, g2, False)

This get route between points kml is to show the directions right?

Is it suppose to be something like that right?

Turn left at A

Drive 2km ahead

Turn right at B

....

How do i display the information out?

 

Coordinator
Aug 1, 2009 at 1:51 PM

GetRouteBetweenPointsKml does not work ;}

Aug 1, 2009 at 1:53 PM
radioman wrote:

GetRouteBetweenPointsKml does not work ;}

Oh..

It has not been implemented?

So there is no way for me to display the driving directions out yet?

Coordinator
Aug 1, 2009 at 1:56 PM

as you see it is implemented, but deserialisation just don't work ;} any ideas?

Aug 1, 2009 at 2:00 PM
radioman wrote:

as you see it is implemented, but deserialisation just don't work ;} any ideas?

oh..

Thanks alot for the help man.. =D

I really appreciate the help given..

Coordinator
Aug 1, 2009 at 2:05 PM

you're welcome ;}