BlackBerry map with multiple markers - blackberry

I want to create a blackberry application which displays a custom map with many markers.
Each marker should be clickable and when clicking on it, more information will display. Also, the map should allow the user to navigate around.

You could extend the class
net.rim.device.api.lbs.MapField
and implement the paint method to display your custom markers.
Overriding navigationMovement and keyChar will help you to implement the navigation as you want it to be .
To make the markers clickable on non-touch devices, you'll need some kind of cursor.
On touch devices you can work with pointerReleased.

you could use this code in mapfield touchEvent class,this will allow you to navigate thru mapfield on moving ur finger on touchscreen,hope this will solve your problem
public boolean touchEvent(TouchEvent message){
int x=message.getX(1);
int y=message.getY(1);
if(message.getEvent()==TouchEvent.MOVE){
XYPoint _xyIn = new XYPoint();
XYPoint _xyOut = new XYPoint();
_xyIn.x=x;
_xyIn.y = y;
convertFieldToWorld(_xyIn,_xyOut);
map.moveTo(_xyOut.y,_xyOut.x);
return true;
}
return false;
}

Related

Vaadin focus Grid inside Panel

I have two Grids (both in its own panel), and want to navigate between them using the Tab Key.
To do that I'm trying to focus the Grid inside a Panel (If Tab is pressed, the Grid should gain focus, so I can use the up/Down key to select Items).
Vaadin doesn't provide a .focus() method for Grid. Is there any solution so I can focus the Grid anyway?
Here is small example which shows working scenario with
Tab key pressed
Arrows down/up should points to a row (exactly in Valo this is presented as contour around one cell)
Space makes row selected (if Grid has enabled selection!) - row should be highlighted.
Code example:
#Theme ( ValoTheme.THEME_NAME )
public class MyUI extends UI {
public class A {
String a;
String b;
A(String a, String b) {
this.a = a;
this.b = b;
}
// getters & setters
}
#Override
protected void init ( VaadinRequest vaadinRequest )
{
Grid g = new Grid();
List<A> list = Arrays.asList(new A("a", "b"), new A("aa", "bb"),
new A("aaa", "bbb"));
BeanItemContainer<A> items = new BeanItemContainer<>(A.class, list);
g.setContainerDataSource(items);
Panel p = new Panel(g);
setContent(p);
}
}
Tested: Vaadin 7.5, Java 8, Tomcat 8.
You could try to use:
setFocusedComponent(p);
after setContent(p). This should exactly tells Vaadin to make panel focused. But you still must press tab - once or more (depending on rest of components, which you placed on screen).
But make sure:
Grid is selectable.
Maybe you should press Tab more than once.
Depending on Theme there could be different effects of getting focus (or even select state). It is also possible that you use some predefined project which has blocked grid css to make it lighter. So check if you can highlight one row by click on it.
Without more information I can't help more.
The OP write in an edit:
Solved the problem using Javascript/Jquery. Added this to my Panel that contains the Grid:
public class FileTable extends Panel
{
String id;
public FileTable(String id)
{
this.id=id;
Grid table = new Grid();
initGrid();
fileTable.setId(id);
}
public void focus()
{
JavaScript.getCurrent().execute("$(\"#"+id+" table:first td:first\").click();");
}
}

How may I use touch gestures to scroll through a series of pictures?

How can I create a gesture activity in Blackberry in such a way that images appear one after another on different screens ? Can anybody explain me with an example ? I want the images to appear one after another on the mouse click when dragged from left side as well as right side
There's some sample code for this on the BlackBerry website.
Create a scrollable image field
http://supportforums.blackberry.com/t5/Java-Development/Create-a-scrollable-image-field/ta-p/444955
Also it sounds like you might find this introduction to touch gestures helpful
http://supportforums.blackberry.com/t5/Java-Development/Introduction-to-Touch-Gestures/ta-p/555363
use the below code to find the touchGESTURE.
protected boolean touchEvent(TouchEvent message)
{
switch(message.getEvent())
{
case TouchEvent.GESTURE:
TouchGesture gesture = message.getGesture();
switch(gesture.getEvent())
{
case TouchGesture.NAVIGATION_SWIPE:
Dialog.alert("Swipe direction: " + gesture.getSwipeDirection()
+ ", "
+ "\nMagnitude: " + gesture.getSwipeMagnitude());
return true;
}
}
return false;
}
for more info visit Swipe_gestures_trackpad

scroll change listener on blackberry

