var Overlays= []
//var Overlay;
function get_overlay_image(_ne, _sw){
var imageBounds = {
north: _ne.lat(),
south: _sw.lat(),
east: _ne.lng(),
west: _sw.lng()
};
var export_bbox = _sw.lng() + ',' + _sw.lat() + ',' + _ne.lng() + ',' + _ne.lat();
var url_param = '&format=png&transparent=true&f=image&bboxSR=4326&imageSR=4326';
var _width = map.getDiv().offsetWidth;
var _height = map.getDiv().offsetHeight;
var _size = '&size='+ _width + ',' + _height
var _layers ='&layers=show:0,340'
//var root_url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export?bbox=';
//var root_url = 'https://maps2.dcgis.dc.gov/dcgis/rest/services/Zoning/MapServer/export?bbox=';
var root_url = 'https://maps.lacity.org/arcgis/rest/services/Mapping/NavigateLA/MapServer/export?bbox=';
var image_url = root_url + export_bbox + url_param + _size + _layers;
// delete remove all overlay in overlays array.
while(Overlays[0])
{
Overlays.pop().setMap(null);
}
var Overlay = new google.maps.GroundOverlay(
image_url,
imageBounds);
Overlay.setOpacity(0.5)
Overlay.setMap(map);
// push new overlay into overlays array
Overlays.push(Overlay);
}
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
mapTypeId: google.maps.MapTypeId.HYBRID,
// center: {lat: 38.907292, lng: -77.036420} //washington
center: {lat: 34.049039, lng: -118.246521}
});
google.maps.event.addListener(map, 'idle', function() {
var bounds = map.getBounds();
var ne = bounds.getNorthEast();
var sw = bounds.getSouthWest();
console.log(ne.lat());
console.log(ne.lng());
console.log(sw.lat());
console.log(sw.lng());
get_overlay_image(ne, sw);
});
}// initMap
No comments:
Post a Comment