Google Maps API v3 işaretçileri yenileniyor

0 Cevap php

Ben Google Maps API V3 ile ilgili sorunlar yaşıyorum. Bu benim sayfasını (belirteçleri dahil) haritalar yük yüklemek ve her zaman daha sonra hızlı bir yeniden yükleme yapar ve tüm işaretleri kaldırır gibi görünüyor. Ben bir şey eksik? Ben yanlış ne yapıyorum?

Here is an example: http://www.PaulPeelen.com/wp-content/uploads/2010/04/SafariScreenSnapz001.mov

Bu benim kod:

<script type="text/javascript">
<!--
var hash = "{{$sHashLocal}}";
var webroot = "{{$webroot}}";
var map;

function initialize() {
    var latlng = new google.maps.LatLng(59.32045, 18.066902);
    var myOptions = {
      zoom: 13,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    return map;
}

function getMarkerInfo (infowindow, rack_id)
{
    // Get all the racks
    $.ajax({
        type: "GET",
        url: webroot+"ajax/getRack/"+hash+"/"+rack_id,
        cache: false,
        dataType: "html",
        success: function(html) {
            $("#rack_"+rack_id).html();

            infowindow.setContent(html);
        }
    });
}

$(document).ready(function () {
map = initialize();



function attachSecretMessage(marker, rack_id) {
    var infowindow = new google.maps.InfoWindow({
        size: new google.maps.Size(50,50)
    });

    google.maps.event.addListener(marker, 'click', function(){
        var ret = '<div id="rack_'+rack_id+'" class="rackDiv"><div class="rackDivLoading"><img src="theme/images/loader-small.gif" border="0"/><span>Hämtar data</span></div></div>';
        infowindow.setContent(ret);
        infowindow.open(map,marker);

        getMarkerInfo(infowindow,rack_id);
    });
}

function addPlacemark (lat,lng,title, rack_id) {
    var image = new google.maps.MarkerImage('http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png',
              new google.maps.Size(32, 32),
              new google.maps.Point(0,0),
              new google.maps.Point(0, 32));
    var shadow = new google.maps.MarkerImage('http://maps.google.com/mapfiles/shadow50.png',
              new google.maps.Size(37, 34),
              new google.maps.Point(0,0),
              new google.maps.Point(-4, 34));

    var location    = new google.maps.LatLng(lat,lng);
    var marker      = new google.maps.Marker({
                        position: location, 
                        map: map,
                        icon: image,
                        shadow: shadow});


    marker.setTitle(title);

    attachSecretMessage(marker, rack_id);
}

// Get all the racks
$.ajax({
    type: "GET",
    url: webroot+"ajax/getRacks/"+hash,
    cache: false,
    dataType: "xml",
    success: function(xml) {
        // Add the results
        $(xml).find("station").each(function () {
            rack_id = $(this).find("rack_id").text();
            title = $(this).find("description").text();
            longitute = parseFloat($(this).find("longitute").text());
            latitude = parseFloat($(this).find("latitude").text());

            addPlacemark(latitude, longitute, title, rack_id);
        });
    }
});

$("#addMark").click(function () {

    addPlacemark (59.32045, 18.066902);
});

// Set size
setPageSize();
});
//-->
</script>

0 Cevap