codesite-noreply at google.com
2010-May-19 23:34 UTC
[Mapstraction] [mapstraction] r79 committed - These files all now passing JSLint.
Revision: 79
Author: dezfowler
Date: Wed May 19 16:33:35 2010
Log: These files all now passing JSLint.
http://code.google.com/p/mapstraction/source/detail?r=79
Modified:
/trunk/build.xml
/trunk/source/mxn.geocommons.core.js
/trunk/source/mxn.google.geocoder.js
/trunk/source/mxn.microsoft.core.js
/trunk/source/mxn.openlayers.core.js
/trunk/source/mxn.openspace.core.js
/trunk/source/mxn.yahoo.core.js
/trunk/tests/index.htm
======================================--- /trunk/build.xml Sun Oct 4 02:16:15
2009
+++ /trunk/build.xml Wed May 19 16:33:35 2010
@@ -26,54 +26,28 @@
<!-- copy our sources in -->
<echo>--- COPY SOURCES ---</echo>
- <copy todir="${build.dir}" overwrite="true"
flatten="true">
- <resources>
- <file file="${source}/mxn.js"/>
- <file file="${source}/mxn.core.js"/>
- <file file="${source}/mxn.(provider).core.js"/>
- <file file="${source}/mxn.cloudmade.core.js"/>
- <file file="${source}/mxn.google.core.js"/>
- <file file="${source}/mxn.googlev3.core.js"/>
- <file file="${source}/mxn.microsoft.core.js"/>
- <file file="${source}/mxn.openlayers.core.js"/>
- <file file="${source}/mxn.yahoo.core.js"/>
- </resources>
+ <copy todir="${build.dir}">
+ <fileset dir="${source}">
+ <exclude name="*(provider)*"/>
+ </fileset>
</copy>
<!-- lint our sources -->
<echo>--- LINT ---</echo>
- <!-- Hopefully get the whole lot linting eventually
- <java jar="tools/rhino/js.jar" fork="true"
failonerror="true">
- <arg value="tools/jslint/jslint.js"/>
- <arg value="${build.dir}/*.js"/>
- </java>
- -->
-
- <java jar="tools/rhino/js.jar" fork="true"
failonerror="true">
- <arg value="tools/jslint/jslint.js"/>
- <arg value="${build.dir}/mxn.js"/>
- </java>
- <java jar="tools/rhino/js.jar" fork="true"
failonerror="true">
- <arg value="tools/jslint/jslint.js"/>
- <arg value="${build.dir}/mxn.core.js"/>
- </java>
- <java jar="tools/rhino/js.jar" fork="true"
failonerror="true">
- <arg value="tools/jslint/jslint.js"/>
- <arg value="${build.dir}/mxn.(provider).core.js"/>
- </java>
- <java jar="tools/rhino/js.jar" fork="true"
failonerror="true">
- <arg value="tools/jslint/jslint.js"/>
- <arg value="${build.dir}/mxn.cloudmade.core.js"/>
- </java>
- <java jar="tools/rhino/js.jar" fork="true"
failonerror="true">
- <arg value="tools/jslint/jslint.js"/>
- <arg value="${build.dir}/mxn.google.core.js"/>
- </java>
- <java jar="tools/rhino/js.jar" fork="true"
failonerror="true">
- <arg value="tools/jslint/jslint.js"/>
- <arg value="${build.dir}/mxn.googlev3.core.js"/>
- </java>
+ <for param="file">
+ <path>
+ <fileset dir="${build.dir}" includes="*.js"/>
+ </path>
+ <sequential>
+ <java jar="tools/rhino/js.jar" fork="true"
failonerror="true">
+ <arg value="tools/jslint/jslint.js"/>
+ <arg value="@{file}"/>
+ </java>
+ </sequential>
+ </for>
+
+
<!-- document our sources -->
<echo>--- DOC ---</echo>
======================================--- /trunk/source/mxn.geocommons.core.js
Mon Dec 14 17:04:05 2009
+++ /trunk/source/mxn.geocommons.core.js Wed May 19 16:33:35 2010
@@ -36,7 +36,8 @@
F1.Maker.finder_host = f1_finder_host;
F1.Maker.maker_host = f1_maker_host;
- new F1.Maker.Map({
+ // we don''t use this object but assign it to dummy for JSLint
+ var dummy = new F1.Maker.Map({
dom_id: this.element.id,
flashvars: {},
onload: function(map){
@@ -159,15 +160,18 @@
getMapType: function() {
var map = this.maps[this.api];
- switch(map.getMapProvider) {
- case "OpenStreetMap (Road)":
- break;
- }
- // TODO: Add provider code
-
- //return mxn.Mapstraction.ROAD;
- //return mxn.Mapstraction.SATELLITE;
- //return mxn.Mapstraction.HYBRID;
+
+ // TODO: I don''t thick this is correct -Derek
+ switch(map.getMapProvider()) {
+ case "OpenStreetMap (road)":
+ return mxn.Mapstraction.ROAD;
+ case "BlueMarble":
+ return mxn.Mapstraction.SATELLITE;
+ case "Google Hybrid":
+ return mxn.Mapstraction.HYBRID;
+ default:
+ return null;
+ }
},
@@ -201,8 +205,8 @@
return;
}
// Try if we''ve been given either a string of the ID or a URL
- match = url.match(/^(\d+)$/)
- if(match != null){
+ match = url.match(/^(\d+)$/);
+ if(match !== null){
match = url.match(/^.*?maps\/(\d+)(\?\(\[?(.*?)\]?\))?$/);
}
======================================--- /trunk/source/mxn.google.geocoder.js
Mon Dec 14 17:04:05 2009
+++ /trunk/source/mxn.google.geocoder.js Wed May 19 16:33:35 2010
@@ -26,8 +26,8 @@
function MapstractionGeocoder(callback, api, error_callback) {
this.api = api;
this.callback = callback;
- this.geocoders = new Object();
- if(error_callback == null) {
+ this.geocoders = {};
+ if(error_callback === null) {
this.error_callback = this.geocode_error
} else {
this.error_callback = error_callback;
======================================--- /trunk/source/mxn.microsoft.core.js
Thu Jan 14 13:41:14 2010
+++ /trunk/source/mxn.microsoft.core.js Wed May 19 16:33:35 2010
@@ -32,7 +32,7 @@
me.load.fire();
}
else{
- alert(api + '' map script not imported'')
+ throw api + '' map script not imported'';
}
},
@@ -56,14 +56,14 @@
map.SetDashboardSize(VEDashboardSize.Normal);
}
else {
- map.SetDashboardSize(VEDashboardSize.Tiny)
+ map.SetDashboardSize(VEDashboardSize.Tiny);
}
if (args.zoom == ''large'') {
- map.SetDashboardSize(VEDashboardSize.Small)
+ map.SetDashboardSize(VEDashboardSize.Small);
}
else if ( args.zoom == ''small'' ) {
- map.SetDashboardSize(VEDashboardSize.Tiny)
+ map.SetDashboardSize(VEDashboardSize.Tiny);
}
else {
map.HideDashboard();
@@ -79,7 +79,7 @@
addLargeControls: function() {
var map = this.maps[this.api];
map.SetDashboardSize(VEDashboardSize.Normal);
- this.addControlsArgs.pan=true;
+ this.addControlsArgs.pan = true;
this.addControlsArgs.zoom = ''large'';
},
@@ -91,10 +91,10 @@
dragging: function(on) {
var map = this.maps[this.api];
- if(on){
+ if (on) {
map.enableDragMap();
}
- else{
+ else {
map.disableDragMap();
}
},
@@ -218,10 +218,7 @@
return mxn.Mapstraction.HYBRID;
default:
return null;
-
- }
-
-
+ }
},
getBounds: function () {
@@ -281,7 +278,7 @@
mousePosition: function(element) {
var locDisp = document.getElementById(element);
- if (locDisp != null) {
+ if (locDisp !== null) {
var map = this.maps[this.api];
map.AttachEvent("onmousemove", function(veEvent){
var latlon = map.PixelToLatLong(new VEPixel(veEvent.mapX,
veEvent.mapY));
======================================--- /trunk/source/mxn.openlayers.core.js
Thu Jan 14 13:41:14 2010
+++ /trunk/source/mxn.openlayers.core.js Wed May 19 16:33:35 2010
@@ -15,7 +15,7 @@
}
);
- this.layers[''osmmapnik''] = new OpenLayers.Layer.TMS(
+ this.layers.osmmapnik = new OpenLayers.Layer.TMS(
''OSM Mapnik'',
[
"http://a.tile.openstreetmap.org/",
@@ -46,7 +46,7 @@
}
);
- this.layers[''osm''] = new OpenLayers.Layer.TMS(
+ this.layers.osm = new OpenLayers.Layer.TMS(
''OSM'',
[
"http://a.tah.openstreetmap.org/Tiles/tile.php/",
@@ -77,8 +77,8 @@
}
);
- this.maps[api].addLayer(this.layers[''osmmapnik'']);
- this.maps[api].addLayer(this.layers[''osm'']);
+ this.maps[api].addLayer(this.layers.osmmapnik);
+ this.maps[api].addLayer(this.layers.osm);
this.loaded[api] = true;
},
@@ -164,11 +164,11 @@
addMarker: function(marker, old) {
var map = this.maps[this.api];
var pin = marker.toProprietary(this.api);
- if (!this.layers[''markers'']) {
- this.layers[''markers''] = new
OpenLayers.Layer.Markers(''markers'');
- map.addLayer(this.layers[''markers'']);
- }
- this.layers[''markers''].addMarker(pin);
+ if (!this.layers.markers) {
+ this.layers.markers = new
OpenLayers.Layer.Markers(''markers'');
+ map.addLayer(this.layers.markers);
+ }
+ this.layers.markers.addMarker(pin);
return pin;
},
@@ -176,7 +176,7 @@
removeMarker: function(marker) {
var map = this.maps[this.api];
var pin = marker.toProprietary(this.api);
- this.layers[''markers''].removeMarker(pin);
+ this.layers.markers.removeMarker(pin);
pin.destroy();
},
@@ -197,26 +197,28 @@
var map = this.maps[this.api];
var pl = polyline.toProprietary(this.api);
- if (!this.layers[''polylines'']) {
- this.layers[''polylines''] = new
OpenLayers.Layer.Vector(''polylines'');
- map.addLayer(this.layers[''polylines'']);
+ if (!this.layers.polylines) {
+ this.layers.polylines = new
OpenLayers.Layer.Vector(''polylines'');
+ map.addLayer(this.layers.polylines);
}
polyline.setChild(pl);
- this.layers[''polylines''].addFeatures([pl]);
+ this.layers.polylines.addFeatures([pl]);
return pl;
},
removePolyline: function(polyline) {
var map = this.maps[this.api];
var pl = polyline.toProprietary(this.api);
- this.layers[''polylines''].removeFeatures([pl]);
+ this.layers.polylines.removeFeatures([pl]);
},
removeAllPolylines: function() {
var olpolylines = [];
for(var i = 0, length = this.polylines.length; i < length; i++){
olpolylines.push(this.polylines[i].toProprietary(this.api));
}
- if (this.layers[''polylines''])
this.layers[''polylines''].removeFeatures(olpolylines);
+ if (this.layers.polylines) {
+ this.layers.polylines.removeFeatures(olpolylines);
+ }
},
getCenter: function() {
======================================--- /trunk/source/mxn.openspace.core.js
Wed Mar 24 11:33:58 2010
+++ /trunk/source/mxn.openspace.core.js Wed May 19 16:33:35 2010
@@ -2,459 +2,451 @@
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
- },
-
- removeAllMarkers: function() {
- 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;
+ 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
+ },
+
+ removeAllMarkers: function() {
+ 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;
+ 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
- }
+ },
+
+ 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;
- }
-
+ 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],
+
+ 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
- // if (this.labelText) {
- // var marker = new
- OpenLayers.Marker.Label(this.location.toProprietary(this.api), icon,
+ }
+ 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});
- // }
- // else {
- 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
- }
+
+ 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
- }
-
-}
-
+ 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
+ }
+
+}
+
});
======================================--- /trunk/source/mxn.yahoo.core.js Mon
Dec 14 17:04:05 2009
+++ /trunk/source/mxn.yahoo.core.js Wed May 19 16:33:35 2010
@@ -235,8 +235,8 @@
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){
+ 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;
}
======================================--- /trunk/tests/index.htm Mon Dec 14
17:04:05 2009
+++ /trunk/tests/index.htm Wed May 19 16:33:35 2010
@@ -5,11 +5,9 @@
<title>Mapstraction V2 demo</title>
<script type="text/javascript"
src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAY70wuSo0zF3ZtJVp5bDm1BS1Y2ErAqCHV5rDhHSzgjy23KqwdRRaoSBuZk72oDzzAYxVBjtsLqSmTw"></script>
-
<script type="text/javascript"
src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=5wTxDW_V34GQjK.7glLG6OnJSRxCvfLj7ktMsuOoR42Gkm16vDVEjjw6FGWJ1Gky"></script>
- <script type="text/javascript"
src="http://openlayers.org/api/OpenLayers.js"></script>
-
- <script src="../source/mxn.js?(google,yahoo,openlayers)"
type="text/javascript"></script>
+
+ <script src="../source/mxn.js?(google,yahoo)"
type="text/javascript"></script>
<!--<script src="domReady.js"
type="text/javascript"></script>-->
@@ -94,6 +92,12 @@
action: function(){
m.setZoom(8);
}
+ },
+ {
+ desc: ''Change type'',
+ action: function(){
+ m.setMapType(mxn.Mapstraction.SATELLITE);
+ }
},
{
desc: ''Add marker'',
@@ -162,12 +166,7 @@
m.swap(''map'', ''yahoo'');
}
},
- {
- desc: ''Swap API (openlayers)'',
- action: function(){
- m.swap(''map'', ''openlayers'');
- }
- },
+
{ desc: ''Done.'', action: function(){} }
];