Here is my code to get map in map canvas
 
function initialize() {

var myOptions = {

zoom: 7,

mapTypeId: google.maps.MapTypeId.ROADMAP,

center: new google.maps.LatLng(37.4419, -122.1419),

mapTypeControl: true,

mapTypeControlOptions: {

style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,

position: google.maps.ControlPosition.BOTTOM

},

navigationControl: true,

navigationControlOptions: {

style: google.maps.NavigationControlStyle.ZOOM_PAN,

position: google.maps.ControlPosition.TOP_RIGHT

},

scaleControl: true,

scaleControlOptions: {

position: google.maps.ControlPosition.TOP_LEFT

},

provideRouteAlternatives: false

}

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

directionsService = new google.maps.DirectionsService();

directionsDisplay = new google.maps.DirectionsRenderer();

directionsDisplay.setPanel(document.getElementById("directions"));

directionsDisplay.setMap(map);

google.maps.event.addListener(map, 'addoverlay', afterDir);

google.maps.event.addListener(map, "error", handleErrors);

directionsService.route({

origin: "<%=strOrig%>",

destination: "<%=strDest%>",

travelMode: google.maps.DirectionsTravelMode.DRIVING

}, function (result, status) {

if (status == google.maps.DirectionsStatus.OK) {

var route = result.routes[0];

startAddress = route.legs[0].start_address;

endAddress = route.legs[0].end_address;

CheckPBCLimit(route.legs[0].start_address, route.legs[0].start_location);

CheckPBCLimit(route.legs[0].end_address, route.legs[0].end_location);

directionsDisplay.setDirections(result);

lstrDistance = route.legs[0].distance.text;

document.getElementById("distance_road").innerHTML = lstrDistance;

//alert(lstrDistance);

}

});

// GEvent.addListener(gdir, "addoverlay", afterDir);

// google.maps.event.addListener(map, 'addoverlay', afterDir);

// GEvent.addListener(gdir, "error", handleErrors);

// google.maps.event.addListener(map, "error", handleErrors);

// setDirections("<%=strOrig%>", "<%=strDest%>", "en_US");

// calcRoute("<%=strOrig%>", "<%=strDest%>");

}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-maps-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to