This is a sample of my code that works on an Android.  Maybe it will help 
you.

// This function makes the map
function InitializeMap(idElement,renderType) {
    var initialLocation;
    var browserSupportFlag =  new Boolean();
    var Location=new Array();
    var idElements = idElement.split("-");
    var thisTour = idElements[1];
    var thisLocation = idElements[3];
    idElement = idElement + '-content';
    $.getJSON('http://tables.googlelabs.com/api/query?sql=SELECT * FROM 
829392 WHERE fkTour = ' + thisTour + ' AND pkLocation = ' + thisLocation + 
'&jsonCallback=?', function(locData) {
        Location[0]=new 
google.maps.LatLng(locData.table.rows[0][9],locData.table.rows[0][10]); // 
Tour Stop Location
        Location[1]=locData.table.rows[0][2]; // Tour Stop Location Name
        Location[2]=locData.table.rows[0][8]; // Street Address
        var myOptions = {
            zoom: 15,
            mapTypeControl: false,
            streetViewControl: false,
            panControl: false,
            zoomControl: false,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var putMap;
        if (renderType == 'map') {
            putMap = document.getElementById(idElement);
        } else {
            putMap = document.getElementById(idElement+'-novis');
        }
        var theMap = new google.maps.Map(putMap, myOptions);
        // Try W3C Geolocation (Preferred)
        if(navigator.geolocation) {
            browserSupportFlag = true;
            navigator.geolocation.getCurrentPosition(function(position) {
                initialLocation = new 
google.maps.LatLng(position.coords.latitude,position.coords.longitude);
                theMap.setCenter(Location[0]);
                // User's Location
                var markerYou = new google.maps.Marker({
                    icon: 'http://localhost/googdata/i/here.png',
                    position: initialLocation, 
                    map: theMap, 
                    title: 'You are here.',
                    visible: true
                });
                var infowindowYou = new google.maps.InfoWindow({
                    content: 'You are here'
                });
                google.maps.event.addListener(markerYou, 'click', function() 
{
                    infowindowYou.open(theMap,markerYou);
                });
                // Tour Location
                var markerTL = new google.maps.Marker({
                    icon: 'http://localhost/googdata/i/1.png',
                    position: Location[0], 
                    map: theMap, 
                    title: Location[1],
                    visible: true
                });
                var InfoWindow = new google.maps.InfoWindow({
                    content: Location[1]
                });
                google.maps.event.addListener(markerTL, 'click', function() 
{
                    InfoWindow.open(theMap,markerTL);
                });
                var directionDisplay;
                var directionsService = new google.maps.DirectionsService();
                var renderingOptions = {
                    suppressMarkers: true,
                    preserveViewport: true
                };
                directionsDisplay = new 
google.maps.DirectionsRenderer(renderingOptions);
                if (renderType == 'map') {
                    directionsDisplay.setMap(theMap);
                    var end = Location[0];
                } else {
                    
directionsDisplay.setPanel(document.getElementById(idElement));
                    var end = Location[2];
                }
                var start = initialLocation;
                var request = {
                    origin: start, 
                    destination: end,
                    travelMode: google.maps.DirectionsTravelMode.WALKING
                };
                directionsService.route(request, function(result, status) {
                    if (status == google.maps.DirectionsStatus.OK) {
                        directionsDisplay.setDirections(result);
                    }
                });
            }, function() {
                handleNoGeolocation(browserSupportFlag);
            });
        // Browser does not support Geolocation
        } else {
            browserSupportFlag = false;
            handleNoGeolocation(browserSupportFlag);
        }
        function handleNoGeolocation(errorFlag) {
            if (errorFlag == true) {
                alert("Geolocation service failed.");
                initialLocation = Location[0];
                var markerTL = new google.maps.Marker({
                    position: Location[0], 
                    map: theMap, 
                    title: Location[1]
                });
                var InfoWindow = new google.maps.InfoWindow({
                    content: Location[1]
                });
                InfoWindow.open(theMap,markerTL);
            } else {
                alert("Your browser does not support geolocation.");
                initialLocation = Location[0];
                var markerTL = new google.maps.Marker({
                    position: Location[0], 
                    map: theMap, 
                    title: Location[1]
                });
                var InfoWindow = new google.maps.InfoWindow({
                    content: Location[1]
                });
                InfoWindow.open(theMap,markerTL);
            }
            theMap.setCenter(initialLocation);
        }
    });
}
$('.mappage').live('pageshow',function(event, ui){
    InitializeMap($(this).attr("id"),'map');
});

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to