Coding for iOS App:
I am integrating Indoor location estimote functionality. I am able to configure 4 beacons and get the indoor location positioning JSON and added in the code. I am able to display the indoor positioning path when I want on the beacons placed. In the indoor location map path, I can see the beacon icons, further I want to add a beacon name near to the beacon icon. My question is, How to add a name label in the indoor location map path?
The “object” parameter can by any UIView, e.g., UILabel.
And for the “position” parameter: you can retrieve a list of the beacons + their positions in the location via ESTLocation's beacons property. It returns an array of ESTPositionedBeacon objects, and ESTPositionedBeacon has a position property which you can pass to the drawObject method.
Lastly, the “identifier” parameter is there in case you want to later remove the label via the removeObjectWithIdentifier: method, or move it. Should be unique per each object.
(The “drawObject InTheBackground” part means that the avatar will be drawn “on top” of the label. You can also use “drawObject InTheForeground” if that fits your app better.)
Thank you for the reply. I have another doubt. Can we get this position from JSON we exported and use for labeling , since this JSON already contains the beacon positions ? Will that work as well?
I am working on the same project as Martin worked.
I am following this post and trying to keep lables for every beacon on the ESTBeaconViewController.
But I am getting run time error. Kindly help me. I have posted my code here.
The object passed to the drawObject method should be the UI element you want to draw inside the location view (e.g., a UILabel), and not the location view itself. It should be something like this instead:
// this label will be 150 points wide and 40 points high
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];
label1.text = roomNames[0];
[self.locationView drawObjectInBackground:label1 withPosition:estOrientedPointorentation identifier:@"sdb"];
As for your questions:
(1) The identifier string can be anything, but should be unique for each object you’ll be drawing via the “drawObject” methods. It’s only use if you later want to remove the object from the location view, or move it to some other place.
(2) See the code above. You should not use the [self.locationView addSubview:lable1];, and instead add the label to the location view via the “drawObject” method.
we had got one problem, while placing labels besides the beacons on the wall of the view. The label text is placed on the wall and unable to read the text.
Is there any possibility to change position of the label just beneath the wall of the view?
Hi heyplotr,
yes facing the similar issue as mentioned by soujanya. Label is overlapping and no way to move at the correct positions. Changing x or y axis, doesn’t change the label position at all. Could you please advise please?
for(int iloop = 0; iloop< beaconsArray.count ; iloop++) // for 4 beacons placed
{
ESTPositionedBeacon *estPositionedBeacons = beaconsArray[iloop];
ESTOrientedPoint *estOrientedPoint = estPositionedBeacons.position;
// trying to add + 50 in the x and y axis, but there is no change happening
CGRect frame = CGRectMake((estOrientedPoint.x) + 50.0, (estOrientedPoint.y) + 50.0, 200.0, 40.0);
UILabel *lable = [[UILabel alloc] initWithFrame:frame];
lable.text = appdelegate.roomNameArray[iloop];
lable.font = [UIFont fontWithName:@"Arial" size:9.0];
[self.locationView drawObjectInBackground:lable withPosition:estOrientedPoint identifier:appdelegate.roomNameArray[iloop]];
}
… only changes the label itself, not its position, and the first two arguments are ignored by the location view anyway. What you actually need to change is the estOrientedPoint, i.e.: