//EnvNavi: 03, Navi:, S: var isT = false; var G_SATELLITE_MAP = google.maps.MapTypeId.HYBRID; var G_NORMAL_MAP = google.maps.MapTypeId.ROADMAP; var G_MAP_MARKER_MOUSE_TARGET_PANE = 0; GLatLng.prototype = new google.maps.LatLng(); function GLatLng(lat, lng){ google.maps.LatLng.call(this, lat, lng); } GMarker.prototype = new google.maps.Marker(); function GMarker(pos){ google.maps.Marker.call(this, {position:pos}); this.setLatLng = function(pos){ this.setPosition(pos); }; } function GClientGeocoder(){ this.getLatLng = function(address, fnct){ fnct(null); }; } google.maps.Polyline.prototype.Distance = function() { var dist = 0; for (var i=1; i < this.getPath().getLength(); i++) { dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1)); } return dist; }; google.maps.LatLng.prototype.distanceFrom = function(newLatLng) { var R = 6378100; var lat1 = this.lat(); var lon1 = this.lng(); var lat2 = newLatLng.lat(); var lon2 = newLatLng.lng(); var dLat = (lat2-lat1) * Math.PI / 180; var dLon = (lon2-lon1) * Math.PI / 180; var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1 * Math.PI / 180 ) * Math.cos(lat2 * Math.PI / 180 ) * Math.sin(dLon/2) * Math.sin(dLon/2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; return d; }; google.maps.Polygon.prototype.getBounds = function() { var bounds = new google.maps.LatLngBounds(); var paths = this.getPaths(); var path; for (var p = 0; p < paths.getLength(); p++) { path = paths.getAt(p); for (var i = 0; i < path.getLength(); i++) { bounds.extend(path.getAt(i)); } } return bounds; }; google.maps.Polygon.prototype.getVertexCount = function() { return this.getPath().getLength(); }; google.maps.Polygon.prototype.getVertex = function(i) { return this.getPath().getAt(i); }; google.maps.Map.prototype.enableContinuousZoom = function(){ return true; }; google.maps.Map.prototype.addOverlay = function(layer){ return true; }; google.maps.Map.prototype.removeOverlay = function(layer){ layer.setMap(null); }; google.maps.Map.prototype.setMapType = function(MapType){ this.setMapTypeId(MapType); }; google.maps.Polyline.prototype.getVertexCount = function(){ var path = this.getPath(); return path.length; }; google.maps.Polyline.prototype.getVertex = function(index){ var path = this.getPath(); return path[index]; }; function MapRect(map, lat_t, lng_l, lat_b, lng_r, poly_col, poly_col_fill, line_w, line_opacity, fill_opacity, title, lblclass ) { this.lat_t = lat_t; this.lng_l = lng_l; this.lat_b = lat_b; this.lng_r = lng_r; this.Map = map; var path_arr = []; path_arr[0] = new google.maps.LatLng(lat_t, lng_l); path_arr[1] = new google.maps.LatLng(lat_t, lng_r); path_arr[2] = new google.maps.LatLng(lat_b, lng_r); path_arr[3] = new google.maps.LatLng(lat_b, lng_l); path_arr[4] = new google.maps.LatLng(lat_t, lng_l); this.Polygon = new google.maps.Polygon({map:this.Map, clickable:false, paths:path_arr, strokeColor:poly_col, strokeWeight:line_w, strokeOpacity:line_opacity, fillColor:poly_col_fill, fillOpacity:fill_opacity}); this.Map.addOverlay(this.Polygon); if(title != ""){ if(lblclass == null){lblclass = "map_rect_label";} this.pol_title = new NLabel(this.Map, lat_t, lng_l, title, false, lblclass, 100, "highpane" , 0, 0, true ); } this.remove = function(){ this.Polygon.setMap(null); if(this.pol_title != undefined){this.pol_title.remove();} }; this.isSame = function(olat_t, olng_l, olat_b, olng_r){ return (olat_t == this.lat_t && olng_l == this.lng_l && olat_b == this.lat_b && olng_r == this.lng_r); }; this.setFillCol = function(poly_col_fill){ this.Polygon.setOptions({ fillColor:poly_col_fill}); }; this.setOptions = function(opts){ this.Polygon.setOptions(opts); }; } function MapMarkerTypes() { this.MarkerTypes = new Array( ); this.Add = function(type, show_yn){ var len = this.MarkerTypes.length; this.MarkerTypes[len] = new Array(type, show_yn); }; this.ShowType = function(type){ var rtn = false; for(var i=0;i= 0){ this.MarkerTypes[i][1] = "N"; } } for(var i=0;i lat){ this.slat = lat; } if(this.nlat == null || this.nlat < lat){ this.nlat = lat; } if(this.wlng == null || this.wlng > lng){ this.wlng = lng; } if(this.elng == null || this.elng < lng){ this.elng = lng; } }; this.getCenter = function(){ return new google.maps.LatLng((this.slat+this.nlat)/2, (this.wlng + this.elng)/2); }; this.noArea = function(){ return (this.slat == null || (this.slat == this.nlat && this.wlng == this.elng)); }; } function MapMan(mycanvas, zoomlvl, centerlat, centerlng, isRoadMap, str_initMarkerXML, url_pagingXML, divList) { this.dragstart_callfunction; this.dragend_callfunction; this.click_callfunction; this.zoom_callfunction; this.bDragStarted = false; this.bRefreshStarted = false; this.bRefreshOnMove = true; this.MapMarkers = new Array(); this.RealMarkers = new Array(); this.PagingMarkers = new Array(); this.PagingMarkerIndice = new Array(); this.Polyline = null; this.Polygon = null; this.Overlays = new Array(); this.Rectangles = new Array(); this.InitXML = str_initMarkerXML; this.PagingXML = url_pagingXML; this.DivList = divList; this.Page = 1; this.ListCnt = 50; this.ViewerDivID = ""; this.TargetDivID = ""; this.APIType = "G"; this.ViewerShowIDs = new Array(); this.ViewerHideIDs = new Array(); var me = this; this.oldInfo = null; this.viewer = null; this.posShowView = null; var tpid = (isRoadMap)?google.maps.MapTypeId.ROADMAP:google.maps.MapTypeId.HYBRID; var myOptions = { zoom: zoomlvl, center: new google.maps.LatLng(centerlat,centerlng), mapTypeControl: true, navigationControl: true, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, mapTypeId: tpid }; this.Map = new google.maps.Map(document.getElementById(mycanvas), myOptions); this.mapDiv = document.getElementById(mycanvas); this.mapOverlay = new MapOverlay(this.Map); google.maps.event.addListener(this.Map, 'dragstart', function() { if(me.dragstart_callfunction != undefined){ me.dragstart_callfunction(); } me.bDragStarted = true; }); google.maps.event.addListener(this.Map, 'dragend', function() { if(me.bRefreshOnMove){ me.RemovePagingAll(); me.RefreshMarkers(); } me.bDragStarted = false; }); google.maps.event.addListener(this.Map, 'click', function(e) { if(me.click_callfunction != undefined){ me.click_callfunction(e.latLng.lat(), e.latLng.lng()); } }); google.maps.event.addListener(this.Map, 'zoom_changed', function() { $scale = me.Map.getZoom(); me.CloseInfoWin(); if(me.zoom_callfunction != undefined){ me.zoom_callfunction(); } if(me.bRefreshOnMove){ me.RemovePagingAll(); me.RefreshMarkers(); return false; } }); this.Init = function(){ }; this.setCenter = function(centerlat, centerlng){ this.Map.setCenter(new google.maps.LatLng(centerlat,centerlng)); }; this.fitBounds = function(latlngBounds){ if(latlngBounds.noArea()){ if(latlngBounds.slat != null){ this.Map.setCenter(new google.maps.LatLng(latlngBounds.slat, latlngBounds.wlng));} return; } var sw = new google.maps.LatLng(latlngBounds.slat, latlngBounds.wlng); var ne = new google.maps.LatLng(latlngBounds.nlat, latlngBounds.elng); var bnd = new google.maps.LatLngBounds(sw, ne); this.Map.fitBounds(bnd); }; this.AddMarker = function(marker){ var len = this.MapMarkers.length; var pos; var tp; marker.MrkOpt.map = this.Map; this.MapMarkers[len] = marker; }; this.GetMarker =function(id){ for(var i=0;i -1){ mrk = this.PagingMarkerIndice[k]; } if(mrk == undefined){ for(var i=0;i me.Map.getZoom()) return false; var p = projection.fromLatLngToContainerPixel(Mrk.MrkOpt.position); if(p.x <0 || p.y<0 || p.x>me.mapDiv.offsetWidth || p.y>me.mapDiv.offsetHeight){ return false; }else{ return true; } }; this.getLatLng = function(X, Y){ var projection = this.mapOverlay.getProjection(); if(projection == undefined){return null;} var latlng = projection.fromContainerPixelToLatLng(new google.maps.Point(X, Y)); return {lat:latlng.lat(), lng:latlng.lng()}; }; this.GetCanvasLatLng = function(){ var projection = me.mapOverlay.getProjection(); if(projection == undefined){return null;} var lefttop = projection.fromContainerPixelToLatLng(new google.maps.Point(0, 0)); var rightbottom = projection.fromContainerPixelToLatLng(new google.maps.Point(me.mapDiv.offsetWidth, me.mapDiv.offsetHeight)); return { ltLat: lefttop.lat(), ltLng: lefttop.lng(), rbLat: rightbottom.lat(), rbLng: rightbottom.lng() }; }; this.GetEmptyPos = function(){ for(var i=0;i"),"&","&"); div.innerHTML = ss; } } var results = xml.GetElementsByTagName('CenterZoom'); if(results.length > 0){ me.CenterZoom(results[0]); } if(bUpdate){ me.RemovePaging(); }else{ me.RemoveOut(); } me.PagingMarkerIndice = new Array(); if(xml.results != undefined){ var Mrk; for(var i=0; i-1)?"&":"?"; url += "ltlat="+ canvasLatLng.ltLat; url += "<lng="+ canvasLatLng.ltLng; url += "&rblat="+ canvasLatLng.rbLat; url += "&rblng="+ canvasLatLng.rbLng; url += "&page="+ this.Page+"&list_cnt="+ this.ListCnt+"&scale="+this.Map.getZoom(); if(isT) alert(url); xml.ReadXMLPage(url, 'Marker'); } }; this.RefreshMarkers = function(page, list_cnt){ if(!this.PagingXML){return;} if(this.bRefreshStarted){ this.bRefreshStarted = false; return; } this.bRefreshStarted = true; var me = this; this.RefreshMarkersLogic(page, list_cnt); }; this.RefreshBckMarkers = function(){ var j, k; for(var i=0;i= 0){ this.RealMarkers[j][0] = -1; this.RealMarkers[j][1].setMap(null); this.MapMarkers[i].RealIndex = -1; } } }; this.SetURLParam = function(param, val){ var url = this.PagingXML; var pos = url.indexOf("&"+param+"="); if(pos < 0){pos = url.indexOf("?"+param+"=");} if(pos > -1){ var epos = url.indexOf("&", pos + 2); var s1 = url.substring(0, pos + param.length+2); var s2 = (epos>-1)?url.substring(epos):""; this.PagingXML = s1+val+s2; }else{ url +=(this.PagingXML.indexOf("?") >-1)?"&":"?"; this.PagingXML = url+param+"="+val; } }; this.GetPagingEntryPos = function(pos, title){ var rtn = -1; var mpos; for(var i=0;i -1) return Mrk.RealIndex; var IWnd; var j = this.GetEmptyPos(); if(j == this.RealMarkers.length){ this.RealMarkers[j] = new Array(id, new google.maps.Marker(Mrk.MrkOpt)); }else{ this.RealMarkers[j][0] = id; this.RealMarkers[j][1].setOptions(Mrk.MrkOpt); } if(!Mrk.IsShowing){ this.RealMarkers[j][1].setMap(null); } Mrk.RealIndex = j; if(Mrk.IWndOpt != undefined){ IWnd = new google.maps.InfoWindow(Mrk.IWndOpt); google.maps.event.addListener(this.RealMarkers[j][1], 'click', function() { if(Mrk.IWndOpt == undefined) return; if(me.oldinfo != null) me.oldinfo.close(); IWnd.open(me.Map, me.RealMarkers[j][1]); me.oldinfo = IWnd; }); } return j; }; this.ShowInfo = function(id){ var k = -1; var mrk; for(var i=0;i -1){ mrk = this.PagingMarkers[k]; } if(mrk == undefined){ for(var i=0;i=0;i--){ if(this.MapMarkers[i].HasType(type)){ this.MapMarkers.splice(i, 1); } } this.RefreshBckMarkers(); }; this.ShowAllTypes = function(){ for(var i=0;i canvasLatLng.ltLat || pos.lat() < canvasLatLng.rbLat || pos.lng() < canvasLatLng.ltLng || pos.lng() > canvasLatLng.rbLng){ this.PagingMarkers[i].setMap(null); this.PagingMarkers[i] = null; } } for(var i=0;i canvasLatLng.ltLat || pos.lat() < canvasLatLng.rbLat || pos.lng() < canvasLatLng.ltLng || pos.lng() > canvasLatLng.rbLng){ this.Overlays[i].remove(); this.Overlays[i] = null; } } for(var i=0;i canvasLatLng.ltLat || this.Rectangles[i].lat_t < canvasLatLng.rbLat || this.Rectangles[i].lng_r < canvasLatLng.ltLng || this.Rectangles[i].lng_l > canvasLatLng.rbLng){ this.Rectangles[i].remove(); this.Rectangles[i] = null; } } }; this.ShowID = function(id, show){ var bShow =(show == null)?true:show; var map = (bShow)?this.Map:null; for(var i=0;i 0) Rtn+=delim; Rtn += this.MapMarkers[i].ID; } } } return Rtn; }; this.AddInitMarkers = function(){ if(this.InitXML == undefined) return; if(this.InitXML == '') return; var xmlobj = (new DOMParser()).parseFromString(this.InitXML, "text/xml"); var markers = xmlobj.documentElement.getElementsByTagName("Marker"); for (var i=0; i"),"&","&"); var Ovr = new NLabel(this.Map, latitude, longitude, content, false, "map_font", 60, null); var ix = this.GetOverlayEntryPos(Ovr.getPoint()); if(ix < 0){ Ovr.remove(); }else{ this.Overlays[ix] = Ovr; } }; this.AddRectangle = function(e){ var lat_t = parseFloat(e.getAttribute("lat_t")); var lng_l = parseFloat(e.getAttribute("lng_l")); var lat_b = parseFloat(e.getAttribute("lat_b")); var lng_r = parseFloat(e.getAttribute("lng_r")); var poly_col = e.getAttribute("poly_col"); var poly_col_fill = e.getAttribute("poly_col_fill"); var line_w = parseInt(e.getAttribute("line_w")); var line_opacity = parseFloat(e.getAttribute("line_opacity")); var fill_opacity = parseFloat(e.getAttribute("fill_opacity")); var title = " "+ e.getAttribute("title") + " "; title = replaceAll(replaceAll(replaceAll(title,"<","<"),">",">"),"&","&"); var Rect = new MapRect(this.Map, lat_t, lng_l, lat_b, lng_r, poly_col, poly_col_fill, line_w, line_opacity, fill_opacity, title ); var ix = this.GetRectangleEntryPos(Rect.lat_t, Rect.lng_l, Rect.lat_b, Rect.lng_r); if(ix < 0){ Rect.remove(); }else{ this.Rectangles[ix] = Rect; } }; this.CenterZoom = function(e){ var lat = parseFloat(e.getAttribute("lat")); var lng = parseFloat(e.getAttribute("lng")); var zoom = parseFloat(e.getAttribute("zoom")); this.Map.setCenter(new google.maps.LatLng(lat,lng)); this.Map.setZoom(zoom); }; this.CreateMarker = function(e){ var id = parseInt(e.getAttribute("gid")); var scale = parseInt(e.getAttribute("scale")); var show = parseInt(e.getAttribute("show")); var title = e.getAttribute("title"); var imgurl = e.getAttribute("imgurl"); var imgW = parseInt(e.getAttribute("imgW")); var imgH = parseInt(e.getAttribute("imgH")); var imgAnchorX = parseInt(e.getAttribute("imgAnchorX")); var imgAnchorY = parseInt(e.getAttribute("imgAnchorY")); var shadowurl = e.getAttribute("shadowurl"); var shadowW = parseInt(e.getAttribute("shadowW")); var shadowH = parseInt(e.getAttribute("shadowH")); var shadowAnchorX = parseInt(e.getAttribute("shadowAnchorX")); var shadowAnchorY = parseInt(e.getAttribute("shadowAnchorY")); var latitude = parseFloat(e.getAttribute("latitude")); var longitude = parseFloat(e.getAttribute("longitude")); var seqs = e.getAttribute("seqs"); var info = (e.childNodes[0] == undefined)?"":e.childNodes[0].nodeValue; var infoWidth = parseInt(e.getAttribute("infoWidth")); var infostr = replaceAll(replaceAll(replaceAll(info,"<","<"),">",">"),"&","&"); var shape = { coord: [1, 1, 1, imgH*0.7, imgW, imgH*0.7, imgW , 1], type: 'poly' }; if(imgurl == "") imgurl = shadowurl; var Mrk = new MapMarker(id, scale, show, latitude, longitude, imgurl, imgW, imgH, imgAnchorX, imgAnchorY, shadowurl, shadowW, shadowH, shadowAnchorX, shadowAnchorY, shape, title); var w = (infoWidth)?infoWidth:200; Mrk.SetInfoWnd(infostr, w); var keys = seqs.split(','); var key = []; for(i=0;i100){percentOpacity=100;} } this.percentOpacity = percentOpacity; this.pane = pane; this.hidden = false; this.setMap(map); } NLabel.prototype = new google.maps.OverlayView(); NLabel.prototype.onAdd = function() { var div = document.createElement("div"); div.style.position = "absolute"; div.innerHTML = '
' + this.html + '
' ; this.div_ = div; var panes = this.getPanes(); if(this.pane == null){ panes.mapPane.appendChild(div); }else{ panes.overlayMouseTarget.appendChild(div); } if (this.percentOpacity) { if(typeof(div.style.filter)=='string'){div.style.filter='alpha(opacity:'+this.percentOpacity+')';} if(typeof(div.style.KHTMLOpacity)=='string'){div.style.KHTMLOpacity=this.percentOpacity/100;} if(typeof(div.style.MozOpacity)=='string'){div.style.MozOpacity=this.percentOpacity/100;} if(typeof(div.style.opacity)=='string'){div.style.opacity=this.percentOpacity/100;} } if (this.hidden) { this.hide(); } }; NLabel.prototype.onRemove = function() { this.div_.parentNode.removeChild(this.div_); this.div_ = null; }; NLabel.prototype.remove = function() { this.setMap(null); }; NLabel.prototype.copy = function() { return new NLabel(this.map_, this.point.lat(), this.point.lng(), this.html, this.classname, this.percentOpacity); }; NLabel.prototype.draw = function() { var proj = this.getProjection(); var p = proj.fromLatLngToDivPixel(this.point); var h = (this.Up)?parseInt(this.div_.clientHeight):parseInt(this.div_.clientHeight/2); var w_2 = parseInt(this.div_.clientWidth/2); var L = p.x; var T = p.y; if(!this.NoCenter){ L -= w_2; T -= h; } if(this.offsetx != undefined) L += this.offsetx; if(this.offsety != undefined) T += this.offsety; this.div_.style.left = L+ "px"; this.div_.style.top = T+ "px"; }; NLabel.prototype.show = function() { if (this.div_) { this.div_.style.display=""; this.draw(); } this.hidden = false; }; NLabel.prototype.hide = function() { if (this.div_) { this.div_.style.display="none"; } this.hidden = true; }; NLabel.prototype.isHidden = function() { return this.hidden; }; NLabel.prototype.supportsHide = function() { return true; }; NLabel.prototype.setContents = function(html) { this.html = html; this.div_.innerHTML = '
' + this.html + '
' ; this.draw(); }; NLabel.prototype.setPoint = function(point) { this.point = point; this.draw(true); }; NLabel.prototype.setOpacity = function(percentOpacity) { if (percentOpacity) { if(percentOpacity<0){percentOpacity=0;} if(percentOpacity>100){percentOpacity=100;} } this.percentOpacity = percentOpacity; if (this.percentOpacity) { if(typeof(this.div_.style.filter)=='string'){this.div_.style.filter='alpha(opacity:'+this.percentOpacity+')';} if(typeof(this.div_.style.KHTMLOpacity)=='string'){this.div_.style.KHTMLOpacity=this.percentOpacity/100;} if(typeof(this.div_.style.MozOpacity)=='string'){this.div_.style.MozOpacity=this.percentOpacity/100;} if(typeof(this.div_.style.opacity)=='string'){this.div_.style.opacity=this.percentOpacity/100;} } }; NLabel.prototype.getPoint = function() { return this.point; }; function NaviView(view_divid, hide_ids, show_ids, pointLat, pointLng, v_yaw, v_pitch, v_zoom, bHideXBtn) { this.move_call = function(lat, lng){}; this.yaw_change_call = function(yaw){}; this.pitch_change_call = function(pitch){}; this.zoom_change_call = function(zoom){}; this.hide_ids = hide_ids; this.show_ids = show_ids; this.div_ = document.getElementById(view_divid); if(this.div_ == undefined){ return;} this.div_.style.display = ""; this.div_.style.zIndex = 100; this.pos = new google.maps.LatLng(pointLat, pointLng); if(v_zoom == undefined){v_zoom = 0;} this.POV = {heading:v_yaw, pitch:v_pitch, zoom:v_zoom}; var panoramaOptions = { position: this.pos, pov: this.POV }; this.viewer = new google.maps.StreetViewPanorama(this.div_, panoramaOptions); var me = this; google.maps.event.addListener(this.viewer, 'position_changed', function() { var p = me.viewer.getPosition(); me.move_call(p.lat(), p.lng()); }); google.maps.event.addListener(this.viewer, 'pov_changed', function() { var pov = me.viewer.getPov(); me.yaw_change_call(pov.heading); me.pitch_change_call(pov.pitch); me.zoom_change_call(pov.zoom); }); this.ShowHide = function(bViewOpen){ var el = null; var dis = ""; if(bViewOpen){ dis = "none";} for(var i=0;i