123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- mxn.register('googlev3', {
- Mapstraction: {
-
- init: function(element, api){
- var me = this;
- if ( google && google.maps ){
-
- var myOptions = {
- disableDefaultUI: true,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- var map = new google.maps.Map(element, myOptions);
-
-
- google.maps.event.addListener(map, 'click', function(location){
- me.clickHandler(location.latLng.lat(),location.latLng.lng(),location,me);
- });
-
- google.maps.event.addListener(map, 'zoom_changed', function(){
- me.changeZoom.fire();
- });
-
- google.maps.event.addListener(map, 'dragend', function(){
- me.moveendHandler(me);
- me.endPan.fire();
- });
- this.maps[api] = map;
- this.loaded[api] = true;
- me.load.fire();
- }
- else {
- alert(api + ' map script not imported');
- }
- },
-
- applyOptions: function(){
- var map = this.maps[this.api];
- var myOptions = [];
- if (this.options.enableDragging) {
- myOptions.draggable = true;
- }
- if (this.options.enableScrollWheelZoom){
- myOptions.scrollwheel = true;
- }
- map.setOptions(myOptions);
- },
- resizeTo: function(width, height){
- this.currentElement.style.width = width;
- this.currentElement.style.height = height;
- var map = this.maps[this.api];
- google.maps.event.trigger(map,'resize');
- },
- addControls: function( args ) {
- var map = this.maps[this.api];
-
-
- if (args.zoom || args.pan) {
- if (args.zoom == 'large'){
- this.addLargeControls();
- } else {
- this.addSmallControls();
- }
- }
- if (args.scale){
- var myOptions = {
- scaleControl:true,
- scaleControlOptions: {style:google.maps.ScaleControlStyle.DEFAULT}
- };
- map.setOptions(myOptions);
- this.addControlsArgs.scale = true;
- }
- },
- addSmallControls: function() {
- var map = this.maps[this.api];
- var myOptions = {
- navigationControl: true,
- navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}
- };
- map.setOptions(myOptions);
- this.addControlsArgs.pan = false;
- this.addControlsArgs.scale = false;
- this.addControlsArgs.zoom = 'small';
- },
- addLargeControls: function() {
- var map = this.maps[this.api];
- var myOptions = {
- navigationControl:true,
- navigationControlOptions: {style:google.maps.NavigationControlStyle.DEFAULT}
- };
- map.setOptions(myOptions);
- this.addControlsArgs.pan = true;
- this.addControlsArgs.zoom = 'large';
- },
- addMapTypeControls: function() {
- var map = this.maps[this.api];
- var myOptions = {
- mapTypeControl: true,
- mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DEFAULT}
- };
- map.setOptions(myOptions);
- this.addControlsArgs.map_type = true;
- },
- setCenterAndZoom: function(point, zoom) {
- var map = this.maps[this.api];
- var pt = point.toProprietary(this.api);
- map.setCenter(pt);
- map.setZoom(zoom);
- },
-
- addMarker: function(marker, old) {
- return marker.toProprietary(this.api);
- },
- removeMarker: function(marker) {
-
- marker.hide();
- },
- removeAllMarkers: function() {
- var map = this.maps[this.api];
-
- },
-
- declutterMarkers: function(opts) {
- var map = this.maps[this.api];
-
- },
- addPolyline: function(polyline, old) {
- var map = this.maps[this.api];
- return polyline.toProprietary(this.api);
- },
- removePolyline: function(polyline) {
- var map = this.maps[this.api];
-
- },
-
- getCenter: function() {
- var map = this.maps[this.api];
- var pt = map.getCenter();
- return new mxn.LatLonPoint(pt.lat(),pt.lng());
- },
- setCenter: function(point, options) {
- var map = this.maps[this.api];
- var pt = point.toProprietary(this.api);
- if(options && options.pan) {
- map.panTo(pt);
- }
- else {
- map.setCenter(pt);
- }
- },
- setZoom: function(zoom) {
- var map = this.maps[this.api];
- map.setZoom(zoom);
- },
-
- getZoom: function() {
- var map = this.maps[this.api];
- return map.getZoom();
- },
- getZoomLevelForBoundingBox: function( bbox ) {
- var map = this.maps[this.api];
- var sw = bbox.getSouthWest().toProprietary(this.api);
- var ne = bbox.getNorthEast().toProprietary(this.api);
- var gLatLngBounds = new google.maps.LatLngBounds(sw, ne);
- map.fitBounds(gLatLngBounds);
- return map.getZoom();
- },
- setMapType: function(type) {
- var map = this.maps[this.api];
- switch(type) {
- case mxn.Mapstraction.ROAD:
- map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
- break;
- case mxn.Mapstraction.SATELLITE:
- map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
- break;
- case mxn.Mapstraction.HYBRID:
- map.setMapTypeId(google.maps.MapTypeId.HYBRID);
- break;
- default:
- map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
- }
- },
- getMapType: function() {
- var map = this.maps[this.api];
- var type = map.getMapTypeId();
- switch(type) {
- case google.maps.MapTypeId.ROADMAP:
- return mxn.Mapstraction.ROAD;
- case google.maps.MapTypeId.SATELLITE:
- return mxn.Mapstraction.SATELLITE;
- case google.maps.MapTypeId.HYBRID:
- return mxn.Mapstraction.HYBRID;
-
-
- default:
- return null;
- }
- },
- getBounds: function () {
- var map = this.maps[this.api];
- var gLatLngBounds = map.getBounds();
- var sw = gLatLngBounds.getSouthWest();
- var ne = gLatLngBounds.getNorthEast();
- return new mxn.BoundingBox(sw.lat(), sw.lng(), ne.lat(), ne.lng());
- },
- setBounds: function(bounds){
- var map = this.maps[this.api];
- var sw = bounds.getSouthWest().toProprietary(this.api);
- var ne = bounds.getNorthEast().toProprietary(this.api);
- var gLatLngBounds = new google.maps.LatLngBounds(sw, ne);
- map.fitBounds(gLatLngBounds);
- },
- addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
- var map = this.maps[this.api];
-
-
- },
- setImagePosition: function(id, oContext) {
- var map = this.maps[this.api];
- var topLeftPoint; var bottomRightPoint;
-
-
-
-
-
- },
-
- addOverlay: function(url, autoCenterAndZoom) {
- var map = this.maps[this.api];
-
-
-
- },
- addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom, map_type) {
- var map = this.maps[this.api];
-
-
- },
- toggleTileLayer: function(tile_url) {
- var map = this.maps[this.api];
-
-
- },
- getPixelRatio: function() {
- var map = this.maps[this.api];
-
- },
-
- mousePosition: function(element) {
- var map = this.maps[this.api];
-
- }
- },
- LatLonPoint: {
-
- toProprietary: function() {
- return new google.maps.LatLng(this.lat, this.lon);
- },
- fromProprietary: function(googlePoint) {
- this.lat = googlePoint.lat();
- this.lon = googlePoint.lng();
- }
-
- },
- Marker: {
-
- toProprietary: function() {
- var options = {};
-
- var ax = 0;
- var ay = 0;
- if (this.iconAnchor) {
- ax = this.iconAnchor[0];
- ay = this.iconAnchor[1];
- }
- var gAnchorPoint = new google.maps.Point(ax,ay);
- if (this.iconUrl) {
- options.icon = new google.maps.MarkerImage(
- this.iconUrl,
- new google.maps.Size(this.iconSize[0],
- this.iconSize[1]),
- new google.maps.Point(0,0),
- gAnchorPoint
- );
-
- if (this.iconShadowUrl) {
- if (this.iconShadowSize) {
- var x = this.iconShadowSize[0];
- var y = this.iconShadowSize[1];
- options.shadow = new google.maps.MarkerImage(
- this.iconShadowUrl,
- new google.maps.Size(x,y),
- new google.maps.Point(0,0),
- gAnchorPoint
- );
- }
- else {
- options.shadow = new google.maps.MarkerImage(this.iconShadowUrl);
- }
- }
- }
- if (this.draggable){
- options.draggable = this.draggable;
- }
- if (this.labelText){
- options.title = this.labelText;
- }
- if (this.imageMap){
- options.shape = {
- coord: this.imageMap,
- type: 'poly'
- };
- }
-
- options.position = this.location.toProprietary(this.api);
- options.map = this.map;
- var marker = new google.maps.Marker(options);
- if (this.infoBubble){
- var infowindow = new google.maps.InfoWindow({
- content: this.infoBubble
- });
- var event_action = "click";
- if (this.hover) {
- event_action = "mouseover";
- }
- google.maps.event.addListener(marker, event_action, function() { infowindow.open(this.map,marker); });
- }
- if (this.hoverIconUrl){
- var gSize = new google.maps.Size(this.iconSize[0],
- this.iconSize[1]);
- var zerozero = new google.maps.Point(0,0);
- var hIcon = new google.maps.MarkerImage(
- this.hoverIconUrl,
- gSize,
- zerozero,
- gAnchorPoint
- );
- var Icon = new google.maps.MarkerImage(
- this.iconUrl,
- gSize,
- zerozero,
- gAnchorPoint
- );
- google.maps.event.addListener(
- marker,
- "mouseover",
- function(){
- marker.setIcon(hIcon);
- }
- );
- google.maps.event.addListener(
- marker,
- "mouseout",
- function(){ marker.setIcon(Icon); }
- );
- }
- google.maps.event.addListener(marker, 'click', function() {
- marker.mapstraction_marker.click.fire();
- });
-
- return marker;
- },
- openBubble: function() {
- var infowindow = new google.maps.InfoWindow({
- content: this.infoBubble
- });
- infowindow.open(this.map,this.proprietary_marker);
- },
- hide: function() {
- this.proprietary_marker.setOptions({visible:false});
- },
- show: function() {
- this.proprietary_marker.setOptions({visible:true});
- },
- update: function() {
-
- }
-
- },
- Polyline: {
- toProprietary: function() {
- throw 'Not implemented';
- },
-
- show: function() {
- throw 'Not implemented';
- },
- hide: function() {
- throw 'Not implemented';
- }
-
- }
- });
|