-1

HTMLページでajaxを使用してgmapを読み込もうとしていますが、機能しません

index.html

<head>    
<script type="text/javascript">      
function load_pages(url) {         
$('#project').html('<p><img src="../images/loader/ajax-loader1.gif" width="100"     height="19" style="margin: 30% auto 0px 30%;"/></p>');                   
$('#project').load(url, "",           
function(responseText, textStatus, XMLHttpRequest) {              
if (textStatus === 'error') {                    
$('#project').html('<p style="margin: 30% auto 0 30%;">Unable to load the content...</p>');               
}            
});       
}
</script>
</head>

<body>
<div id="project">
<a href="javascript:void 0" onclick="load_pages('project-1/location.html');">Location</a>
<p>Here Map Should be load</p>
</div>
</body>

Location.html はこちら

<div class="map">
<center>                                            
<div id="bd"></div>                                            
<div id="gmap" class="roundtext"></div>                                        
</center> 
</div>

<!-- Map -->                            
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>                            
<script src="../js/map.js"></script>                            
<!-- Map End -->

そして、これが私のlocation.htmlの下部で使用したmap.jsで、index.htmlでも試しました

var map;
var marker = false;
function initialize() {
    var mLati = 18.546821;
    var mLongi = 73.935998;
    var myLatlng = new google.maps.LatLng(mLati, mLongi);
    var myOptions = {
        zoom: 19,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("gmap"), myOptions);

    marker = new google.maps.Marker({
        position: myLatlng,
        map: map
    });

    google.maps.event.addListener(map, 'center_changed', function() {
        var location = map.getCenter();
        document.getElementById("lat").innerHTML = location.lat();
        document.getElementById("lon").innerHTML = location.lng();
        document.getElementById("frmLat").value = location.lat();
        document.getElementById("frmLon").value = location.lng();
        placeMarker(location);
    });

    google.maps.event.addListener(map, 'zoom_changed', function() {
        zoomLevel = map.getZoom();
        document.getElementById("zoom_level").innerHTML = zoomLevel;
    });

    google.maps.event.addListener(marker, 'dblclick', function() {
        zoomLevel = map.getZoom() + 1;
        if (zoomLevel == 20) {
            zoomLevel = 10;
        }
        document.getElementById("zoom_level").innerHTML = zoomLevel;
        map.setZoom(zoomLevel);
    });

    document.getElementById("zoom_level").innerHTML = 11;
    document.getElementById("lat").innerHTML = 18.546821;
    document.getElementById("lon").innerHTML = 73.935998;
}

function placeMarker(location) {
    var clickedLocation = new google.maps.LatLng(location);
    marker.setPosition(location);
}

window.onload = function() {
    initialize();
};

この問題を解決するために私を助けてください

4

2 に答える 2

0

Location.html 内

あなたが持っている:

<div class="map>

二重引用符がありません:

<div class="map">
于 2013-10-15T05:33:53.670 に答える