This is my code : i have two textboxes and getdirection button when i enter 
name of the cities in textboxes and press getdirection button it will show 
me the direction between two place. i can also drag my marker from one 
place to another. what i want is when i drag my marker to another position 
my textbox text will also change with it and show me the place where i put 
my marker.

var map = null;
        function initialize() {
            var myLatlng = new google.maps.LatLng(25.263327, 55.329895);
            var myOptions = {
                zoom: 10,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var map = new 
google.maps.Map(document.getElementById("map_canvas"), myOptions);

            var marker;

            function placeMarker(location) {
                if (marker) {
                    marker.setPosition(location);
                } else {
                    marker = new google.maps.Marker({
                        position: location,
                        map: map
                    });
                }
            }

            google.maps.event.addListener(map, 'click', function (event) {
                placeMarker(event.latLng);
                document.getElementById("latFld").value = 
event.latLng.lat();
                document.getElementById("lngFld").value = 
event.latLng.lng();
            });


        }

        $(document).ready(function () {

            $("#accordion").bind('accordionchange', function (event, ui) {
                if (ui.newContent.attr('id') == 'tabThree' && !map) {
                    map = initialize();
                }
            });
        });
        function calcRoute() {
            var start = document.getElementById('startvalue').value;
            var end = document.getElementById('endvalue').value;
            var request = {
                origin: start,
                destination: end,

                travelMode: google.maps.TravelMode.DRIVING
            };
            directionsService.route(request, function (response, status) {
                if (status == google.maps.DirectionsStatus.OK) {
                    directionsDisplay.setDirections(response);
                }
            });
        }
    </script>
</head>
<body onload="initialize()" onunload="Gunload()">
    <form id="form1" runat="server">
    <input id ='latFld' onkeyup='updatePosition()'/><br />
    <input id ='lngFld' onkeyup='updatePosition()'/><br />
     <input type="button" id="Button1" value="GetDirection" 
onclick="calcRoute();" /> 
    <div id="map_canvas" style="width:777px; height:329px; margin-bottom: 
0px;"/>
    </form>
</body>
</html>

-- 
You received this message because you are subscribed to the Google Groups 
"iGoogle Developer Forum" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/Google-Gadgets-API/-/YQgeQTS3TNAJ.
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-Gadgets-API?hl=en.

Reply via email to