마커는 내 Db에있는 Google지도의 위도와 경도를 기준으로 표시하려고합니다.Google지도가지도를 표시하지 않고 마커를 표시하지 않습니다.
하지만 내 페이지에는지도가없고 마커가 없습니다.
여기에서 문제가 무엇인지 파악할 수 없습니다.
나는 console.log
마커를 가지고 있습니다. & 그 결과가 있어야하는지 확실하지 않은 개체입니다.
@if (item.Longitude != null)
{
<span class="js-latmaps"> @item.Latitude</span>
<span class="js-longmaps"> @item.Longitude</span>
}
<div id="dvMap" style="width: 500px; height: 500px">
</div>
@section scripts {
<script src="http://maps.google.com/maps/api/js?key=<"LONG_NUMBER">libraries = places"></script>
<script type = "text/javascript">
var markers = [
{
"lat": $('.js-latmaps'),
"lng": $('.js-longmaps')
}
];
console.log(markers);
window.onload = function() {
var mapOptions = {
center: new window.google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 8,
mapTypeId: window.google.maps.MapTypeId.ROADMAP
};
var infoWindow = new window.google.maps.InfoWindow();
var map = new window.google.maps.Map(document.getElementById("dvMap"), mapOptions);
for (var i = 0; i < markers.length; i++) {
var data = markers[i];
var myLatlng = new window.google.maps.LatLng(data.lat, data.lng);
var marker = new window.google.maps.Marker({
position: myLatlng,
map: map
});
(function(marker, data) {
window.google.maps.event.addListener(marker,
"click",
function(e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
};
</script>}
https://jsfiddle.net/9z6t2m3q/
당신은 무엇 콘솔 오류
libraries=places
(공백없이)에 의해 당신의 API_KEY 사이&
및libraries=places
libraries = places
를 추가 할 API_KEY 주위<>
를 제거하려면? –전혀 오류가 없습니다 –
js biddle을 질문에 추가하십시오. –