1
我使用Google地图API开发了地图。标记以正确的标签显示。但是我怎样才能在多个标记之间绘制路线。我很困惑,任何人都可以帮忙?如何使用javascript在Google地图中的多个标记之间绘制路线图
谷歌地图的图像:
JS文件代码如下(userhistory.js)
var \t marker = [];
\t \t \t \t \t \t $("#map").show();
\t \t \t \t \t map = new google.maps.Map(document.getElementById('map'), {
\t \t \t \t \t \t zoom: 10,
\t \t \t \t \t center: new google.maps.LatLng(17.7254567, 83.3097112),
\t \t \t \t \t mapTypeId: google.maps.MapTypeId.ROADMAP
\t \t \t \t \t });
\t \t \t \t \t directionsDisplay.setMap(map);
\t \t \t var infowindow = new google.maps.InfoWindow();
\t \t \t var i;
\t \t \t \t
\t \t \t for (i = 0; i < response.length; i++) {
\t \t \t \t
\t \t \t \t marker = new google.maps.Marker({
\t \t \t position: new google.maps.LatLng(response[i].latitude, response[i].longitude),
\t \t \t map: map,
\t \t \t label: response[i].count
\t \t \t \t });
\t \t \t \t google.maps.event.addListener(marker, 'click', (function(marker, i) {
\t \t \t return function() {
\t \t \t infowindow.setContent("Name :"+response[i].name+","+"<br>"+"Date & Time :"+response[i].date+", "+response[i].time+","+"<br>"+"Location :"+response[i].address);
\t \t \t infowindow.open(map, marker);
\t \t \t }
\t \t \t })(marker, i));
\t \t \t }
谢谢你的答复。我试过老板。这不是我想的正确答案。 –
请尝试遵循脚本[此处](https://stackoverflow.com/a/37393954/4507810)。 – eNVy
我已根据您的代码更新了答案。 – eNVy