Espresso
Espresso

Reputation: 930

How to draw a line under a circle with Mapbox's Annotation plugin?

I am trying to display two circles and a line connecting them using the Mapbox Android SDK (7.0.0) and Annotations plugin (0.4.0). The line should be drawn when the user taps on two the two circles. Ideally, the line should appear underneath the circles. If I declare the line and circle managers like this:

lineManager = new LineManager(mapView, mapboxMap, style);
circleManager = new CircleManager(mapView, mapboxMap, style);

The circle.OnClickListener is never called. If I declare the line and circle managers like this:

circleManager = new CircleManager(mapView, mapboxMap, style);
lineManager = new LineManager(mapView, mapboxMap, style);

The circle.OnClickListener is called, but the resulting line is drawn on top of the circles, like this:

enter image description here

Instead of like this:

enter image description here

Not sure what I am doing wrong here. Is there a way to tell the map to draw the line underneath the circles? Or is there an issue with the order I am declaring the LineManager and CircleManager.

Thanks!

EDIT

Here are my build.gradle files:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "http://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "nocompany.datacollectionapp"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
} 
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.0.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.5.0-SNAPSHOT'
    implementation 'com.android.support:design:28.0.0'
}

Results in a gradle build error of Failed to resolve: com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.5.0-SNAPSHOT

Upvotes: 2

Views: 508

Answers (1)

Łukasz Paczos
Łukasz Paczos

Reputation: 607

Your idea is correct and regarding the

The circle.OnClickListener is never called.

This is most likely already resolved. You can test the solution with the com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.5.0-SNAPSHOT, but remember to include Sonatype repository reference.

Upvotes: 1

Related Questions