小编use*_*097的帖子

Android Google Map如何检查用户是否在标记圈区域

我正在使用谷歌地图,并希望能够使用用户当前位置检测用户是否在标记的半径(放置在地图上).我有用户当前位置坐标(纬度和经度)和标记的坐标,但不知道如何计算用户是否在该区域.下面的图片可能最能描述我想要做的事情.

在此输入图像描述

我有这样的算法:

map.OnInfoWindowClickListener(new OnInfoWindowClickListener()){
    public void isUserInArea(Marker marker){

        float[] distance = new float[2];
           //users current location 
        Location.distanceBetween(currentLocation.getLatitude(),currentLocatiocation.getLongitude(),
        marker.getPosition().latitude, marker.getPosition().longitude, distance);
}
Run Code Online (Sandbox Code Playgroud)

如果当前位置在标记区域内,则无法找到,因为我无法抓住标记圈.然而,这是我最接近它的.很感激帮助.

为了提供帮助,我在这样的地图上添加了一个圆圈

// adding circle to map
circleOptions = new CircleOptions();
circleOptions.center(new LatLng(locationlist.get(i)
        .getLatitude(), locationlist.get(i).getLongitude()));
circleOptions.radius(20);
circleOptions.strokeColor(Color.BLUE);
circleOptions.fillColor(Color.BLUE);
map.addCircle(circleOptions);

//check that all tasks are in circle radius

Marker locationMarker = map.addMarker(markerOp);
locationMarker.showInfoWindow();
Run Code Online (Sandbox Code Playgroud)

google-maps distance area marker

3
推荐指数
1
解决办法
8680
查看次数

如何从String变量中获取小时和分钟?

我有一个String timme = "13:10".我想知道如何最好地获取小时和分钟并将它们转换为整数.即int hours = 13,int minute = 10.我知道for循环不是最有效的方法,有什么更简单的吗?

java string time

1
推荐指数
2
解决办法
1万
查看次数

index(of:element)不存在

我有一个非常奇怪的错误.一直在学习Swift,并且正在阅读有关在数组中查找对象索引的文档:https://developer.apple.com/reference/swift/array/1689674-index

但是我的Xcode中不存在这种方法.

这是一个例子:

var items : [TaskItem]
items = [TaskItem] () 

    let rowitem = TaskItem()
    rowitem.text = "helloworld"
    items.append(rowitem)

//Attempting to find the index of an object

   items.Index(of: rowitem) 
Run Code Online (Sandbox Code Playgroud)

//错误 - Xcode无法找到我正在寻找的特定功能

我附上了一个出现的方法的图像,但是无法找到答案,为什么这可能发生在任何地方.

我找不到使用func索引(of :)方法,虽然我知道它存在!

我得到以下编译器错误:

ChecklistViewController.swift:186:26:参数标签'(of:,_ :)'与任何可用的重载都不匹配

ChecklistViewController.swift:186:26:这些部分匹配的参数列表存在'index'的重载:(Int,offsetBy:Int),(Self.Index,offsetBy:Self.IndexDistance)

在此输入图像描述

indexof swift

1
推荐指数
1
解决办法
886
查看次数

"s"附近的SQLite异常语法错误

真的很抱歉,如果这是微不足道的,但我已经非常努力地找到这个方法中的错误,并且我对sql很新.不知道这里出了什么问题.真的很感激帮助

public List getAllTask​​sbyLocation(String address){

    List<Task> tasklist = new ArrayList<Task>();
     String selectQuery = "SELECT * FROM " + TABLE_TASKS + " tskTble, "
                + TABLE_LOCATIONS + " locTble, " + TABLE_TLRELATIONSHIP
                + " tlRelation WHERE locTble." + KEY_MARKER_ADDRESS + " = '"
                + address + "'" + " AND locTble." + KEY_ID + " = "
                + "tlRelation." + KEY_LOCATION_ID + " AND tskTble." + KEY_ID
                + " = " + "tlRelation." + KEY_TASK_ID;

        // insert log here

        SQLiteDatabase db …
Run Code Online (Sandbox Code Playgroud)

sql android

0
推荐指数
1
解决办法
2470
查看次数

JavaScript JSON对象对象错误

我试图从下面的数据打印出关键和值名称,例如"玩家1" - "球"帽子"和"玩家2 - '球,'帽子'.所以键有多个值名称,但我不知道我是如何打印出来的.**我得到'[object Object]'作为回复**.有人可以帮助我理解这个理解并试图解决这个问题.

数据

{
    "Player1": {
        "ball": 1,
        "hat": 2

    },
    "Player2": {
        "ball": 1,
        "hat": 2,
    }
}
Run Code Online (Sandbox Code Playgroud)

JavaScript的

$.getJSON('data.json', function (data) {
    var response = data;
    for (key in response){
        alert("key: " + key + "value :" + response[key]);
    }
});
Run Code Online (Sandbox Code Playgroud)

javascript jquery json

0
推荐指数
1
解决办法
7514
查看次数

标签 统计

android ×1

area ×1

distance ×1

google-maps ×1

indexof ×1

java ×1

javascript ×1

jquery ×1

json ×1

marker ×1

sql ×1

string ×1

swift ×1

time ×1