views:

58

answers:

1

Hello!

I have the problem about geocoder! I have 20 address and my map shows me only 11 points!

I know about “delay” and “setTimeout”, but I don’t know how use it.

I found answer about it on this page - http://stackoverflow.com/questions/2899506/loading-city-state-from-sql-server-to-google-maps

Where wrote about setTimeout (Call the geocoder with a 100ms delay), but I don’t know how use this code in my code! Please help, about 2 weeks I can’t do it!!! In my code, also, I use markerclusterer v3. It’s work. showAddress – it’s Russian address. I need Only setTimeout geocoder, help! This map I use in Oracle BI. Thanks!

Best regards, Vasily.

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;
</script>
<script src="http://www.google.com/jsapi"&gt;&lt;/script&gt; 
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js"&gt;&lt;/script&gt;
<script type="text/javascript">
    var geocoder;
    var markers = [];
    var map;



    function initialize() {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(55.02940345314003, 82.919938);
        var myOptions = {
            zoom: 3,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP


        }
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        GetMapAdress ();

        setTimeout(createCluster, 2000);


    }

    function createCluster() 
    {
        var markerCluster = new MarkerClusterer(map, markers);
    }

    function showAddress(address, comment) {
        if (geocoder) {

            geocoder.geocode( { 'address': address}, function(results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    //map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location,
                        title: 'bla bla'
                    });
                    markers.push(marker);
                    var infowindow = new google.maps.InfoWindow({
                        content:comment
                    });

                    google.maps.event.addListener(marker, 'click', function() {
                        infowindow.open(map,marker);
                    });        
                } 

                else {
                //alert("Mistake: " + status);
                }

            });
        }
    }

    function GetMapAdress () {
      showAddress('Новосибирск, Красный проспект, 66', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 70', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 76', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 77', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 86', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 88', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 99', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 94', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 98', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 87', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 101', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 168', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 157', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 52', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 33', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 40', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 23', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 32', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
      showAddress('Новосибирск, Красный проспект, 13', 'Тут необходимая инфа <span style="font-weight: bold">Очень нужная инфа</span>');
   }
</script>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready( function(){initialize();return true;});
</script>

<body>
<div id="map_canvas" style="width: 900px; height: 500px; border: 3px solid orange" > </div>
</body>
+1  A: 

In this specific case, the issue seems to be that several of the addresses you are trying to encode simply don't exist.

Novosibirsk's Krasnyy Prospekt doesn't have any addresses in the range between 100 and 155 (but does have an 184). You can see this by looking at the house numbers here.

You can recognize this in the Google Maps Front-end by how the search result is named. If it is Krasnyy Prospekt without the number you searched for, it found the road but not the address. If the number is in the search result, it did find the complete address.

Pekka
Thanks for answer!
Riedel
But my address in my code are correctly - house №66, 70, 101, 168 and so on! But my error in geocode - It receives quickly too addresses and cuts! Г must use setTimeout, but don't know how to use it:(
Riedel
In this page: http://stackoverflow.com/questions/2899506/loading-city-state-from-sql-server-to-google-maps
Riedel
I showed about setTimeout, but i don't understand:(
Riedel
Also I use also other addresses, somewhere 100 which exist, but also 11 points are deduced only, it as though takes the first 11 and puts, and then gives out error Over Query Limit if to deduce alert in my code which disappears behind the comment
Riedel
@Riedel I see. Well in the answer you link to, there is an example on how to do an address request with pauses in between, why not use that?
Pekka
I simply don't know as to use "index++; if (locations.length > index) { setTimeout(geocoderFunction, 100);" in my code, I can not correctly introduce
Riedel
Help, Pekka, to insert a delay into my code, and I then will try to penetrate and understand! Thanks!
Riedel
@Riedel sorry, I can't delve into both the codes that deeply right now. What I would do is copy that other code 1:1 and work based on that...
Pekka
The matter is that I can't reconstruct on another the code because I use it in Oracle BI, on another it is impossible! But all the same thanks that have responded!
Riedel