var Class = { create: function() { return function() { this.initialize.apply(this, arguments) } } }; var PlaceViewer = Class.create(); PlaceViewer.prototype = { initialize: function(C, A) { Event.observe($$("body")[0], "unload", GUnload); this.mapTypeContainer = A.mapTypeContainer; this.mapZoomContainer = A.mapZoomContainer; this.mapWidth = (A.width != undefined) ? A.width : 446; this.mapHeight = (A.height != undefined) ? A.height : 300; this.map = new GMap2($(C), { size: new GSize(this.mapWidth, this.mapHeight) }); this.map.addControl(new GLargeMapControl()); this.map.addControl(new GMapTypeControl()); this.markerInitailized = false; this.changedHandler = A.pointChangedHandler; GEvent.addListener(this.map, "load", this.mapLoaded.bindAsEventListener(this)); GEvent.addListener(this.map, "dragend", this.mapDragEnd.bindAsEventListener(this)); if (A.mapLoadedHandler) { GEvent.addListener(this.map, "load", A.mapLoadedHandler) } if (A.centerLat != "" && A.centerLng != "") { var B = ($F(this.mapZoomContainer) != "") ? parseInt($F(this.mapZoomContainer)) : 14; this.map.setCenter(new GLatLng(A.centerLat, A.centerLng), B); this.initializeMarker(); if (A.lat != "" && A.lng != "") { this.marker.setPoint(new GLatLng(A.lat, A.lng)); this.marker.show() } } switch ($F(this.mapTypeContainer)) { case "G_NORMAL_MAP": this.map.setMapType(G_NORMAL_MAP); break; case "G_SATELLITE_MAP": this.map.setMapType(G_SATELLITE_MAP); break; case "G_HYBRID_MAP": this.map.setMapType(G_HYBRID_MAP); break } GEvent.addListener(this.map, "maptypechanged", this.mapTypeChanged.bindAsEventListener(this)); GEvent.addListener(this.map, "zoomend", this.mapZoomEnd.bindAsEventListener(this)) }, mapDragEnd: function() { var B = this.map.getCenter(); if (this.marker) { if (!this.marker.isHidden()) { var A = this.marker.getPoint(); this.changedHandler(B.lat(), B.lng(), A.y, A.x); return } } this.changedHandler(B.lat(), B.lng(), "", "") }, reset: function() { this.selectorElement.removeClassName("inactive"); if (this.marker) { this.marker.hide() } this.changedHandler("", "", "", "") }, mapTypeChanged: function(A) { switch (this.map.getCurrentMapType()) { case G_NORMAL_MAP: this.mapTypeContainer.value = "G_NORMAL_MAP"; break; case G_SATELLITE_MAP: this.mapTypeContainer.value = "G_SATELLITE_MAP"; break; case G_HYBRID_MAP: this.mapTypeContainer.value = "G_HYBRID_MAP"; break } }, mapZoomEnd: function(B, A) { this.mapZoomContainer.value = this.map.getZoom() }, initializeMarker: function() { if (!this.markerInitailized) { this.markerIcon = new GIcon(); this.markerIcon.image = rootUrl + "images/map_arrow.png"; this.markerIcon.iconSize = new GSize(51, 38); this.markerIcon.iconAnchor = new GPoint(27, 36); this.marker = new GMarker(this.map.getCenter(), { draggable: false, icon: this.markerIcon }); this.map.addOverlay(this.marker); this.marker.hide() } }, mapLoaded: function() { this.initializeMarker() } };