Create marker with lanlng position

Topics: Windows Forms
Mar 25, 2011 at 11:00 PM
Edited Mar 25, 2011 at 11:00 PM

Hi

I want to create marker with lntlng in offline and Cacheonly mode but in AddLocation function (in demo), Gmaps connect to the internet then get lntlng and status.

I have lnt and lng. how do i pass lnt and lng to function and set marker on the map ?

this code doesn't work.

 

 double lat = 35.6999651086143;
            double lng = 51.3378238677979;
            PointLatLng? pos = new PointLatLng(lat, lng);
            GMapMarkerGoogleGreen m = new GMapMarkerGoogleGreen(pos.Value);
            m.ToolTip = new GMapRoundedToolTip(m);
            objects.Markers.Add(m);
            MainMap.Overlays.Add(objects);

Thanks.

Hamid

Mar 25, 2011 at 11:20 PM

your code is correct

Mar 26, 2011 at 8:13 AM

at 

objects.Markers.Add(m);

show error that m is null;but m not null.which propety of m is neccessary in code line ?

So why marker don't show on the map ?

Thanks.

Mar 26, 2011 at 11:00 AM

add overlay first

Mar 26, 2011 at 12:05 PM

I changed code to below

double lat = 35.6999651086143;
            double lng = 51.3378238677979;
            PointLatLng pos = new PointLatLng(lat, lng);
            GMapMarkerGoogleGreen m = new GMapMarkerGoogleGreen(pos);
            m.ToolTip = new GMapRoundedToolTip(m);
            MainMap.Overlays.Add(objects);
            objects.Markers.Add(m);

and this

double lat = 35.6999651086143;
            double lng = 51.3378238677979;
            PointLatLng? pos = new PointLatLng(lat, lng);
            GMapMarkerGoogleGreen m = new GMapMarkerGoogleGreen(pos.Value);
            m.ToolTip = new GMapRoundedToolTip(m);
            MainMap.Overlays.Add(objects);
            objects.Markers.Add(m);
            

but gives me "Object reference not set to an instance of an object." error.

how do i solved this error ?

can you give me a sample ?

Mar 26, 2011 at 12:17 PM

yes, it's Demo.WindowsForms, open it ;}

Mar 26, 2011 at 1:00 PM

i forgat add top to Overlays.

Thanks radioman

Mar 26, 2011 at 2:31 PM

;}