hello Sencha friends!
I have a map on my app that shows a route between two locations. The issue is that the map shows mountain view, ca for about a second before loading my custom map
Any advice would be awesome~!!!
Code:
var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Loading..."});
myMask.show();
postcard.setActiveItem(mappanel);
//grab location from record
var getaddress = postdetailcard.data.address;
var getzipcode = postdetailcard.data.zipcode;
var getcity = postdetailcard.data.city;
//geocode address
var address = getaddress +', '+ getcity+', '+ getzipcode;
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
var coord = results[0].geometry.location;
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
directionsDisplay = new google.maps.DirectionsRenderer();
var lat = locationstore.data.items[0].data.latitude;
var lng = locationstore.data.items[0].data.longitude;
var start = lat+','+lng;
var end = coord;
var request = {
origin:start,
destination:end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
var image = 'logo-map-sm.png';
//show marker
var marker = new google.maps.Marker({
map: map,
position: coord,
icon: image
});
var myOptions ={
zoom: 14,
center: coord,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
//creates map
var map = new google.maps.Map(document.getElementById("detailmap"), myOptions);
directionsDisplay.setMap(map);
}
});
myMask.hide();
}
else {
alert("Geocode fail" + status);
myMask.hide();
}
});