Gmap3-Jquery plugin을 사용하여 웹 응용 프로그램 중 하나에서 Google지도를 생성합니다. 현재 로컬 드라이브에 Google API을 다운로드하고 HTML 페이지에서이 드라이브를 사용합니다.얼마 후 Google API 3이 만료됩니다.
그러나 모든 작업이 정상적으로 작동하지만 3-4 일 후에 Google API가 작동을 멈 춥니 다. 내 로컬 드라이브에 동일한 링크에서 신선한 Google API를 다운로드하면 모든 것이 정상적으로 작동합니다. 그런 문제의 원인은 무엇일까요? API 키 때문입니까? 아니면 내 로컬 드라이브에 다운로드하여 로컬에서 참조하기 때문에입니까?
하지만 API 키가 필요없는 Google지도 API3을 다운로드 중입니다.
<script src="/site_media/js/google-map.js" type="text/javascript"></script>
<script type="text/javascript" src="/site_media/js/gmap3.js"></script>
<script type="text/javascript">
$(function(){
$('#facility_map').gmap3(
{
action:'init',
options:{
center:[26.327475, 50.20134],
zoom: 18,
mapTypeId: google.maps.MapTypeId.HYBRID
}
},
{
action:'getRoute',
options:{
origin:['26.327475', '50.20134'],
destination:['{{facility.latitude}}', '{{facility.longitude}}'],
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
callback: function(results)
{
if (!results) return;
$(this).gmap3(
{
action:'addDirectionsRenderer',
options:{
preserveViewport: true,
directions:results
}
});
}
},
{
action:'getDistance',
options:{
origins:[['26.327475', '50.20134']],
destinations:[['{{facility.latitude}}', '{{facility.longitude}}']],
travelMode: google.maps.TravelMode.DRIVING
},
callback: function(results)
{
var html = '';
if (results)
{
for (var i = 0; i < results.rows.length; i++)
{
var elements = results.rows[i].elements;
for(var j=0; j<elements.length; j++)
{
switch(elements[j].status)
{
case google.maps.DistanceMatrixStatus.OK:
html += results.destinationAddresses[j]+" -<b> "+elements[j].distance.text + ' (' + elements[j].duration.text + '</b>)<br />';
break;
case google.maps.DistanceMatrixStatus.NOT_FOUND:
html += 'The origin and/or destination of this pairing could not be geocoded<br />';
break;
case google.maps.DistanceMatrixStatus.ZERO_RESULTS:
html += 'No route could be found between the origin and destination.<br />';
break;
}
}
}
}
else
{
html = 'error';
}
$('#distance_msg').html("Distance From Rezayat Head Office Khobar to "+html);
}
}
);
});
</script>
지도 API를 부트 스트랩 파일은 특별히이를 방지하기 위해 모든 너무 많은 시간을 무효화 코드가 포함되어 있습니다. –
@Chand Killingsworth :지도 API를 외부에서 참조해야합니까? 로컬 드라이브에서 참조하는 대신 URL을 통해? – Asif
예, 외부에서 참조해야합니다. – JohnnyCoder