Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine 异步从数据存储中提取数据并绘制地图_Google App Engine_Spring Mvc_Google Maps Api 3 - Fatal编程技术网

Google app engine 异步从数据存储中提取数据并绘制地图

Google app engine 异步从数据存储中提取数据并绘制地图,google-app-engine,spring-mvc,google-maps-api-3,Google App Engine,Spring Mvc,Google Maps Api 3,我有一个springmvc3应用程序(使用JSP)在googleappengine上运行,并将信息保存在数据存储上。我正在使用谷歌地图API v3,通过绘制形状、着色等方式将一些数据投影到地图上。我的数据库将潜在地保存数百万条条目 我想知道最好的方法是一直从数据存储中提取数据并将其投影到地图上,直到没有更多的数据库条目可供投影。我需要这样做,以避免达到30秒的限制(并获得DeadLineExceedexception),但也为了良好的用户体验 值得使用GWT吗 任何建议都很好 谢谢 您可以使用类

我有一个springmvc3应用程序(使用JSP)在googleappengine上运行,并将信息保存在数据存储上。我正在使用谷歌地图API v3,通过绘制形状、着色等方式将一些数据投影到地图上。我的数据库将潜在地保存数百万条条目

我想知道最好的方法是一直从数据存储中提取数据并将其投影到地图上,直到没有更多的数据库条目可供投影。我需要这样做,以避免达到30秒的限制(并获得DeadLineExceedexception),但也为了良好的用户体验

值得使用GWT吗

任何建议都很好


谢谢

您可以使用类似于此处描述的分页技术的光标:

当您的地图页面加载时,让它发出一个带有空白游标参数的AJAX请求。请求处理程序将获取少量实体,然后返回一个包含它们的响应和一个游标(如果还有实体)

从客户端javascript,在映射上显示项目后,如果响应中有光标,则使用光标作为参数启动新请求。在请求处理程序中,如果提供了游标,则在进行查询时使用它

这将建立一个连续的AJAX请求循环,直到所有项目都被提取并显示在地图上

更新:

您可以编写一个返回JSON的服务,如下所示:

{
    items: 
    [
        { lat: 1.23, lon: 3.45, abc = 'def' },
        { lat: 2.34, lon: 4.56, abc = 'ghi' }
    ],
    cursor: '1234abcd'
}
$(document).ready(function()
{
    // first you may need to initialise the map - then start fetching items
    fetchItems(null);
});

function fetchItems(cursor)
{
    // build the url to request the items - include the cursor as an argument
    // if one is specified
    var url = "/path/getitems";
    if (cursor != null)
        url += "?cursor=" + cursor;

    // start the ajax request
    $.ajax({
        url: url,
        dataType: 'json',
        success: function(response)
        {
            // now handle the response - first loop over the items
            for (i in response.items)
            {
                var item = response.items[i];
                // add something to the map using item.lat, item.lon, etc
            }

            // if there is a cursor in the response then there are more items,
            // so start fetching them
            if (response.cursor != null)
                fetchItems(response.cursor);
        }});
}
因此,它包含一个项目数组(带有lat/lon和每个项目所需的任何其他信息),以及一个游标(在获取最后一个实体时为null)

然后,在客户端,我建议使用的函数进行ajax调用,如下所示:

{
    items: 
    [
        { lat: 1.23, lon: 3.45, abc = 'def' },
        { lat: 2.34, lon: 4.56, abc = 'ghi' }
    ],
    cursor: '1234abcd'
}
$(document).ready(function()
{
    // first you may need to initialise the map - then start fetching items
    fetchItems(null);
});

function fetchItems(cursor)
{
    // build the url to request the items - include the cursor as an argument
    // if one is specified
    var url = "/path/getitems";
    if (cursor != null)
        url += "?cursor=" + cursor;

    // start the ajax request
    $.ajax({
        url: url,
        dataType: 'json',
        success: function(response)
        {
            // now handle the response - first loop over the items
            for (i in response.items)
            {
                var item = response.items[i];
                // add something to the map using item.lat, item.lon, etc
            }

            // if there is a cursor in the response then there are more items,
            // so start fetching them
            if (response.cursor != null)
                fetchItems(response.cursor);
        }});
}

您可以使用类似于此处描述的分页技术的光标:

当您的地图页面加载时,让它发出一个带有空白游标参数的AJAX请求。请求处理程序将获取少量实体,然后返回一个包含它们的响应和一个游标(如果还有实体)

从客户端javascript,在映射上显示项目后,如果响应中有光标,则使用光标作为参数启动新请求。在请求处理程序中,如果提供了游标,则在进行查询时使用它

这将建立一个连续的AJAX请求循环,直到所有项目都被提取并显示在地图上

更新:

您可以编写一个返回JSON的服务,如下所示:

{
    items: 
    [
        { lat: 1.23, lon: 3.45, abc = 'def' },
        { lat: 2.34, lon: 4.56, abc = 'ghi' }
    ],
    cursor: '1234abcd'
}
$(document).ready(function()
{
    // first you may need to initialise the map - then start fetching items
    fetchItems(null);
});

function fetchItems(cursor)
{
    // build the url to request the items - include the cursor as an argument
    // if one is specified
    var url = "/path/getitems";
    if (cursor != null)
        url += "?cursor=" + cursor;

    // start the ajax request
    $.ajax({
        url: url,
        dataType: 'json',
        success: function(response)
        {
            // now handle the response - first loop over the items
            for (i in response.items)
            {
                var item = response.items[i];
                // add something to the map using item.lat, item.lon, etc
            }

            // if there is a cursor in the response then there are more items,
            // so start fetching them
            if (response.cursor != null)
                fetchItems(response.cursor);
        }});
}
因此,它包含一个项目数组(带有lat/lon和每个项目所需的任何其他信息),以及一个游标(在获取最后一个实体时为null)

然后,在客户端,我建议使用的函数进行ajax调用,如下所示:

{
    items: 
    [
        { lat: 1.23, lon: 3.45, abc = 'def' },
        { lat: 2.34, lon: 4.56, abc = 'ghi' }
    ],
    cursor: '1234abcd'
}
$(document).ready(function()
{
    // first you may need to initialise the map - then start fetching items
    fetchItems(null);
});

function fetchItems(cursor)
{
    // build the url to request the items - include the cursor as an argument
    // if one is specified
    var url = "/path/getitems";
    if (cursor != null)
        url += "?cursor=" + cursor;

    // start the ajax request
    $.ajax({
        url: url,
        dataType: 'json',
        success: function(response)
        {
            // now handle the response - first loop over the items
            for (i in response.items)
            {
                var item = response.items[i];
                // add something to the map using item.lat, item.lon, etc
            }

            // if there is a cursor in the response then there are more items,
            // so start fetching them
            if (response.cursor != null)
                fetchItems(response.cursor);
        }});
}

谢谢,听起来像是我的想法。你能提供一些代码吗?这只是一个让我开始学习的例子,因为我以前从未使用过AJAX。谢谢,这听起来像是我的想法。你能提供一些代码吗?这只是一个让我开始学习的例子,因为我以前从未使用过AJAX。