Removing extra mapstraction provider javascript files after conversations with Serge Noiraud. Would like to do some more research on mxn.googleearth.core.js for possible use in something else.

svn: r15591
This commit is contained in:
Rob G. Healey 2010-06-24 06:44:28 +00:00
parent aad0f9d0f5
commit 01d27b8694
5 changed files with 0 additions and 2067 deletions

View File

@ -1,372 +0,0 @@
/*
Copyright (c) 2010 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
mxn.register('cloudmade', {
Mapstraction: {
init: function(element, api) {
var me = this;
var cloudmade = new CM.Tiles.CloudMade.Web({key: cloudmade_key});
this.maps[api] = new CM.Map(element, cloudmade);
this.loaded[api] = true;
CM.Event.addListener(this.maps[api], 'click', function(location,marker) {
if ( marker && marker.mapstraction_marker ) {
marker.mapstraction_marker.click.fire();
}
else if ( location ) {
me.click.fire({'location': new mxn.LatLonPoint(location.lat(), location.lng())});
}
// If the user puts their own Google markers directly on the map
// then there is no location and this event should not fire.
if ( location ) {
me.clickHandler(location.lat(),location.lng(),location,me);
}
});
CM.Event.addListener(this.maps[api], 'dragend', function() {
me.endPan.fire();
});
CM.Event.addListener(this.maps[api], 'zoomend', function() {
me.changeZoom.fire();
});
},
applyOptions: function(){
var map = this.maps[this.api];
if(this.options.enableScrollWheelZoom){
map.enableScrollWheelZoom();
}
},
resizeTo: function(width, height){
this.maps[this.api].checkResize();
},
addControls: function( args ) {
var map = this.maps[this.api];
var c = this.addControlsArgs;
switch (c.zoom) {
case 'large':
this.addLargeControls();
break;
case 'small':
this.addSmallControls();
break;
}
if (c.map_type) {
this.addMapTypeControls();
}
if (c.scale) {
map.addControl(new CM.ScaleControl());
this.addControlsArgs.scale = true;
}
},
addSmallControls: function() {
var map = this.maps[this.api];
map.addControl(new CM.SmallMapControl());
this.addControlsArgs.zoom = 'small';
},
addLargeControls: function() {
var map = this.maps[this.api];
map.addControl(new CM.LargeMapControl());
this.addControlsArgs.zoom = 'large';
},
addMapTypeControls: function() {
var map = this.maps[this.api];
map.addControl(new CM.TileLayerControl());
this.addControlsArgs.map_type = true;
},
dragging: function(on) {
var map = this.maps[this.api];
if (on) {
map.enableDragging();
} else {
map.disableDragging();
}
},
setCenterAndZoom: function(point, zoom) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
map.setCenter(pt, zoom);
},
addMarker: function(marker, old) {
var map = this.maps[this.api];
var pin = marker.toProprietary(this.api);
map.addOverlay(pin);
return pin;
},
removeMarker: function(marker) {
var map = this.maps[this.api];
marker.proprietary_marker.closeInfoWindow();
map.removeOverlay(marker.proprietary_marker);
},
declutterMarkers: function(opts) {
var map = this.maps[this.api];
// TODO: Add provider code
},
addPolyline: function(polyline, old) {
var map = this.maps[this.api];
var pl = polyline.toProprietary(this.api);
map.addOverlay(pl);
return pl;
},
removePolyline: function(polyline) {
var map = this.maps[this.api];
map.removeOverlay(polyline.proprietary_polyline);
},
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 !== null && 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];
// NE and SW points from the bounding box.
var ne = bbox.getNorthEast();
var sw = bbox.getSouthWest();
var zoom = map.getBoundsZoomLevel(new CM.LatLngBounds(sw.toProprietary(this.api), ne.toProprietary(this.api)));
return zoom;
},
setMapType: function(type) {
var map = this.maps[this.api];
// TODO: Are there any MapTypes for Cloudmade?
switch(type) {
case mxn.Mapstraction.ROAD:
// TODO: Add provider code
break;
case mxn.Mapstraction.SATELLITE:
// TODO: Add provider code
break;
case mxn.Mapstraction.HYBRID:
// TODO: Add provider code
break;
default:
// TODO: Add provider code
}
},
getMapType: function() {
var map = this.maps[this.api];
// TODO: Are there any MapTypes for Cloudmade?
return mxn.Mapstraction.ROAD;
//return mxn.Mapstraction.SATELLITE;
//return mxn.Mapstraction.HYBRID;
},
getBounds: function () {
var map = this.maps[this.api];
var box = map.getBounds();
var sw = box.getSouthWest();
var ne = box.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();
var ne = bounds.getNorthEast();
map.zoomToBounds(new CM.LatLngBounds(sw.toProprietary(this.api), ne.toProprietary(this.api)));
},
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
var map = this.maps[this.api];
// TODO: Add provider code
},
setImagePosition: function(id, oContext) {
var map = this.maps[this.api];
var topLeftPoint; var bottomRightPoint;
// TODO: Add provider code
},
addOverlay: function(url, autoCenterAndZoom) {
var map = this.maps[this.api];
// TODO: Add provider code
},
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
var map = this.maps[this.api];
// TODO: Add provider code
},
toggleTileLayer: function(tile_url) {
var map = this.maps[this.api];
// TODO: Add provider code
},
getPixelRatio: function() {
var map = this.maps[this.api];
// TODO: Add provider code
},
mousePosition: function(element) {
var map = this.maps[this.api];
// TODO: Add provider code
}
},
LatLonPoint: {
toProprietary: function() {
var cll = new CM.LatLng(this.lat,this.lon);
return cll;
},
fromProprietary: function(point) {
this.lat = point.lat();
this.lon = point.lng();
}
},
Marker: {
toProprietary: function() {
var pt = this.location.toProprietary(this.api);
var options = {};
if (this.iconUrl) {
var cicon = new CM.Icon();
cicon.image = this.iconUrl;
if (this.iconSize) {
cicon.iconSize = new CM.Size(this.iconSize[0], this.iconSize[1]);
if (this.iconAnchor) {
cicon.iconAnchor = new CM.Point(this.iconAnchor[0], this.iconAnchor[1]);
}
}
if (this.iconShadowUrl) {
cicon.shadow = this.iconShadowUrl;
if (this.iconShadowSize) {
cicon.shadowSize = new CM.Size(this.iconShadowSize[0], this.iconShadowSize[1]);
}
}
options.icon = cicon;
}
if (this.labelText) {
options.title = this.labelText;
}
var cmarker = new CM.Marker(pt, options);
if (this.infoBubble) {
cmarker.bindInfoWindow(this.infoBubble);
}
return cmarker;
},
openBubble: function() {
var pin = this.proprietary_marker;
pin.openInfoWindow(this.infoBubble);
},
hide: function() {
var pin = this.proprietary_marker;
pin.hide();
},
show: function() {
var pin = this.proprietary_marker;
pin.show();
},
update: function() {
// TODO: Add provider code
}
},
Polyline: {
toProprietary: function() {
var pts = [];
var poly;
for (var i = 0, length = this.points.length ; i< length; i++){
pts.push(this.points[i].toProprietary(this.api));
}
if (this.closed || pts[0].equals(pts[pts.length-1])) {
poly = new CM.Polygon(pts, this.color, this.width, this.opacity, this.fillColor || "#5462E3", this.opacity || "0.3");
}
else {
poly = new CM.Polyline(pts, this.color, this.width, this.opacity);
}
return poly;
},
show: function() {
this.proprietary_polyline.show();
},
hide: function() {
this.proprietary_polyline.hide();
}
}
});

View File

@ -1,367 +0,0 @@
/*
Copyright (c) 2010 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
mxn.register('microsoft', {
Mapstraction: {
init: function(element, api) {
var me = this;
if (VEMap){
this.maps[api] = new VEMap(element.id);
this.maps[api].AttachEvent('onclick', function(event){
me.clickHandler();
var x = event.mapX;
var y = event.mapY;
var pixel = new VEPixel(x,y);
me.click.fire({'location': new mxn.LatLonPoint(pixel.Latitude, pixel.Longitude)});
});
this.maps[api].AttachEvent('onendzoom', function(event){
me.moveendHandler(me);
me.changeZoom.fire();
});
this.maps[api].AttachEvent('onendpan', function(event){
me.moveendHandler(me);
me.endPan.fire();
});
this.maps[api].AttachEvent('onchangeview', function(event){
me.endPan.fire();
});
this.maps[api].LoadMap();
document.getElementById("MSVE_obliqueNotification").style.visibility = "hidden";
//removes the bird's eye pop-up
this.loaded[api] = true;
me.load.fire();
}
else{
throw api + ' map script not imported';
}
},
applyOptions: function(){
var map = this.maps[this.api];
if(this.options.enableScrollWheelZoom){
map.enableContinuousZoom();
map.enableScrollWheelZoom();
}
},
resizeTo: function(width, height){
this.maps[this.api].Resize(width, height);
},
addControls: function( args ) {
var map = this.maps[this.api];
if (args.pan) {
map.SetDashboardSize(VEDashboardSize.Normal);
}
else {
map.SetDashboardSize(VEDashboardSize.Tiny);
}
if (args.zoom == 'large') {
map.SetDashboardSize(VEDashboardSize.Small);
}
else if ( args.zoom == 'small' ) {
map.SetDashboardSize(VEDashboardSize.Tiny);
}
else {
map.HideDashboard();
map.HideScalebar();
}
},
addSmallControls: function() {
var map = this.maps[this.api];
map.SetDashboardSize(VEDashboardSize.Tiny);
},
addLargeControls: function() {
var map = this.maps[this.api];
map.SetDashboardSize(VEDashboardSize.Normal);
this.addControlsArgs.pan = true;
this.addControlsArgs.zoom = 'large';
},
addMapTypeControls: function() {
var map = this.maps[this.api];
map.addTypeControl();
},
dragging: function(on) {
var map = this.maps[this.api];
if (on) {
map.enableDragMap();
}
else {
map.disableDragMap();
}
},
setCenterAndZoom: function(point, zoom) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
var vzoom = zoom;
map.SetCenterAndZoom(new VELatLong(point.lat,point.lon), vzoom);
},
addMarker: function(marker, old) {
var map = this.maps[this.api];
marker.pinID = "mspin-"+new Date().getTime()+'-'+(Math.floor(Math.random()*Math.pow(2,16)));
var pin = marker.toProprietary(this.api);
map.AddShape(pin);
//give onclick event
//give on double click event
//give on close window
//return the marker
return pin;
},
removeMarker: function(marker) {
var map = this.maps[this.api];
var id = marker.proprietary_marker.GetID();
var microsoftShape = map.GetShapeByID(id);
map.DeleteShape(microsoftShape);
},
declutterMarkers: function(opts) {
var map = this.maps[this.api];
// TODO: Add provider code
},
addPolyline: function(polyline, old) {
var map = this.maps[this.api];
var pl = polyline.toProprietary(this.api);
pl.HideIcon();//hide the icon VE automatically displays
map.AddShape(pl);
return pl;
},
removePolyline: function(polyline) {
var map = this.maps[this.api];
var id = polyline.proprietary_polyline.GetID();
var microsoftShape = map.GetShapeByID(id);
map.DeleteShape(microsoftShape);
},
getCenter: function() {
var map = this.maps[this.api];
var LL = map.GetCenter();
var point = new mxn.LatLonPoint(LL.Latitude, LL.Longitude);
return point;
},
setCenter: function(point, options) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
map.SetCenter(new VELatLong(point.lat, point.lon));
},
setZoom: function(zoom) {
var map = this.maps[this.api];
map.SetZoomLevel(zoom);
},
getZoom: function() {
var map = this.maps[this.api];
var zoom = map.GetZoomLevel();
return zoom;
},
getZoomLevelForBoundingBox: function( bbox ) {
var map = this.maps[this.api];
// NE and SW points from the bounding box.
var ne = bbox.getNorthEast();
var sw = bbox.getSouthWest();
var zoom;
// TODO: Add provider code
return zoom;
},
setMapType: function(type) {
var map = this.maps[this.api];
switch(type) {
case mxn.Mapstraction.ROAD:
map.SetMapStyle(VEMapStyle.Road);
break;
case mxn.Mapstraction.SATELLITE:
map.SetMapStyle(VEMapStyle.Aerial);
break;
case mxn.Mapstraction.HYBRID:
map.SetMapStyle(VEMapStyle.Hybrid);
break;
default:
map.SetMapStyle(VEMapStyle.Road);
}
},
getMapType: function() {
var map = this.maps[this.api];
var mode = map.GetMapStyle();
switch(mode){
case VEMapStyle.Aerial:
return mxn.Mapstraction.SATELLITE;
case VEMapStyle.Road:
return mxn.Mapstraction.ROAD;
case VEMapStyle.Hybrid:
return mxn.Mapstraction.HYBRID;
default:
return null;
}
},
getBounds: function () {
var map = this.maps[this.api];
view = map.GetMapView();
var topleft = view.TopLeftLatLong;
var bottomright = view.BottomRightLatLong;
return new mxn.BoundingBox(bottomright.Latitude,topleft.Longitude,topleft.Latitude, bottomright.Longitude );
},
setBounds: function(bounds){
var map = this.maps[this.api];
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var rec = new VELatLongRectangle(new VELatLong(ne.lat, ne.lon), new VELatLong(sw.lat, sw.lon));
map.SetMapView(rec);
},
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
var map = this.maps[this.api];
// TODO: Add provider code
},
setImagePosition: function(id, oContext) {
var map = this.maps[this.api];
var topLeftPoint; var bottomRightPoint;
// TODO: Add provider code
// oContext.pixels.top = ...;
// oContext.pixels.left = ...;
// oContext.pixels.bottom = ...;
// oContext.pixels.right = ...;
},
addOverlay: function(url, autoCenterAndZoom) {
var map = this.maps[this.api];
var layer = new VEShapeLayer();
var mlayerspec = new VEShapeSourceSpecification(VEDataType.GeoRSS, url, layer);
map.AddShapeLayer(layer);
},
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
throw 'Not implemented';
},
toggleTileLayer: function(tile_url) {
throw 'Not implemented';
},
getPixelRatio: function() {
throw 'Not implemented';
},
mousePosition: function(element) {
var locDisp = document.getElementById(element);
if (locDisp !== null) {
var map = this.maps[this.api];
map.AttachEvent("onmousemove", function(veEvent){
var latlon = map.PixelToLatLong(new VEPixel(veEvent.mapX, veEvent.mapY));
var loc = latlon.Latitude.toFixed(4) + " / " + latlon.Longitude.toFixed(4);
locDisp.innerHTML = loc;
});
locDisp.innerHTML = "0.0000 / 0.0000";
}
}
},
LatLonPoint: {
toProprietary: function() {
return new VELatLong(this.lat, this.lon);
},
fromProprietary: function(mpoint) {
this.lat = mpoint.Latitude;
this.lon = mpoint.Longitude;
}
},
Marker: {
toProprietary: function() {
var mmarker = new VEShape(VEShapeType.Pushpin, this.location.toProprietary('microsoft'));
return mmarker;
},
openBubble: function() {
var mmarker = this.proprietary_marker;
map.ClearInfoBoxStyles();
mmarker.SetTitle(this.infoBubble);
},
hide: function() {
this.proprietary_marker.hide();
},
show: function() {
this.proprietary_marker_unhide();
},
update: function() {
throw 'Not implemented';
}
},
Polyline: {
toProprietary: function() {
var mpoints =[];
for(var i =0, length = this.points.length; i < length; i++) {
mpoints.push(this.points[i].toProprietary('microsoft'));
}
var mpolyline = new VEShape(VEShapeType.Polyline, mpoints);
if(this.color){
var color = new mxn.util.Color(this.color);
var opacity = (typeof(this.opacity) == 'undefined' || this.opacity === null) ? 1.0 : this.opacity;
var vecolor = new VEColor(color.red, color.green, color.blue, opacity);
mpolyline.SetLineColor(vecolor);
}
// TODO ability to change line width
return mpolyline;
},
show: function() {
this.proprietary_polyline.Show();
},
hide: function() {
this.proprietary_polyline.Hide();
}
}
});

View File

@ -1,471 +0,0 @@
/*
Copyright (c) 2010 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
mxn.register('multimap', {
Mapstraction: {
init: function(element, api) {
var me = this;
if (MultimapViewer) {
if(this.debug){
// multimap calls this print_debug function to output debug info
window.print_debug = function(strMessage){
var dbg = document.getElementById('debug');
if(dbg){
dbg.innerHTML += '<p>MUlTIMAP: ' + strMessage + '</p>';
}
else {
alert(strMessage);
}
};
}
var map = new MultimapViewer(element);
// Hook up our events
map.addEventHandler('click', function(eventType, eventTarget, arg1, arg2, arg3){
if (arg1) {
me.clickHandler(arg1.lat, arg1.lon, me);
me.click.fire({'location': new mxn.LatLonPoint(arg1.lat, arg1.lon)});
}
});
map.addEventHandler('changeZoom', function(eventType, eventTarget, arg1, arg2, arg3){
me.moveendHandler(me);
me.changeZoom.fire();
});
map.addEventHandler('endPan', function(eventType, eventTarget, arg1, arg2, arg3){
me.moveendHandler(me);
me.endPan.fire();
});
map.addEventHandler('openInfoBox', function(eventType, eventTarget, arg1, arg2, arg3){
if(arg1.mapstraction_marker) {
arg1.mapstraction_marker.openInfoBubble.fire();
}
});
map.addEventHandler('closeInfoBox', function(eventType, eventTarget, arg1, arg2, arg3){
if(arg1.mapstraction_marker) {
marker.closeInfoBubble.fire();
}
});
this.maps[api] = map;
this.loaded[api] = true;
}
else {
alert(api + ' map script not imported');
}
},
applyOptions: function(){
var map = this.maps[this.api];
if (this.options.enableScrollWheelZoom) {
map.setOptions( { 'mousewheel:wheelup': 'zoomin', 'mousewheel:wheeldown': 'zoomout' } );
}
if (this.options.enableDragging) {
map.setOption('drag', 'dragmap');
}
else {
map.setOption('drag', '');
}
},
resizeTo: function(width, height){
this.currentElement.style.width = width;
this.currentElement.style.height = height;
this.maps[this.api].resize();
},
addControls: function( args ) {
var map = this.maps[this.api];
var pan_zoom_widget = 'MM';
if (args.zoom && args.zoom == "small") {
pan_zoom_widget = pan_zoom_widget + "Small";
}
if (args.pan) {
pan_zoom_widget = pan_zoom_widget + "Pan";
}
if (args.zoom) {
pan_zoom_widget = pan_zoom_widget + "Zoom";
}
pan_zoom_widget = pan_zoom_widget + "Widget";
if (pan_zoom_widget != "MMWidget") {
eval(' map.addWidget( new ' + pan_zoom_widget + '() );');
}
if ( args.map_type ) {
map.addWidget( new MMMapTypeWidget() );
}
if ( args.overview ) {
map.addWidget( new MMOverviewWidget() );
}
},
addSmallControls: function() {
var map = this.maps[this.api];
smallPanzoomWidget = new MMSmallPanZoomWidget();
map.addWidget( smallPanzoomWidget );
this.addControlsArgs.pan = true;
this.addControlsArgs.zoom = 'small';
},
addLargeControls: function() {
var map = this.maps[this.api];
panzoomWidget = new MMPanZoomWidget();
map.addWidget( panzoomWidget );
this.addControlsArgs.pan = true; // keep the controls in case of swap
this.addControlsArgs.zoom = 'large';
},
addMapTypeControls: function() {
var map = this.maps[this.api];
map.addWidget( new MMMapTypeWidget() );
},
setCenterAndZoom: function(point, zoom) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
// TODO: toProprietary() here?
map.goToPosition( new MMLatLon( point.lat, point.lng ), zoom );
},
addMarker: function(marker, old) {
var map = this.maps[this.api];
var pin = marker.toProprietary(this.api);
map.addOverlay(pin);
return pin;
},
removeMarker: function(marker) {
var map = this.maps[this.api];
map.removeOverlay(marker.proprietary_marker);
},
declutterMarkers: function(opts) {
var map = this.maps[this.api];
map.declutterGroup(opts.groupName);
},
addPolyline: function(polyline, old) {
var map = this.maps[this.api];
var pl = polyline.toProprietary(this.api);
map.addOverlay( pl );
return pl;
},
removePolyline: function(polyline) {
var map = this.maps[this.api];
polyline.proprietary_polyline.remove();
},
getCenter: function() {
var point;
var map = this.maps[this.api];
var mmPt = map.getCurrentPosition();
point = new mxn.LatLonPoint();
point.fromProprietary(this.api, mmPt);
return point;
},
setCenter: function(point, options) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
if(options && options.pan) {
map.panToPosition(pt);
}
else {
map.goToPosition(pt);
}
},
setZoom: function(zoom) {
var map = this.maps[this.api];
map.setZoomFactor(zoom);
},
getZoom: function() {
var map = this.maps[this.api];
var zoom;
zoom = map.getZoomFactor();
return zoom;
},
getZoomLevelForBoundingBox: function( bbox ) {
var map = this.maps[this.api];
// NE and SW points from the bounding box.
var ne = bbox.getNorthEast();
var sw = bbox.getSouthWest();
var zoom;
var mmlocation = map.getAutoScaleLocation( [sw.toProprietary(this.api), ne.toProprietary(this.api)] );
zoom = mmlocation.zoom_factor;
return zoom;
},
setMapType: function(type) {
var map = this.maps[this.api];
var defaultType = null;
var requiredType = null;
var typeWeWillUse = null;
// check we can map the type
switch (type) {
case mxn.Mapstraction.ROAD:
requiredType = MM_WORLD_MAP;
break;
case mxn.Mapstraction.SATELLITE:
requiredType = MM_WORLD_AERIAL;
break;
case mxn.Mapstraction.HYBRID:
requiredType = MM_WORLD_HYBRID;
break;
}
var availableTypes = map.getAvailableMapTypes();
for (var i = 0; i < availableTypes.length; i++) {
if(requiredType && availableTypes[i] == requiredType) {
typeWeWillUse = requiredType;
break;
}
if(availableTypes[i] == MM_WORLD_MAP) {
defaultType = MM_WORLD_MAP;
}
}
typeWeWillUse = typeWeWillUse || defaultType;
if(typeWeWillUse !== null) {
map.setMapType(typeWeWillUse);
}
},
getMapType: function() {
var map = this.maps[this.api];
type = map.getMapType();
switch(type) {
case MM_WORLD_MAP:
return mxn.Mapstraction.ROAD;
case MM_WORLD_AERIAL:
return mxn.Mapstraction.SATELLITE;
case MM_WORLD_HYBRID:
return mxn.Mapstraction.HYBRID;
default:
return null;
}
},
getBounds: function () {
var map = this.maps[this.api];
var mmbox = map.getMapBounds();
sw = mmbox.getSouthWest();
ne = mmbox.getNorthEast();
return new mxn.BoundingBox(sw.lat, sw.lon, ne.lat, ne.lon);
},
setBounds: function(bounds){
var map = this.maps[this.api];
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var mmlocation = map.getAutoScaleLocation([sw.toProprietary(this.api), ne.toProprietary(this.api)]);
map.goToPosition(mmlocation.coords, mmlocation.zoom_factor);
},
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
var map = this.maps[this.api];
map.getContainer().appendChild(oContext.imgElm);
this.setImageOpacity(id, opacity);
this.setImagePosition(id);
var me = this;
map.addEventHandler( 'changeZoom', function(eventType, eventTarget, arg1, arg2, arg3) {
me.setImagePosition(id);
});
map.addEventHandler( 'drag', function(eventType, eventTarget, arg1, arg2, arg3) {
me.setImagePosition(id);
});
map.addEventHandler( 'endPan', function(eventType, eventTarget, arg1, arg2, arg3) {
me.setImagePosition(id);
});
},
setImagePosition: function(id, oContext) {
var map = this.maps[this.api];
var topLeftPoint; var bottomRightPoint;
topLeftPoint = map.geoPosToContainerPixels(new MMLatLon(oContext.latLng.top, oContext.latLng.left));
bottomRightPoint = map.geoPosToContainerPixels(new MMLatLon(oContext.latLng.bottom, oContext.latLng.right));
oContext.pixels.top = topLeftPoint.y;
oContext.pixels.left = topLeftPoint.x;
oContext.pixels.bottom = bottomRightPoint.y;
oContext.pixels.right = bottomRightPoint.x;
}
/* Not supported
addOverlay: function(url, autoCenterAndZoom) {
var map = this.maps[this.api];
// TODO: Add provider code
},
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
var map = this.maps[this.api];
// TODO: Add provider code
},
toggleTileLayer: function(tile_url) {
var map = this.maps[this.api];
// TODO: Add provider code
},
getPixelRatio: function() {
var map = this.maps[this.api];
// TODO: Add provider code
},
mousePosition: function(element) {
var map = this.maps[this.api];
// TODO: Add provider code
}
*/
},
LatLonPoint: {
toProprietary: function() {
return new MMLatLon(this.lat, this.lon);
},
fromProprietary: function(multimapPoint) {
this.lat = multimapPoint.lat;
this.lon = multimapPoint.lon;
}
},
Marker: {
toProprietary: function() {
//prepare our markeroptions
var mmmarkeropts = {};
if(this.iconUrl) {
mmmarkeropts.icon = new MMIcon(this.iconUrl);
if(this.iconSize) {
mmmarkeropts.icon.iconSize = new MMDimensions(this.iconSize[0], this.iconSize[1]);
}
else {
//mmmarkeropts.icon.iconSize = new MMDimensions(32, 32); //how to get this?
}
if(this.iconAnchor) {
mmmarkeropts.icon.iconAnchor = new MMPoint(this.iconAnchor[0], this.iconAnchor[1]);
}
if(this.groupName) {
mmmarkeropts.icon.groupName = this.groupName;
}
}
if(this.labelText) {
mmmarkeropts.label = this.labelText;
}
var mmmarker = new MMMarkerOverlay( this.location.toProprietary('multimap'), mmmarkeropts );
if(this.infoBubble) {
mmmarker.setInfoBoxContent(this.infoBubble);
}
if(this.infoDiv) { }
for (var key in this.attributes) {
if (this.attributes.hasOwnProperty(key)) {
mmmarker.setAttribute(key, this.attributes[key]);
}
}
return mmmarker;
},
openBubble: function() {
this.proprietary_marker.openInfoBox();
},
hide: function() {
this.proprietary_marker.setVisibility(false);
},
show: function() {
this.proprietary_marker.setVisibility(true);
}
/* Not supported
update: function() {
// TODO: Add provider code
}
*/
},
Polyline: {
toProprietary: function() {
var mmpolyline;
var mmpoints = [];
for (var i = 0, length = this.points.length ; i < length; i++){
mmpoints.push(this.points[i].toProprietary('multimap'));
}
mmpolyline = new MMPolyLineOverlay(mmpoints, this.color, this.opacity, this.width, this.closed, this.fillColor);
return mmpolyline;
}
}
});

