Problem with showing of addresses - not all the addresses are showed

22 views
Skip to first unread message

Lukes

unread,
May 25, 2011, 6:55:57 PM5/25/11
to google-map...@googlegroups.com
Hello,
I'm trying to show addresses on the map, but not all the addresses are showed. My code looks as follows:
   
    var map = null;
    var geocoder = null;
    bounds = new GLatLngBounds;

    function createMarker(point, contentMoved, contentClicked, scale, present)
    {
        var ico = new GIcon(G_DEFAULT_ICON);
        if(present > 0) ico.image = "./img/puppet_green.png";
        else ico.image = "./img/puppet.png";

        markerOptions = { icon:ico };
        map.setCenter(point, scale);
        var marker = new GMarker(point, markerOptions);

        GEvent.addListener(marker, "click", function()
        {
            if(contentMoved != "") marker.openInfoWindowHtml(contentClicked);
        });

        GEvent.addListener(marker, "mouseover", function()
        {
            if(contentMoved != "") marker.openInfoWindowHtml(contentClicked);
        });
       
        return marker;
    }


    function showAddress(address, contentMoved, contentClicked, scale, present)
    {
        geocoder.getLatLng(
            address, function(point)
            {
                        if(point)
                        {
                            bounds.extend(point);
                            map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));

                            map.addOverlay(createMarker(point, contentMoved, contentClicked, scale, present));
                        }
           }
        );
    }
   
   
    function initialize()
    {
        map = new GMap2(document.getElementById("map_canvas"));
        geocoder = new GClientGeocoder();
        map.setUIToDefault();
       
        <?php
        foreach($dataArray as $currCity)
        {
            ...
            ...
            ...
            ?>
            showAddress('<?php echo $currCityArray[0] ?>', '<?php echo $stringMove ?>', '<?php echo $stringClick ?>', 5, <?php echo $sh ?>);
            <?php
        }
        ?>
    }


So I'm generating the calls of showAddress function using PHP for loop. Problem is if I generate a lot of addresses, e.g. 30. About 10 addresses are showed correctly but the rest not. Addresses are correct - if I skip first 10 addresses, further 10 addresses are showed correctly.

So I'm a bit confused. Where could be a problem, please? Thanks a lot, Lukes.

geoco...@gmail.com

unread,
May 25, 2011, 7:14:12 PM5/25/11
to Google Maps JavaScript API v3
On May 25, 3:55 pm, Lukes <lk.ko...@gmail.com> wrote:
> Hello,
> I'm trying to show addresses on the map, but not all the addresses are
> showed. My code looks as follows:
>


>
> So I'm generating the calls of showAddress function using PHP for loop.
> Problem is if I generate a lot of addresses, e.g. 30. About 10 addresses are
> showed correctly but the rest not. Addresses are correct - if I skip first
> 10 addresses, further 10 addresses are showed correctly.
>
> So I'm a bit confused. Where could be a problem, please? Thanks a lot,
> Lukes.

Don't geocode known addresses every time your page loads. Geocode
them offline, save the results an use the coordinates to display the
markers.

See this from the "Articles" section of the documentation:
Geocoding Strategies
An overview of different strategies you can use for making sure
you stay within the Google Maps API geocoding limits. This is a good
article to read if you find you are frequently running into the quota
limits of the Maps API Geocoders.

http://code.google.com/apis/maps/articles/geocodestrat.html


-- Larry
Reply all
Reply to author
Forward
0 new messages