gpt4 book ai didi

javascript - 用于实时跟踪的 ESRI javascript API

转载 作者:行者123 更新时间:2023-11-30 11:38:11 25 4
gpt4 key购买 nike

我正在尝试使用 ESRI ArcGIS javascript API 实现实时跟踪功能。我无法根据从数据库中检索到的纬度、经度移动标记。为了清楚起见,这是我们为此目的使用 Google map 的现有代码。如何使用 ESRI arcGIS javascript API 实现同样的目标?

<script type="text/javascript">

var marker, map, ct=0, geocoder ;
function initialize() {
var myLatlng = new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng; ?>);
var mapOptions = {
zoom: 14,
maxZoom: 16,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById('main-map'), mapOptions);
geocoder = new google.maps.Geocoder();


var image = new google.maps.MarkerImage(
'assets/images/marker-images/image.png',
new google.maps.Size(20,21),
new google.maps.Point(0,0),
new google.maps.Point(10,21)
);


marker = new google.maps.Marker({
position: myLatlng,
map: map,
icon: image,
title: 'I might be here'
});

}


///////////////////////////////////////////////////

$(function() {
initialize();
live();
setInterval( live , 10000);
});

function live() {
var duration = 10000;

$.ajax({

type: "GET",
url: "otravels_ajax/getlivedata.php?vid=<?php echo $imei; ?>",
dataType: 'xml',
async:false,
success: function(xml) {
$(xml).find("marker").each(function(){

var id = $(this).find('id').text(); lid=id; //alert(lid);
var lat = $(this).find('lat').text();
var lng = $(this).find('lng').text();
var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));//console.log(point);

var ts = $(this).find('ts').text();//alert(ts);
var speed = $(this).find('speed').text();
var status = $(this).find('status').text();
if(status=='A') status="<span class='label label-success '>Active</span>"; else status="<span class='label label-important '>InActive</span>";
var loc_addr = $(this).find('loc').text();
var img=$(this).find('img').text();

var image = new google.maps.MarkerImage(
img,
new google.maps.Size(46,42),
new google.maps.Point(0,0),
new google.maps.Point(23,42)
);
marker.setIcon(image);
marker.animateTo(point, {easing: 'linear', duration: duration});

if(!map.getBounds().contains(point))
map.panTo(point);

// $('#live_data').html("<tr><td>"+ts+"</td><td>"+speed+"KM/HR</td><td>"+status+"</td><td id=\"loc\">"+loc_addr+"</td></tr>");

$("#d_time").html(ts);
$("#d_speed").html(speed+"KM/HR");
$("#d_status").html(status);



geocoder.geocode({
"latLng":point
}, function (results, status) { // alert("fgb");
if (status == google.maps.GeocoderStatus.OK) {
var placeName = results[1].formatted_address; //alert(placeName);
$("#loc").html(placeName);
}
});


});
}
});

}


</script>

最佳答案

关于javascript - 用于实时跟踪的 ESRI javascript API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43626197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com