BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-14-2010, 10:28 AM   #1 (permalink)
New Member
 
Join Date: Aug 2010
Model: 9550
PIN: N/A
Carrier: Airtel
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question Need sample code for using Blackberry maps

Please Login to Remove!

Hey,
can some one help me with some sample code for using Blackberry maps.
I reffered to a link for Blackberry developers
"docs.blackberry.com/en/developers/deliverables/11944/CS_Embedding_a_map_in_an_application_897004_11.jsp "
but the map was not displayed on the simulator.

Please send me some sample code for showing map on a screen with a particular latitude and longitude and also able to zoom-in and zoom-out.

It seems using Blackberry maps is too complicated.

Thanks in advance..
Offline  
Old 09-14-2010, 12:30 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Have you looked at the MapFieldDemo that ships with the dev tools? Source is included.

You might also want to consider simply using the Invoke class to start the maps program, passing your location information to the invoked program using ApplicationArguments. This is much easier.
Offline  
Old 10-18-2010, 11:40 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2010
Model: bold
PIN: N/A
Carrier: tmobile
Posts: 16
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default

Here is a code sample according to BB:

import net.rim.device.api.lbs.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

public class MapFieldDemo extends UiApplication
{
public static void main(String[] args)
{
MapFieldDemo theApp = new MapFieldDemo();
theApp.enterEventDispatcher();
}

MapFieldDemo()
{
pushScreen(new myScreen());
}
}

class myScreen extends FullScreen implements FieldChangeListener
{
private MapField _mapField;
private ButtonField _zoomIn;
private ButtonField _zoomOut;
private ButtonField _moveTo;
private BasicEditField _moveByText;
private BasicEditField _testsOutput;
private ObjectChoiceField _moveUnits;
private int _prevLat = 4328915;
private int _prevLon = -8032480;
private int _prevZoom = 4;

myScreen()
{
super(DEFAULT_MENU | DEFAULT_CLOSE);
createUI();
}

private void createUI()
{
VerticalFieldManager vfm;

synchronized (Application.getEventLock())
{
vfm = new VerticalFieldManager
(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT);
_mapField = new MapField();
_mapField.setPreferredSize(_mapField.getPreferredW idth(),
(int)(Display.getHeight() * 0.66));
vfm.add(_mapField);
}

FlowFieldManager ffm = new FlowFieldManager();
ffm.add(_zoomIn = new ButtonField("Zoom In"));
_zoomIn.setChangeListener(this);

ffm.add(_zoomOut = new ButtonField("Zoom Out"));
_zoomOut.setChangeListener(this);

ffm.add(_moveUnits = new ObjectChoiceField("Units: ", new String[]
{
"pixels", "degrees"
}));
ffm.add(_moveByText = new BasicEditField("Move horizontal, vertical: ",
"", 20, BasicEditField.NO_NEWLINE));

ffm.add(_moveTo = new ButtonField("Move"));
_moveTo.setChangeListener(this);

vfm.add(ffm);
add(vfm);

_mapField.moveTo(_prevLat, _prevLon);
_mapField.setZoom(_prevZoom);
}

public void fieldChanged(Field field, int context)
{
if (field == _zoomIn)
{
_mapField.setZoom(Math.max(_mapField.getZoom() - 1,
_mapField.getMinZoom()));
}
else if (field == _zoomOut)
{
_mapField.setZoom(Math.min(_mapField.getZoom() + 1,
_mapField.getMaxZoom()));
}
else if (field == _moveTo)
{
String amount = _moveByText.getText();
int ix = amount.indexOf(",");
int horizontalDelta = 0;
int verticalDelta = 0;

if (ix == -1)
{
ix = amount.indexOf(" ");
}

try
{
horizontalDelta = Integer.parseInt
(amount.substring(0, ix).trim());
verticalDelta = Integer.parseInt
(amount.substring(ix + 1, amount.length()).trim());
}
catch (NumberFormatException nfe)
{
Dialog.alert("Bad value!");
}

if (_moveUnits.getSelectedIndex() == 0)
{
_mapField.move(horizontalDelta, verticalDelta);
}
else
{
horizontalDelta += _mapField.getLongitude();
verticalDelta += _mapField.getLatitude();
_mapField.moveTo(verticalDelta, horizontalDelta);
}
}
}
}
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.