-
Notifications
You must be signed in to change notification settings - Fork 14
Advanced point handling
Except creating and displaying of points, Locus API offer some few very interesting options.
Imagine your add-on display point on a map. Since that moment, you lost contact with your point. What if you want to react on user events and do something more with point, once clicked? For this, exists OnClick callback feature.
Prepare ID that will identify event once received
public static final String EXTRA_ON_DISPLAY_ACTION_ID = "myOnDisplayExtraActionId";
point.setExtraOnDisplay(
"com.asamm.locus.api.sample",
"com.asamm.locus.api.sample.MainActivity",
EXTRA_ON_DISPLAY_ACTION_ID,
"id01");
First two parameters define package name and class name of activity, that receive event. Third parameter is our ACTION_ID and last is unique identification of point.
Once your activity starts, check content of intent
if (getIntent().hasExtra(EXTRA_ON_DISPLAY_ACTION_ID)) {
// get ID of point
String id = getIntent().getStringExtra(EXTRA_ON_DISPLAY_ACTION_ID);
// now we should have ID of point. We may for example generate new improved version ...
Waypoint pt = ... create new point
pt.addParameter(ExtraData.PAR_DESCRIPTION,
"Extra description to ultra improved point!, received value:" + value);
// ... and send it back
Intent retInent = LocusUtils.prepareResultExtraOnDisplayIntent(pt, true);
act.setResult(Activity.RESULT_OK, retInent);
act.finish();
// or we should just display dialog/toast to user
new AlertDialog.Builder(act).
setTitle("Intent - PickLocation").
setMessage("Some message ...").
setPositiveButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {}
}).show();
}
Locus API offer to search in Locus database and get points defined by name.
ActionTools.getLocusWaypointId(context, locusVersion, name);
Name parameter use wildcards, so following options are valid
- search for point that has exact name "Cinema", just write "Cinema" as name
- search for point that starts with "Cinema", just write "Cinema%" as name
- search for point that contains word "cinema", just write "%cinema%" as name
Result of search is list of found points, better it's ID's.
With known ID of point, we may load full point over Locus API
Waypoint point = ActionTools.getLocusWaypoint(context, locusVersion, pointId);
With known ID of point, we may also display big point screen directly in Locus.
ActionTools.displayWaypointScreen(context, locusVersion, pointId);
This method exists in advanced variation, where callback may be also defined and Locus then report back even when point screen is closed.
-
Basics
-
Non-API tools
-
Using API
-
Work with points
-
Work with tracks
-
Integration into Locus Map
-
Other/advanced features