请帮我纠正java脚本,在地图上加载gps cordinates [英] please help me to correct the java script to load gps cordinates on map
本文介绍了请帮我纠正java脚本,在地图上加载gps cordinates的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在地图上点击鼠标时,我可以在地图上标记一个点但是当它通过js加载时它会卡住并冻结
我的目标是标记gps cordinates动态
< html>
When i mouse click on the maps i can mark a point on map but when it loads through js it stuck and freeze
my aim is to mark gps cordinates dynamically
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="js/jquery-1.4.4.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=geometry" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
</head>
<body>
<script>
var i=0;
var enb=0;
var wickedLocation;
var auto_refresh = setInterval(
function()
{
$.get("buslocationget.php", function(data)
{
//alert("Data Loaded: " + data);
var n=data.split("^");
document.body.innerHTML=document.body.innerHTML+n+"<br>";
wickedLocation = new google.maps.LatLng(n[0], n[1]);
measureAdd(wickedLocation);
}
);
}, 5000);
</script>
<div class="google-maps" id="map" style="height: 400px; position: relative; border: 1px solid #CCC;"></div>
<script>jQuery.noConflict();</script>
<script type="text/javascript">
var map;
map = new google.maps.Map(document.getElementById("map"), {
zoom: 25,
center: new google.maps.LatLng(8.897171, 76.643563),
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggableCursor: "crosshair" // Make the map cursor a crosshair so the user thinks they should click something
});
google.maps.event.addListener(map, "click", function(evt) {
// When the map is clicked, pass the LatLng obect to the measureAdd function
measureAdd(evt.latLng);
});
function measureAdd(latLng) {
// Add a draggable marker to the map where the user clicked
var marker = new google.maps.Marker({
map: map,
position: latLng,
draggable: true,
raiseOnDrag: false,
title: "Drag me to change shape",
icon: new google.maps.MarkerImage("images/measure-vertex.png", new google.maps.Size(9, 9), new google.maps.Point(0, 0), new google.maps.Point(5, 5))
});
}
</script>
</body>
< / html>
</html>
推荐答案
.get(buslocationget。 php,function(data)
{
// alert(Data Loaded:+ data);
var n = data.split(^ );
document.body.innerHTML = document.body.innerHTML + n +< br > ;
wickedLocation = new google.maps.LatLng(n [0],n [1] );
measureAdd(wickedLocation);
}
);
},5000);
< / script >
< div class = google-maps id < span class =code-keyword> = map style = height:400px; position:relative; border:1px solid #CCC ; > < / div >
< 跨度>script > jQuery.noConflict(); < / script >
< script type = text / javascript >
var map;
map = new google.maps.Map(document.getElementById(map),{
zoom:25,
center:new google.maps.LatLng(8.897171, 76.643563),
mapTypeId:google.maps.MapTypeId.ROADMAP,
draggableCursor:crosshair//使地图光标成为十字准线,以便用户认为他们应该点击某些内容
});
google.maps.event.addListener(map,click,function(evt){
//点击地图后,将LatLng对象传递给measureAdd函数
measureAdd(evt.latLng);
});
函数measureAdd(latLng){
//向用户点击的地图添加一个可拖动的标记
var marker = new google.maps.Marker({
map:map,
position:latLng,
draggable:true,
raiseOnDrag:false,
title:拖我到改变形状,
icon:new google.maps.MarkerImage(images / measure-vertex.png,new google.maps.Size(9,9),new google.maps.Point(0,0) ,new google.maps.Point(5,5))
});
}
< / script >
< / body >
.get("buslocationget.php", function(data) { //alert("Data Loaded: " + data); var n=data.split("^"); document.body.innerHTML=document.body.innerHTML+n+"<br>"; wickedLocation = new google.maps.LatLng(n[0], n[1]); measureAdd(wickedLocation); } ); }, 5000); </script> <div class="google-maps" id="map" style="height: 400px; position: relative; border: 1px solid #CCC;"></div> <script>jQuery.noConflict();</script> <script type="text/javascript"> var map; map = new google.maps.Map(document.getElementById("map"), { zoom: 25, center: new google.maps.LatLng(8.897171, 76.643563), mapTypeId: google.maps.MapTypeId.ROADMAP, draggableCursor: "crosshair" // Make the map cursor a crosshair so the user thinks they should click something }); google.maps.event.addListener(map, "click", function(evt) { // When the map is clicked, pass the LatLng obect to the measureAdd function measureAdd(evt.latLng); }); function measureAdd(latLng) { // Add a draggable marker to the map where the user clicked var marker = new google.maps.Marker({ map: map, position: latLng, draggable: true, raiseOnDrag: false, title: "Drag me to change shape", icon: new google.maps.MarkerImage("images/measure-vertex.png", new google.maps.Size(9, 9), new google.maps.Point(0, 0), new google.maps.Point(5, 5)) }); } </script> </body>
< / html>
</html>
这篇关于请帮我纠正java脚本,在地图上加载gps cordinates的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文