Autor Zpráva
Jirka77
Profil
Potreboval bych pomoct od tech co tomu rozumí, protoze v tom plavu....
Mam DB adresy bez GPS, moznost definovat ikony....

Markery se vypisou, ale vsude je stejný text v infoWindows a nemení se ikony.
Do geocoder.geocode se neprenásí ostatní promenné (content, ikon).

Vsem moc dekuji za radu.


Zdroj
https://developers.google.com/maps/articles/phpsqlajax_v3

Data
<markers>
<marker name="Pan Africa Market" adresa="1521 1st Ave, Seattle, WA"  type="restaurant"/>
<marker name="Buddha Thai a Bar" adresa="2222 2nd Ave, Seattle, WA"  type="bar"/>
<marker name="The Melting Pot" adresa="14 Mercer St, Seattle, WA"  type="restaurant"/>
<marker name="Ipanema Grill" adresa="1225 1st Ave, Seattle, WA" type="restaurant"/>
<marker name="Sake House" adresa="2230 1st Ave, Seattle, WA" type="bar"/>
<marker name="Crab Pot" adresa="1301 Alaskan Way, Seattle, WA"  type="restaurant"/>
<marker name="Mama's Mexican Kitchen" adresa="2234 2nd Ave, Seattle, WA"  type="bar"/>
<marker name="Wingdome" adresa="1416 E Olive Way, Seattle, WA" type="bar"/>
<marker name="Piroshky Piroshky" adresa="1908 Pike pl, Seattle, WA"  type="restaurant"/>
</markers>

Script (nemám GPS)
var customIcons = {restaurant: {icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png'}, bar: {icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png'}};
    var geocoder = new google.maps.Geocoder();
    var infoWindow = new google.maps.InfoWindow;
    function load() {
      var map = new google.maps.Map(document.getElementById("map"), {
        center: new google.maps.LatLng(47.6145, -122.3418),
        zoom: 13,
        mapTypeId: 'roadmap'
      });//map
      downloadUrl("data2.xml", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var adresa = markers[i].getAttribute("adresa");
            var type = markers[i].getAttribute("type");
            var content = '<b>' + name + '</b> <br/>' + adresa + '';            
            var icon = customIcons[type] || {};    
            
            geocoder.geocode( { 'address': adresa }, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) { 
                  var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location,
                    icon: icon.icon
                  });
              }
              bindInfoWindow(marker, map, infoWindow, content);
           });
           
        }
      });
    }
    
    
    function bindInfoWindow(marker, map, infoWindow, content) {
      google.maps.event.addListener(marker, 'click', function() {
        infoWindow.setContent(content);
        infoWindow.open(map, marker);
      });
    }
    
    function downloadUrl(url, callback) {
      var request = window.ActiveXObject ?
          new ActiveXObject('Microsoft.XMLHTTP') :
          new XMLHttpRequest;

      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          request.onreadystatechange = doNothing;
          callback(request, request.status);
        }
      };

      request.open('GET', url, true);
      request.send(null);
    }
        
    function doNothing() {}

Vaše odpověď

Mohlo by se hodit

Neumíte-li správně určit příčinu chyby, vkládejte odkazy na živé ukázky.
Užíváte-li nějakou cizí knihovnu, ukažte odpovídajícím, kde jste ji vzali.

Užitečné odkazy:

Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: