My code:


var map;
var poly;
var points = new Array();
var markers = new Array();
var comments = new Array();
var geocoder = new GClientGeocoder();
var mid = 0;


/*
  * Tworzenie mapy
  * Ladowanie punktów dla modulu edycji i widoku
*/
function buildMap() {

        map = new GMap2(document.getElementById('map'),
{draggableCursor:"auto", draggingCursor:"move"});
        map.setCenter(new GLatLng(cLat, cLng), zoom);

        map.disableDoubleClickZoom();
        map.addControl(new GLargeMapControl());
        map.addControl(new GScaleControl());

        map.addMapType(G_PHYSICAL_MAP);

        var hierarchy = new GHierarchicalMapTypeControl();
        hierarchy.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Etykiety",
true);
        map.addControl(hierarchy);



        if ( mode == 'edit' || mode == 'new' ) {

                GEvent.addListener(map, "click", leftClick);
        }


        // jezeli tryb edycji lub "patrzenia" ladujemy gotowe dane
(wspólrzedne) na mape
        if ( mode == 'edit' || mode == 'viev' ) {

                for ( var i=0; i<oldPoints.length; i++ ) {

                        p = new GLatLng(oldPoints[i][0], oldPoints[i][1]);
                        points.push(p);

                        // jezeli tryb edycji pokazujemy markery
                        if ( mode == 'edit' ) {

                                if ( i == 0 )
                                        var icon = getIcon('start');

                                else if ( i == oldPoints.length-1 )
                                        var icon = getIcon('end');

                                else
                                        var icon = '';

                                var marker = new GMarker(p, {icon:icon, 
draggable:true,
bouncy:false, dragCrossMove:true});
                                marker.value = mid++;
                                comments[marker.value] = oldPoints[i][2];
                                map.addOverlay(marker);
                                markers.push(marker);


                                GEvent.addListener(marker, "dragend", 
function() {
                                        drawOverlay();
                                });

                                if ( i == oldPoints.length-1 )
                                        deleteEvent(marker, 1);

                                else
                                        deleteEvent(marker);
                        }

                        drawOverlay();
                }

                drawOverlay();
        }
}



/*
  * Dodaje GEvent (addListener) do markera
  * Klikniecie w marker = jego usuniecie
*/
function deleteEvent(marker, ended) {

        GEvent.addListener(marker, "click", function() {

                commentVal = ( comments[marker.value] == 'undefined' ) ? ' ' :
comments[marker.value];

                marker.openInfoWindowHtml('<div style="float:left; width:60px; 
text-
align:left;">'+
                                                                  '<a 
onclick="deletePoint(\''+marker.value+'\', \''+ended
+'\'); return false;">'+
                                                                  '<img 
src="'+icon_url+'icons/routepointDelete.png"
border="0" /></a></div>'+
                                                                  '<div 
style="float:left; width:200px; text-align:left;">'+
                                                                  '<input 
type="text" style="width:100px;"
class="info'+marker.value+'" value="'+commentVal+'">'+
                                                                  '<input 
type="button" onclick="saveComment(\''+marker.value
+'\')" value="Zapisz"></div>');

        });
}


function saveComment(mid) {

        comment = $('.info'+mid).val();
        comments[mid] = comment;

        for ( var i=0; i<markers.length; i++ ) {

                if ( markers[i].value == mid )
                        markers[i].closeInfoWindow();
        }
}



function deletePoint(mid, ended) {

        for ( var n = 0; n < markers.length; n++ ) {

                if(markers[n].value == mid) {

                        if ( n == 0 )
                                alert('Nie mozesz usunac punktu startowego.');

                        else
                                map.removeOverlay(markers[n]);

                        break;
                }
        }


        if ( ended == 1 )
                end = 0;

        if ( n != 0 )
                markers.splice(n, 1);

        drawOverlay();
}



/*
  * Dodanie nowego markera
*/
function leftClick(overlay, p, ended) {

        if ( p ) {

                if ( end == 1 )
                        alert('Trasa zostala zakonczona.');

                else {

                        if ( ended ) {

                                var icon = getIcon('end');
                                end = 1;

                        } else if ( points.length == 0 )
                                var icon = getIcon('start');


                        var marker = new GMarker(p, {icon:icon, draggable:true,
bouncy:false, dragCrossMove:true});
                        marker.value = mid++;
                        comments[marker.value] = 'Punkt';
                        map.addOverlay(marker);
                        markers.push(marker);


                        GEvent.addListener(marker, "dragend", function() {
                                drawOverlay();
                        });

                        deleteEvent(marker, ended);

                        drawOverlay();
                }
        }
}



function getIcon(type) {

        var icon = new GIcon();

        if ( type == 'start' )
                ico = 'markerStart.png';

        else if ( type == 'end' )
                ico = 'markerEnd.png';

        icon.image = icon_url + ico;
        icon.iconSize = new GSize(20, 34);
        icon.shadow = icon_url + 'mm_20_shadow.png';
        icon.shadowSize = new GSize(35, 35);
        icon.iconAnchor = new GPoint(10, 35);
        icon.infoWindowAnchor = new GPoint(5, 1);

        return icon;
}



/*
  * Rysowanie trasy
*/
function drawOverlay(){

        if (poly)
                map.removeOverlay(poly);


        if ( mode == 'edit' || mode == 'new' ) {

                points.length = 0;

                for( pnts = 0; pnts < markers.length; pnts++ )
                        points.push(markers[pnts].getLatLng());
        }


        poly = new GPolyline(points, lineColor, lineWeight, lineOpacity);
        poly.show();

        var length = poly.getLength()/1000;
        $('.totalLength').val(length.toFixed(3));
        $('.totalLength2').text(length.toFixed(3));

        map.addOverlay(poly);
}

[...]

On 2 Maj, 16:16, "[email protected]" <[email protected]> wrote:
> Hello all,
> I have problem with gpolyline and zoom.
> When I draw polyline all good, but when i viev map with polylines and
> I zoom map much polylines are disappear...
>
> Example working:http://www.dodaj.portalm.pl/files/3124127372912.jpg
>
> ...and not working:http://www.dodaj.portalm.pl/files/5124127374222.jpg
>
> Can anyone help me? ;-(

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to