Mapviewer Zoom Radius

I have the Mapviewer initial radius set to 10km but when I add the following code from a button press the map zooms out to something more like 100km. Also it doesn’t add MyPic as the Pin. Any suggestions as to why the map zooms out and the Pin doesn’t change?

Dim mypicture As Picture
mypicture = New Picture(40, 60)
mypicture.Graphics.DrawPicture(MyPic,0,0,40,60,0,0, MyPic.width, MyPic.height)

locations.Add(New MapLocation(Mylat, Mylong, MyTag))
locations(locations.LastIndex).Icon = mypicture
MapViewer1.AddLocation(locations)

I might add that if I add a location using LocationFrom Query it all works fine. The Radius doesn’t change and myopic Pin is added? I can’t see a difference?

locationsFound = MapViewer1.LocationsFromQuery(mystop)
Dim mypicture As Picture
mypicture = New Picture(40, 60)
mypicture.Graphics.DrawPicture(MyPic,0,0,40,60,0,0,MyPic.width,MyPic.height)
locationsFound(locationsfound.LastIndex).Icon = mypicture
MapViewer1.AddLocation(locationsFound)

Hi @Martin_Fitzgibbons

Doing a quick test with the following code:

Var locations() As MapLocation = MapViewer1.LocationsFromQuery("Castellón de la Plana")
Var lc As MapLocation
If Locations.LastIndex <> -1 Then
  lc = locations(0)
End If
Var p As New Picture(40,60)
p.Graphics.DrawPicture(JProfile,0,0,p.Width,p.Height,0,0,JProfile.Width,JProfile.Height)
lc.Icon = p
Me.AddLocation(lc)

I can get this (with the icon set to the chosen picture)., It also works the same when the MapLocation instance is created without a query (providing the latitude and longitude):

Thanks I’ll check it out. Was that in the Simulator or on a device?
How do you code that with Latitude and longitude? Maybe I am doing something wrong there.

Both.

How do you code that with Latitude and longitude? Maybe I am doing something wrong there.

Var lc As MapLocation = New MapLocation(39.98975,-0.0406115)
Var p As New Picture(40,60)
p.Graphics.DrawPicture(JProfile,0,0,p.Width,p.Height,0,0,JProfile.Width,JProfile.Height)
lc.Icon = p
Me.AddLocation(lc)

Hi Javier,

That works fine if I have a specific lat, long but if I try and get the current Latitude and Longitude from a MobileLocation control then it draws my icon in the Ocean even though the Lat, Long are for a land location (Ericeira, Portugal). I tried to separate the process as I am adding multiple locations after the first location which I save to a database to recall later. I am calling this from a Button control.

I basically want to drop a pin in my current location.

Var mylocations() As MapLocation
Var mlc As MapLocation = New MapLocation(Mylat, Mylong)
MyAddress = mlc.Address
MessageBox(MyAddress)
mylocations = MapViewer1.LocationsFromQuery(mlc.Address)

Var lc As MapLocation
If myLocations.LastIndex <> -1 Then
  lc = mylocations(mylocations.LastIndex)
End If
MessageBox(Mylat.ToString+" , "+Mylong.ToString)

Var p As New Picture(40,60)
p.Graphics.DrawPicture(MyPic,0,0,p.Width,p.Height,0,0,MyPic.Width,MyPic.Height)
lc.Icon = p
locations.Add(lc)
MapViewer1.AddLocation(lc)

Hi @Martin_Fitzgibbons,

Your snippet of code works pretty fine here when running it on device. Maybe the problem is that when it is run on Simulator you get a initial location with lat/long set to 0/0 by default?

Yes I thought that too so I set the location in the Simulator prefs and that fixed that issue but I am getting it on the device. All the info says it should put the pin in the right spot. Could it be because I am setting it from a button?

Hi Javier,
Getting some success and appreciate your feedback.
Thanks
Martin