使用google地图进行实时车辆跟踪,显示车辆在google地图上移动

问题描述 投票:2回答:1

我正在从事实时车辆跟踪项目。

我每隔6秒钟就会获得车辆位置,并且每次都会将经度和纬度存储在静态变量中。

我想在使用ajax更改位置后在Google地图上显示正在行驶的车辆。我写的代码为:

  <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://code.google.com/p/gmaps4jsf/" prefix="m"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<META HTTP-EQUIV=" " CONTENT="6">
<title>Insert title here</title>

<script
src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAtRLgopSfFn_inKV4Mb4dwRQrh986W3YN5ROngdOVRv-81htxfBSHsTcVUm4HRkCt9bSp5mP_3_snrw"
type="text/javascript">
</script>

</head>

<body>

<f:view>
    <h:form id="aaaa">
        <h:panelGrid columns="2">
            <m:map id="mp" width="500px" height="500px" latitude="  #{mp3.lat} "
                longitude=" #{mp3.lon}" zoom="15">
                <m:mapControl name="GMapTypeControl" />
                <m:mapControl name="GLargeMapControl"
                    position="G_ANCHOR_BOTTOM_RIGHT" />

                <m:marker id="m" latitude="  #{mp3.lat} " longitude=" #{mp3.lon}">

    <m:htmlInformationWindow htmlText="Start<br>  " />

               <a4j:support event="onchange" action="  " reRender="m"></a4j:support>

                </m:marker>
            </m:map>
        </h:panelGrid>
        <h:commandButton value="Start" action="#{mp3.meth}" />
        <h:commandButton value="Path Map" action="pathmp" />
    </h:form>

</f:view>
</body>
</html>

我的问题是如何在不重新加载所有页面的情况下使用Ajax A4J在Google地图上移动车辆标记?

我使用的技术是-jsf-丰富的面孔-a4j-javaBean

谢谢

jsf richfaces javabeans ajax4jsf
1个回答
0
投票

当然,您不必重新加载页面。相反,您可以使用Ajax从数据库中检索当前位置数据,然后在google map对象上重绘标记。检查一下。 enter link description here

© www.soinside.com 2019 - 2024. All rights reserved.