hello every one hope you having a nice day
in order to load tons of markers (like 1mil) i am passing a list of MapPos to a VectorDataSource and trying to force it to live create the Points whenever related coordinates must be visible to the map now , but unfortunanly after a few try seems i dont know much about the map . would you please help me solve this puzzle ? thaanks alot
public static void createlustering(Projection proj,MapView mapView,Context context,final Bitmap bmp,float distance,float textSize,final ArrayList<MapPos> points){
AbstractVectorDataSource<Geometry> source = new AbstractVectorDataSource<Geometry>(proj) {
#Override
public Collection<Geometry> loadElements(CullState arg0) {
//what to do here
return list;
}
#Override
public Envelope getDataExtent() {
//what to do here
return null;
}
};
// source.addAll(points);
Clusterer mClusterer = new Clusterer();
mClusterer.addPointCluster(mapView, context,source,bmp,distance,textSize);
}
Unfortunately, that's a bit of a large amount to load with clusters. A more scalable solution, however, is to load them to your CARTO account and query them from there (overviews are used).
cf. android samples: CartoDBSQLDataSource and CartoSQLActivity
Additionally, if you're open to upgrading your SDK version, you can check out newer samples (master branch)
Related
The goal of the program I am writing, is the following:
take a a jpg image with the DJI mavic 2 enterprise
download the jpg image onto the connected android application
The code does this. The issue is, that the entire process takes over 5, sometimes up to 15 seconds to complete. The main bottleneck is the refreshFileListOfStorageLocation() function.
The code setup is the following:
mMediaManager = DJISampleApplication.getProductInstance().getCamera().getMediaManager();
camera = DJISampleApplication.getProductInstance().getCamera();
camera.startShootPhoto(new CommonCallbacks.CompletionCallback() {
#Override
public void onResult(DJIError djiError) {
mMediaManager.refreshFileListOfStorageLocation(SettingsDefinitions.StorageLocation.INTERNAL_STORAGE, new CommonCallbacks.CompletionCallback() {
#Override
public void onResult(DJIError djiError) {
newPicture();
});
});
void newPicture() {
mediaFileList = mMediaManager.getInternalStorageFileListSnapshot();
MediaFile lastImage = mediaFileList.get(mediaFileList.size()-1);
lastImage.fetchFileData(destDir, names[0], new DownloadListener<String>() {
#Override
public void onSuccess(String s) {
deleteAllFilesFromDrone();
return;
}
}
Like I said, this works; the problem is the time between refreshFileListOfStorageLocation() and it's onResult.
Is there any way to speed this up? I've tried:
keeping the number of files on the drones storage at 1 max,
making a FileState listener through addUpdateFileListStateListener, though this is only triggered once
checking the FileListState and only refreshing, if the state is INCOMPLETE or RESET
none of these helped.
According to my correspondence with DJI Developer Support:
Unfortunately, the universal answer is that the speed is what it is
and there's not anything that can be done to speed up the process
other than downloading a preview of the media file or manually taking
the SD card out and downloading the media directly onto a computer.
So it does not seem, as if any further speed improvements through any API tricks are possible.
I have an android app which one of its screens uses google maps, and I load some regions on it. I want to be able to click on a region/shape(circle or polygon) and an info window to appear. I am searching but I cant find enough information on how to show info windows on shapes, only on markers. Is that not a common practice? What should I do? Could anyone help, even theoretically? Any help or direction would be appreciated, thank you very much!
Create a customCircleOnClickListener (or don't and use the title and
snippet properties, as I am doing in step 3).
Then add:
mMap.setInfoWindowAdapter(new
CustomInfoWindowAdapter(MainActivity.this));
mMap.setOnCircleClickListener(customCircleOnClickListener());
Finally:
public GoogleMap.OnCircleClickListener customCircleOnClickListener() {
return new GoogleMap.OnCircleClickListener() {
#Override
public void onCircleClick(Circle circle) {
Log.d("MainActivity", "Clicked a ball!");
POIAnnotationCircle annotCircle = annotationsByCircle.get(circle);
markerForInfoWindow = mMap.addMarker(new MarkerOptions()
.alpha(0.0f)
.infoWindowAnchor(.6f,1.0f)
.position(annotCircle.getCoordinate())
.title(annotCircle.getTitle())
.snippet(annotCircle.getSnippet()));
markerForInfoWindow.showInfoWindow();
}
};
}
I am building this app, that will recognize painting and will display the info about it with the help of AR.
And I need to call multiple image target but not simultaneously, it will only call the image target if it is detected by AR camera.
*Ive tried creating many scenes with Image target on it but I cant call different imagetarget it keeps on reverting to only 1 imagetarget.
This is wat you can see in menu,
Main menu
Start AR camera(This part should have many image target but not detecting it simultaneously)
Help(how to use the app)
Exit
*Im using vuforia in creating AR
Thanks in advance for those who will help me.
This is the imagetarget and its Database
View post on imgur.com
Run the multi target scene sample. There are three target (stone, wood and road).
Each contains the TrackableBehaviour component.
Grab it and disable it in Start. If you do it in Awake it will be set back to active most likely in the Awake of the component itself or via some other manager.
public class TrackerController:MonoBehaviour
{
private IDictionary<string,TrackableBehaviours> trackers = null;
private void Start()
{
this.trackers = new Dictionary<string,TrackableBehaviour>();
var trackers = FindObjectsOfType<TrackableBehaviour>();
foreach(TrackingBehaviour tb in trackers)
{
this.trackers.Add(tb.TrackableName, tb);
tb.enabled = false;
}
}
public bool SetTracker(string name, bool value)
{
if(string.IsNullOrEmpty(name) == true){ return false; }
if(this.trackers.ContainsKey(name) == false){ return false; }
this.trackers[name].enabled = value;
return true;
}
}
The method finds all TrackableBehaviour and places them in a dictionary for easy access. The setting method return boolean, you can change it to throw exception or else.
This is really killing me, I had them working then rewrote a bunch of code, and now it doesn't and I've got no version control! Any help is appreciated.
I create the markers in a Utility class.
private static MarkerOptions buildAmarker(LatLng location, String bankType, String locationDetails,
float markerColour) {
MarkerOptions binMarker = new MarkerOptions().position(location).title(bankType)
.snippet(locationDetails)
.icon(BitmapDescriptorFactory.defaultMarker(markerColour));
//.snippet(siteName + " | " + locationDetails);
return binMarker;enter code here
Then after my Loader completes, onLoadFinish, it hands me back various list of marker Options objects, I process them into Markers here:
private List<Marker> addBankListToMap(List<MarkerOptions> oneBankList) {
Log.i("ADDING a selected", "banks list to map");
// we need to save NEW lists of map attached markers OR can't change marker visibility
List<Marker> newBankList = new ArrayList<>();
for (int i = 0; i < oneBankList.size(); i++) {
MarkerOptions binMarker = oneBankList.get(i);
Marker newMarker = m_map.addMarker(binMarker);
newMarker.setVisible(true);
newBankList.add(newMarker);
//Log.e("!!!addingBank", newMarker.getTitle() + newMarker.getSnippet());
}
return newBankList;
Then end onLoadFinish with this
// setup click event for home marker to launch change home screen
m_map.setOnMarkerClickListener(EarthquakeActivity.this);
But none of the info windows appear if clicked. What am I missing? It was working till I rewrote my code, and I made a LOT of algorthmic improvements, I use arrays instead of half a dozen hashmaps, so the memory overhead should be less.
I can only think I've either deleted something crucial in a tidy up while being tired.
OR
I've blocked the info windows somehow. Some sleuthing to find the block, by disabling the changes, has failed. So it seems I've deleted something, forgotten something vital.
What do I need to do to get infoWindows working again? This is absolutely vital to my app. Arrggg!
#Override
public boolean onMarkerClick(Marker marker) {
if (marker.equals(homeMarkerFinal)) {
// TODO make this launch the change home address screen
Log.wtf("markerClicked", "!!!!");
Intent settingsIntent = new Intent(EarthquakeActivity.this, SettingsActivity.class);
startActivity(settingsIntent);
}
return true;
}
This is just for a single marker, the home marker. All the other markers are unnamed, I've got around 4000 markers stored in Lists as MarkerOptions. These lists are passed to addBankListToMap as oneBankList and converted into Markers, and attached to the map.
To show inforwindow you need call:
marker.showInfoWindow();
Pls put in in your onMarkerClick function.
Brilliant phongvan!, of course at some point I deleted this
else {
marker.showInfoWindow();
}
onMarkerClick.
Thankgod! My app had become useless! :) A thousand thanks phongvan.
I'm working in an app using Parse.com and I've been experiencing some random behavior, I made a simpler version of my code to show you and while it keeps being random (the results I expect happen about 4 in 5 times) it got better (in my code it's correct about 2/5 of the runs).
So the method is this, a very simple creation and filling of a new object:
public void test(){
final List<ParseObject> list = new ArrayList<>();
for(j=0;j<4;j++){
list.add(new ParseObject("Object"));
list.get(j).put("Column1", "sup");
list.get(j).put("Column2", "bro");
if(j==3){
ParseObject.saveAllInBackground(list, new SaveCallback() {
#Override
public void done(ParseException e) {
Toast.makeText(MainActivity.this, "NANANANANANANANA BATMAN!",Toast.LENGTH_LONG).show();
}
});
}
}
}
}
Problem is it creates 4 ParseObjects (as it should) only 4/5 of the tries, then 1/4 it's only 3. Why does this happen?
Why don't you create and store your ParseObject in a variable and then, use put("Column1", "sup"); and put("Column2", "bro"); on it before adding this variable directly to your list? because you are accessing your list two times for nothing where it can be avoided.
It would be cleaner and it would allow you to debug better.