cordova-plugin-googlemaps如何从标记数组触发标记的info_window

时间:2016-03-17 06:01:15

标签: javascript android cordova google-maps google-maps-api-3

我很难显示从标记阵列中选择的特定标记的信息窗口。

我正在使用此插件https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Map与cordova。

我可以将相机移动到特定的标记位置,因为我从阵列中获取了标记的latLng,但是如何触发同一标记的Info_window。请帮忙

1 个答案:

答案 0 :(得分:1)

终于找到了解决方案。 在地图上添加标记时。该函数返回标记对象,将对象推送到一个数组。一个想法,

arrayOfMarker[i].show_infoWindow();

调用info_window

#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;


int main()
{
    int table[20][20] = { 0 };
    int value, n, wt[20], val[20], max_wt;

    cout << " Enter the number of items : ";
    cin >> n;
    cout << " Enter the Maximum weight : ";
    cin >> max_wt;
    cout << endl;
    for (int i = 1; i <= n; i++)
    {
        cout << " Enter weight and value of item " << i << " : ";
        cin >> wt[i] >> val[i];
    }

    // Initialization
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= max_wt; j++)
            table[i][j] = 0;

    // In practice, this can be skipped in a bottom up solution
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= max_wt; j++)
            table[i][j] = -1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= max_wt; j++)
        {
            if (j < wt[i])
                table[i][j] = table[i - 1][j];
            else
                table[i][j] = max(table[i - 1][j], val[i] + table[i - 1][j - wt[i]]);
        }
    }

    cout << " Optimum value : " << table[n][max_wt] << endl;

    cout << " \n Table : \n";
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= max_wt; j++)
            if (table[i][j] == -1)
                cout << setw(5) << "-";
            else
                cout << setw(5) << table[i][j];
        cout << endl;
    }

    return 0;
}

*不要继续使用语法,抓住想法