I already posted my question below link..
scroll change listener on blackberry
The error has been resolved.
But i need to move the field center position after scrolling . pls give any idea... Thanks in advance...
there are number of fields add in the scroll bar...
after scrolling its show like this.
But i need to move the field center position like this.
Pls give any idea..
Looks like you just need some flag to detect whether this is a sroll event originated by user, or from the code (programmatically).
If you originate a scroll event programmatically, then set some boolean, let's call it ignoreScrollEvent, to true. Smth like this (pseudo code):
private boolean ignoreScrollEvent = false;
public void scrollChanged(Manager manager, int newHorizontalScroll,
int newVerticalScroll) {
if (!ignoreScrollEvent) {
ignoreScrollEvent = true;
// recalculate the newHorizontalScroll so the field in the focus
// gets in the middle
horizontalScrollLayout.setHorizontalScroll(newHorizontalScroll);
int fieldIndex = horizontalScrollLayout.getFieldAtLocation(
newHorizontalScroll + customfieldwidth, 0
);
Field f = horizontalScrollLayout.getField(fieldIndex);
f.setFocus();
invalidate();
} else {
ignoreScrollEvent = false;
}
}

partial-screen MapView on BlackBerry

I am currently working on an application that requires a mapview. The thing is I do not require the screen to be completely taken up by the map view. I would like to place a few buttons on the bottom of the screen.
I tried using the VerticalFieldManager to get it working but that didn't work.
This is the code used to call the VerticalFieldManager for the MapView:
private VerticalFieldManager startpageTab()
{
set=new LabelField("Start Map");
add(set);
MapView map = new MapView();
map.setLatitude(4542349);
map.setLongitude(-7569792);
map.setZoom(1);
// Invoke maps application with specified MapView
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(map));
return maptabArea;
}
put your buttons in one FlowFieldManager and put this FlowFieldManager in status,using setStatus(field); method.

Dojo dialog, the iPad and the virtual keyboard issue

Recently, I have been working on a project where the interface should work for desktop and tablets (in particular the iPad).
One issue I am coming across is with a Dojo dialog on the iPad when text entry is taking place.
Basically here is what happens:
Load Dojo interface with buttons on iPad - OK
Press button (touch) to show dialog (90% height and width) - OK
Click on text box (touch) like DateTextBox or TimeTextBox - OK, the virtual keyboard is opened
Click the date or time I want in the UI (touch) - OK, but I can't see all of the options since it is longer than the screen size...
Try to scroll down (swipe up with two fingers or click 'next' in the keyboard) - not OK and the dialog repositions itself to have it's top at the top of the viewport area.
Basically, the issue is that the dialog keeps trying to reposition itself.
Am I able to stop dialog resizing and positioning if I catch the window onResize events?
Does anyone else have this issue with the iPad and Dojo dialogs?
Also, I found this StackOverflow topic on detecting the virtual keyboard, but it wasn't much help in this case...
iPad Web App: Detect Virtual Keyboard Using JavaScript in Safari?
Thanks!
I just came across the same issue yesterday and found a hack,
which is not an elegant solution.
If you want to stop the dijit.Dialog from repositioning you can:
1) Set the property ._relativePosition of a dijit.Dialog object
(in this case it's "pop") after calling the method pop.show():
pop.show();
pop._relativePosition = new Object(); //create empty object
Next steps would probably be:
Check browser type&OS: dojo or even better BrowserDetect
Check when the virtual keyboard is activated and disable repositioning
Extend dijit.Dialog with custom class (handle all of the exceptions)
As suggested another way to do this is to override the _position function by extending the object (or maybe relative position, or other method). Here is my solution which only allows the dialog to be positioned in the middle of the screen once. There are probably better ways to change this by playing with the hide and show events but this suits my needs.
dojo.provide("inno.BigDialog");
dojo.require("dijit.Dialog");
dojo.declare("inno.BigDialog",dijit.Dialog,{
draggable:false,
firstPositioned : false,
_position : function() {
if (!dojo.hasClass(dojo.body(), "dojoMove") && !this.firstPositioned) {
this.firstPositioned = true;
var _8 = this.domNode, _9 = dijit.getViewport(), p = this._relativePosition, bb = p ? null
: dojo._getBorderBox(_8), l = Math
.floor(_9.l
+ (p ? p.x : (_9.w - bb.w) / 2)), t = Math
.floor(_9.t
+ (p ? p.y : (_9.h - bb.h) / 2));
if (t < 0) // Fix going off screen
t = 0;
dojo.style(_8, {
left : l + "px",
top : t + "px"
});
}
}
});
You can override the _position function and call the _position function of the superclass only once. (See http://dojotoolkit.org/reference-guide/dojo/declare.html#calling-superclass-methods)
if (!dojo._hasResource["scorll.asset.Dialog"]) {
dojo._hasResource["scorll.asset.Dialog"] = true;
dojo.provide("scorll.asset.Dialog");
dojo.require("dijit.Dialog");
dojo.declare("scorll.asset.Dialog", [dijit.Dialog], {
_isPositioned: false,
_position: function () {
if(this._isPositioned == false) {
// Calls the superclass method
this.inherited(arguments);
this._isPositioned = true;
}
}
})
}

Resources