View File

@ -1,458 +0,0 @@
/*
Copyright (c) 2010 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
mxn.register('openspace', {
Mapstraction: {
init: function(element, api) {
var me = this;
// create the map with no controls and don't centre popup info window
this.maps[api] = new OpenSpace.Map(element,{
controls: [],
centreInfoWindow: false
});
// note that these three controls are always there and the fact that
// there are three resident controls is used in addControls()
// enable map drag with mouse and keyboard
this.maps[api].addControl(new OpenLayers.Control.Navigation());
this.maps[api].addControl(new OpenLayers.Control.KeyboardDefaults());
// include copyright statement
this.maps[api].addControl(new OpenSpace.Control.CopyrightCollection());
this.maps[api].events.register(
"click",
this.maps[api],
function(evt) {
var point = this.getLonLatFromViewPortPx( evt.xy );
// convert to LatLonPoint
var llPoint = new mxn.LatLonPoint();
llPoint.fromProprietary(this.api, point);
me.clickHandler( llPoint.lat, llPoint.lon );
return false;
}
);
this.loaded[api] = true;
},
applyOptions: function(){
var map = this.maps[this.api];
// TODO: Add provider code
},
resizeTo: function(width, height){
this.currentElement.style.width = width;
this.currentElement.style.height = height;
this.maps[this.api].updateSize();
},
addControls: function( args ) {
var map = this.maps[this.api];
// remove existing controls but leave the basic navigation, keyboard
// and copyright controls in place these were added in addAPI and not
// normally be removed
for (var i = map.controls.length; i>3; i--) {
map.controls[i-1].deactivate();
map.removeControl(map.controls[i-1]);
}
// pan and zoom controls not available separately
if ( args.zoom == 'large') {
map.addControl(new OpenSpace.Control.LargeMapControl());
}
else if ( args.zoom == 'small' || args.pan ) {
map.addControl(new OpenSpace.Control.SmallMapControl());
}
if ( args.overview ) {
// this should work but as of OpenSpace 0.7.2 generates an error
// unless done before setCenterAndZoom
var osOverviewControl = new OpenSpace.Control.OverviewMap();
map.addControl(osOverviewControl);
osOverviewControl.maximizeControl();
}
if ( args.map_type ) {
// this is all you get with openspace, a control to switch on or
// off the layers and markers
// probably not much use to anybody
map.addControl(new OpenLayers.Control.LayerSwitcher());
}
},
addSmallControls: function() {
var map = this.maps[this.api];
map.addControl(new OpenSpace.Control.SmallMapControl());
},
addLargeControls: function() {
var map = this.maps[this.api];
map.addControl(new OpenSpace.Control.LargeMapControl());
},
addMapTypeControls: function() {
var map = this.maps[this.api];
// TODO: Add provider code
},
setCenterAndZoom: function(point, zoom) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
var oszoom = zoom-6;
if (oszoom<0) {
oszoom = 0;
}
else if (oszoom>10) {
oszoom = 10;
}
map.setCenter(pt, oszoom);
},
addMarker: function(marker, old) {
var map = this.maps[this.api];
var pin = marker.toProprietary(this.api);
map.addOverlay(pin);
return pin;
},
removeMarker: function(marker) {
var map = this.maps[this.api];
// TODO: Add provider code
},
declutterMarkers: function(opts) {
var map = this.maps[this.api];
// TODO: Add provider code
},
addPolyline: function(polyline, old) {
var map = this.maps[this.api];
var pl = polyline.toProprietary(this.api);
// TODO: Add provider code
return pl;
},
removePolyline: function(polyline) {
var map = this.maps[this.api];
// TODO: Add provider code
},
getCenter: function() {
var point;
var map = this.maps[this.api];
var pt = map.getCenter(); // an OpenSpace.MapPoint,
// UK National Grid
point = new mxn.LatLonPoint();
point.fromOpenSpace(pt); // convert to LatLonPoint
return point;
},
setCenter: function(point, options) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
if(options && options.pan) {
map.setCenter(pt.toProprietary(this.api));
}
else {
map.setCenter(pt.toProprietary(this.api));
}
},
setZoom: function(zoom) {
var map = this.maps[this.api];
var oszoom = zoom-6;
if (oszoom<0) {
oszoom = 0;
}
else if (oszoom>10) {
oszoom = 10;
}
map.zoomTo(oszoom);
},
getZoom: function() {
var map = this.maps[this.api];
var zoom;
zoom = map.zoom + 6; // convert to equivalent google zoom
return zoom;
},
getZoomLevelForBoundingBox: function( bbox ) {
var map = this.maps[this.api];
// NE and SW points from the bounding box.
var ne = bbox.getNorthEast();
var sw = bbox.getSouthWest();
var zoom;
var obounds = new OpenSpace.MapBounds();
obounds.extend(new mxn.LatLonPoint(sw.lat,sw.lon).toProprietary(this.api));
obounds.extend(new mxn.LatLonPoint(ne.lat,ne.lon).toProprietary(this.api));
zoom = map.getZoomForExtent(obounds) + 6; // get it and adjust to equivalent google zoom
return zoom;
},
setMapType: function(type) {
var map = this.maps[this.api];
switch(type) {
case mxn.Mapstraction.ROAD:
// TODO: Add provider code
break;
case mxn.Mapstraction.SATELLITE:
// TODO: Add provider code
break;
case mxn.Mapstraction.HYBRID:
// TODO: Add provider code
break;
default:
// TODO: Add provider code
}
},
getMapType: function() {
var map = this.maps[this.api];
// TODO: Add provider code
//return mxn.Mapstraction.ROAD;
//return mxn.Mapstraction.SATELLITE;
//return mxn.Mapstraction.HYBRID;
},
getBounds: function () {
var map = this.maps[this.api];
// array of openspace coords
// left, bottom, right, top
var olbox = map.calculateBounds().toArray();
var ossw = new OpenSpace.MapPoint( olbox[0], olbox[1] );
var osne = new OpenSpace.MapPoint( olbox[2], olbox[3] );
// convert to LatLonPoints
var sw = new mxn.LatLonPoint();
sw.fromOpenSpace(ossw);
var ne = new mxn.LatLonPoint();
ne.fromOpenSpace(osne);
return new mxn.BoundingBox(sw.lat, sw.lon, ne.lat, ne.lon);
},
setBounds: function(bounds){
var map = this.maps[this.api];
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var obounds = new OpenSpace.MapBounds();
obounds.extend(new mxn.LatLonPoint(sw.lat,sw.lon).toProprietary(this.api));
obounds.extend(new mxn.LatLonPoint(ne.lat,ne.lon).toProprietary(this.api));
map.zoomToExtent(obounds);
},
addImageOverlay: function(id, src, opacity, west, south, east,
north, oContext) {
var map = this.maps[this.api];
// TODO: Add provider code
},
setImagePosition: function(id, oContext) {
var map = this.maps[this.api];
var topLeftPoint; var bottomRightPoint;
// TODO: Add provider code
//oContext.pixels.top = ...;
//oContext.pixels.left = ...;
//oContext.pixels.bottom = ...;
//oContext.pixels.right = ...;
},
addOverlay: function(url, autoCenterAndZoom) {
var map = this.maps[this.api];
// TODO: Add provider code
},
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
var map = this.maps[this.api];
// TODO: Add provider code
},
toggleTileLayer: function(tile_url) {
var map = this.maps[this.api];
// TODO: Add provider code
},
getPixelRatio: function() {
var map = this.maps[this.api];
// TODO: Add provider code
},
mousePosition: function(element) {
var map = this.maps[this.api];
try {
map.events.register('mousemove', map, function (e) {
var lonLat = map.getLonLatFromViewPortPx(e.xy);
var lon = lonLat.lon * (180.0 / 20037508.34);
var lat = lonLat.lat * (180.0 / 20037508.34);
lat = (180/Math.PI)*(2*Math.atan(Math.exp(lat*Math.PI/180))-(Math.PI/2));
var loc = numFormatFloat(lat,4) + ' / ' + numFormatFloat(lon,4);
// numFormatFloat(X,4) simply formats floating point 'X' to
// 4 dec places
locDisp.innerHTML = loc;
});
locDisp.innerHTML = '0.0000 / 0.0000';
} catch (x) {
alert("Error: " + x);
}
// TODO: Add provider code
}
},
LatLonPoint: {
toProprietary: function() {
var lonlat = new OpenLayers.LonLat(this.lon, this.lat);
// need to convert to UK national grid
var gridProjection = new OpenSpace.GridProjection();
return gridProjection.getMapPointFromLonLat(lonlat);
// on OpenSpace.MapPoint
},
fromProprietary: function(osPoint) {
var gridProjection = new OpenSpace.GridProjection();
var olpt = gridProjection.getLonLatFromMapPoint(osPoint);
// an OpenLayers.LonLat
this.lon = olpt.lon;
this.lat = olpt.lat;
}
},
Marker: {
toProprietary: function() {
var size, anchor, icon;
if(this.iconSize) {
size = new OpenLayers.Size(this.iconSize[0],
this.iconSize[1]);
}
else {
size = new OpenLayers.Size(20,25);
}
if(this.iconAnchor) {
anchor = new OpenLayers.Pixel(this.iconAnchor[0],
this.iconAnchor[1]);
}
else {
// FIXME: hard-coding the anchor point
anchor = new OpenLayers.Pixel(-(size.w/2), -size.h);
}
if(this.iconUrl) {
icon = new OpenSpace.Icon(this.iconUrl, size, anchor);
}
else { // leave at default OpenSpace icon
}
// This requires an OpenLayers specific hack, doesn't work when
// not including OpenLayers.js
OpenLayers.Marker.Label(this.location.toProprietary(this.api), icon,
this.labelText, {mouseOver:true,tooltipsFormat:true});
var marker = new OpenLayers.Marker(this.location.toProprietary(this.api), icon);
return marker;
},
openBubble: function() {
// TODO: Add provider code
},
hide: function() {
// TODO: Add provider code
},
show: function() {
// TODO: Add provider code
},
update: function() {
// TODO: Add provider code
}
},
Polyline: {
toProprietary: function() {
var ospolyline;
var ospoints = [];
for (var i = 0, length = this.points.length ; i< length; i++){
// convert each point to OpenSpace.MapPoint
var ospoint = this.points[i].toProprietary(this.api);
var olgpoint = new OpenLayers.Geometry.Point(ospoint.getEasting(),ospoint.getNorthing());
ospoints.push(olgpoint);
}
if (this.closed) {
ospolyline = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LinearRing(ospoints),
null,
{
fillColor: this.color,
strokeColor: this.color,
strokeOpacity: this.opacity,
fillOpacity: this.opacity,
strokeWidth: this.width
}
);
}
else {
ospolyline = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(ospoints),
null,
{
fillColor: 0,
strokeColor: this.color,
strokeOpacity: this.opacity,
fillOpacity: 0,
strokeWidth: this.width
}
);
}
return ospolyline;
},
show: function() {
// TODO: Add provider code
},
hide: function() {
// TODO: Add provider code
}
}
});

View File

@ -1,399 +0,0 @@
/*
Copyright (c) 2010 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
mxn.register('yahoo', {
Mapstraction: {
init: function(element,api) {
var me = this;
if (YMap) {
this.maps[api] = new YMap(element);
YEvent.Capture(this.maps[api], EventsList.MouseClick, function(event,location) {
me.clickHandler(location.Lat, location.Lon, location, me);
me.click.fire({'location': new mxn.LatLonPoint(location.Lat, location.Lon)});
});
YEvent.Capture(this.maps[api], EventsList.changeZoom, function() {
me.moveendHandler(me);
me.changeZoom.fire();
});
YEvent.Capture(this.maps[api], EventsList.endPan, function() {
me.moveendHandler(me);
me.endPan.fire();
});
YEvent.Capture(this.maps[api], EventsList.endAutoPan, function() {
me.endPan.fire();
});
this.loaded[api] = true;
me.load.fire();
}
else {
alert(api + ' map script not imported');
}
},
applyOptions: function(){
/*
if (this.options.enableDragging) {
map.enableDragMap();
} else {
map.disableDragMap();
}
*/
},
resizeTo: function(width, height){
this.maps[this.api].resizeTo(new YSize(width,height));
},
addControls: function( args ) {
var map = this.maps[this.api];
if (args.pan) {
map.addPanControl();
}
else {
// Yahoo doesn't check the pan control is there before trying to remove it
// so throws an exception :(
map.addPanControl();
map.removePanControl();
}
if (args.zoom == 'large') {
map.addZoomLong();
}
else if ( args.zoom == 'small' ) {
map.addZoomShort();
}
else {
map.removeZoomScale();
}
},
addSmallControls: function() {
var map = this.maps[this.api];
map.addPanControl();
map.addZoomShort();
this.addControlsArgs.pan = true;
this.addControlsArgs.zoom = 'small';
},
addLargeControls: function() {
var map = this.maps[this.api];
map.addPanControl();
map.addZoomLong();
this.addControlsArgs.pan = true; // keep the controls in case of swap
this.addControlsArgs.zoom = 'large';
},
addMapTypeControls: function() {
var map = this.maps[this.api];
map.addTypeControl();
},
dragging: function(on) {
var map = this.maps[this.api];
if (on) {
map.enableDragMap();
} else {
map.disableDragMap();
}
},
setCenterAndZoom: function(point, zoom) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
var yzoom = 18 - zoom; // maybe?
map.drawZoomAndCenter(pt,yzoom);
},
addMarker: function(marker, old) {
var map = this.maps[this.api];
var pin = marker.toProprietary(this.api);
map.addOverlay(pin);
YEvent.Capture(pin, EventsList.MouseClick, function() {
marker.click.fire();
});
YEvent.Capture(pin, EventsList.openSmartWindow, function() {
marker.openInfoBubble.fire();
});
YEvent.Capture(pin, EventsList.closeSmartWindow, function() {
marker.closeInfoBubble.fire();
});
return pin;
},
removeMarker: function(marker) {
var map = this.maps[this.api];
map.removeOverlay(marker.proprietary_marker);
},
declutterMarkers: function(opts) {
throw 'Not supported';
},
addPolyline: function(polyline, old) {
var map = this.maps[this.api];
var pl = polyline.toProprietary(this.api);
map.addOverlay(pl);
return pl;
},
removePolyline: function(polyline) {
var map = this.maps[this.api];
map.removeOverlay(polyline.proprietary_polyline);
},
getCenter: function() {
var map = this.maps[this.api];
var pt = map.getCenterLatLon();
var point = new mxn.LatLonPoint(pt.Lat, pt.Lon);
return point;
},
setCenter: function(point, options) {
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
map.panToLatLon(pt);
},
setZoom: function(zoom) {
var map = this.maps[this.api];
var yzoom = 18 - zoom; // maybe?
map.setZoomLevel(yzoom);
},
getZoom: function() {
var map = this.maps[this.api];
return 18 - map.getZoomLevel();
},
getZoomLevelForBoundingBox: function( bbox ) {
throw 'Not implemented';
},
setMapType: function(type) {
var map = this.maps[this.api];
switch(type) {
case mxn.Mapstraction.ROAD:
map.setMapType(YAHOO_MAP_REG);
break;
case mxn.Mapstraction.SATELLITE:
map.setMapType(YAHOO_MAP_SAT);
break;
case mxn.Mapstraction.HYBRID:
map.setMapType(YAHOO_MAP_HYB);
break;
default:
map.setMapType(YAHOO_MAP_REG);
}
},
getMapType: function() {
var map = this.maps[this.api];
var type = map.getCurrentMapType();
switch(type) {
case YAHOO_MAP_REG:
return mxn.Mapstraction.ROAD;
case YAHOO_MAP_SAT:
return mxn.Mapstraction.SATELLITE;
case YAHOO_MAP_HYB:
return mxn.Mapstraction.HYBRID;
default:
return null;
}
},
getBounds: function () {
var map = this.maps[this.api];
var ybox = map.getBoundsLatLon();
return new mxn.BoundingBox(ybox.LatMin, ybox.LonMin, ybox.LatMax, ybox.LonMax);
},
setBounds: function(bounds){
var map = this.maps[this.api];
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
if(sw.lon > ne.lon) {
sw.lon -= 360;
}
var center = new YGeoPoint((sw.lat + ne.lat)/2, (ne.lon + sw.lon)/2);
var container = map.getContainerSize();
for(var zoom = 1 ; zoom <= 17 ; zoom++){
var sw_pix = mxn.util.convertLatLonXY_Yahoo(sw,zoom);
var ne_pix = mxn.util.convertLatLonXY_Yahoo(ne,zoom);
if(sw_pix.x > ne_pix.x) {
sw_pix.x -= (1 << (26 - zoom)); //earth circumference in pixel
}
if(Math.abs(ne_pix.x - sw_pix.x) <= container.width &&
Math.abs(ne_pix.y - sw_pix.y) <= container.height){
map.drawZoomAndCenter(center, zoom); //Call drawZoomAndCenter here: OK if called multiple times anyway
break;
}
}
},
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
throw 'Not implemented';
},
setImagePosition: function(id) {
throw 'Not implemented';
},
addOverlay: function(url, autoCenterAndZoom) {
var map = this.maps[this.api];
map.addOverlay(new YGeoRSS(url));
},
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
throw 'Not implemented';
},
toggleTileLayer: function(tile_url) {
throw 'Not implemented';
},
getPixelRatio: function() {
throw 'Not implemented';
},
mousePosition: function(element) {
throw 'Not implemented';
}
},
LatLonPoint: {
toProprietary: function() {
return new YGeoPoint(this.lat,this.lon);
},
fromProprietary: function(yahooPoint) {
this.lat = yahooPoint.Lat;
this.lon = yahooPoint.Lon;
}
},
Marker: {
toProprietary: function() {
var ymarker, size;
var infoBubble, event_action, infoDiv, div;
if(this.iconSize) {
size = new YSize(this.iconSize[0], this.iconSize[1]);
}
if(this.iconUrl) {
if(this.iconSize){
ymarker = new YMarker(this.location.toProprietary('yahoo'), new YImage(this.iconUrl, size));
}
else {
ymarker = new YMarker(this.location.toProprietary('yahoo'), new YImage(this.iconUrl));
}
}
else {
if(this.iconSize) {
ymarker = new YMarker(this.location.toProprietary('yahoo'), null, size);
}
else {
ymarker = new YMarker(this.location.toProprietary('yahoo'));
}
}
if(this.labelText) {
ymarker.addLabel(this.labelText);
}
if(this.infoBubble) {
infoBubble = this.infoBubble;
if(this.hover) {
event_action = EventsList.MouseOver;
}
else {
event_action = EventsList.MouseClick;
}
YEvent.Capture(ymarker, event_action, function() {
ymarker.openSmartWindow(infoBubble);
});
}
if(this.infoDiv) {
infoDiv = this.infoDiv;
div = this.div;
if(this.hover) {
event_action = EventsList.MouseOver;
}
else {
event_action = EventsList.MouseClick;
}
YEvent.Capture(ymarker, event_action, function() {
document.getElementById(div).innerHTML = infoDiv;
});
}
return ymarker;
},
openBubble: function() {
var ypin = this.proprietary_marker;
ypin.openSmartWindow(this.infoBubble);
},
hide: function() {
this.proprietary_marker.hide();
},
show: function() {
this.proprietary_marker.unhide();
},
update: function() {
throw 'Not implemented';
}
},
Polyline: {
toProprietary: function() {
var ypolyline;
var ypoints = [];
for (var i = 0, length = this.points.length ; i< length; i++){
ypoints.push(this.points[i].toProprietary('yahoo'));
}
ypolyline = new YPolyline(ypoints,this.color,this.width,this.opacity);
return ypolyline;
},
show: function() {
throw 'Not implemented';
},
hide: function() {
throw 'Not implemented';
}
}
});