codesite-noreply at google.com
2009-Dec-15 01:04 UTC
[Mapstraction] [mapstraction] r69 committed - - Brought file formatting back in line (tabs rather than spaces for in...
Revision: 69
Author: dezfowler
Date: Mon Dec 14 17:04:05 2009
Log: - Brought file formatting back in line (tabs rather than spaces for
indentation and Windows format line endings)
- Also made some general readability changes
- Removed "return" statements from deferred function calls as a
deferrable
function can never return a value
- Added documentation comments to properties of Mapstraction class
- Fixed a couple of linting issues
- Fixed tests/index.htm
http://code.google.com/p/mapstraction/source/detail?r=69
Modified:
/trunk/source/mxn.cloudmade.core.js
/trunk/source/mxn.core.js
/trunk/source/mxn.geocommons.core.js
/trunk/source/mxn.google.core.js
/trunk/source/mxn.google.geocoder.js
/trunk/source/mxn.googlev3.core.js
/trunk/source/mxn.js
/trunk/source/mxn.microsoft.core.js
/trunk/source/mxn.openlayers.core.js
/trunk/source/mxn.yahoo.core.js
/trunk/tests/index.htm
======================================--- /trunk/source/mxn.cloudmade.core.js
Wed Nov 4 08:34:55 2009
+++ /trunk/source/mxn.cloudmade.core.js Mon Dec 14 17:04:05 2009
@@ -1,357 +1,357 @@
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);
- }
- });
- },
-
- 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);
- },
-
- removeAllMarkers: function() {
- // Done in mxn.core.js
- },
-
- 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) {
- return new mxn.LatLonPoint(point.lat(),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();
- }
-
- }
+ 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);
+ }
+ });
+ },
+
+ 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);
+ },
+
+ removeAllMarkers: function() {
+ // Done in mxn.core.js
+ },
+
+ 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) {
+ return new mxn.LatLonPoint(point.lat(),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();
+ }
+
+ }
});
======================================--- /trunk/source/mxn.core.js Sun Dec 13
11:10:14 2009
+++ /trunk/source/mxn.core.js Mon Dec 14 17:04:05 2009
@@ -25,26 +25,65 @@
* @exports Mapstraction as mxn.Mapstraction
*/
var Mapstraction = mxn.Mapstraction = function(element, api, debug) {
- if (!api){
+ if (!api){
api = mxn.util.getAvailableProviders()[0];
}
+
+ /**
+ * The name of the active API.
+ * @name mxn.Mapstraction#api
+ * @type {String}
+ */
this.api = api;
+
this.maps = {};
+
+ /**
+ * The DOM element containing the map.
+ * @name mxn.Mapstraction#currentElement
+ * @property
+ * @type {DOMElement}
+ */
this.currentElement = $m(element);
+
this.eventListeners = [];
+
+ /**
+ * The markers currently loaded.
+ * @name mxn.Mapstraction#markers
+ * @property
+ * @type {Array}
+ */
this.markers = [];
this.layers = [];
+
+ /**
+ * The polylines currently loaded.
+ * @name mxn.Mapstraction#polylines
+ * @property
+ * @type {Array}
+ */
this.polylines = [];
+
this.images = [];
- this.controls = [];
+ this.controls = [];
this.loaded = {};
this.onload = {};
- this.loaded[api] = true;
- this.onload[api] = [];
-
+ this.onload[api] = [];
+
+ /**
+ * The original element value passed to the constructor.
+ * @name mxn.Mapstraction#element
+ * @property
+ * @type {String|DOMElement}
+ */
this.element = element;
- // option defaults
+ /**
+ * Options defaults.
+ * @name mxn.Mapstraction#options
+ * @property {Object}
+ */
this.options = {
enableScrollWheelZoom: false,
enableDragging: true
@@ -352,8 +391,9 @@
this.currentElement.style.display = ''block'';
this.api = api;
-
- if (this.maps[this.api] === undefined) {
+ this.onload[api] = [];
+
+ if (this.maps[this.api] === undefined) {
init.apply(this);
this.setCenterAndZoom(center,zoom);
@@ -407,7 +447,7 @@
* @param {Boolean} set deferred to true to turn on deferment
*/
Mapstraction.prototype.setDefer = function(deferred){
- this.loaded[this.api] = !deferred;
+ this.loaded[this.api] = !deferred;
};
/**
@@ -417,9 +457,9 @@
* implementation loads the map, it calls this.runDeferred and any queued
calls will be run.
*/
Mapstraction.prototype.runDeferred = function(){
- while(this.onload[this.api].length > 0) {
- this.onload[this.api].shift().apply(this); //run deferred calls
- }
+ while(this.onload[this.api].length > 0) {
+ this.onload[this.api].shift().apply(this); //run deferred calls
+ }
};
/////////////////////////
@@ -1725,7 +1765,7 @@
};
///////////////
-// Radius //
+// Radius //
///////////////
/**
@@ -1746,7 +1786,7 @@
var rad = Math.PI / 180;
this.calcs = [];
- for(var i = 0; i < 360; i += quality) {
+ for(var i = 0; i < 360; i += quality){
this.calcs.push([Math.cos(i * rad) / latConv, Math.sin(i * rad) /
lonConv]);
}
};
@@ -1758,7 +1798,7 @@
* @returns {Polyline} Polyline
*/
Radius.prototype.getPolyline = function(radius, colour) {
- var points = Array();
+ var points = [];
for(var i = 0; i < this.calcs.length; i++){
var point = new LatLonPoint(
======================================--- /trunk/source/mxn.geocommons.core.js
Sun Dec 13 11:10:07 2009
+++ /trunk/source/mxn.geocommons.core.js Mon Dec 14 17:04:05 2009
@@ -1,329 +1,330 @@
mxn.register(''geocommons'', {
- Mapstraction: {
-
- // These methods can be called anytime but will only execute
- // once the map has loaded.
- deferrable: {
- applyOptions: true,
- resizeTo: true,
- addControls: true,
- addSmallControls: true,
- addLargeControls: true,
- addMapTypeControls: true,
- dragging: true,
- setCenterAndZoom: true,
- getCenter: true,
- setCenter: true,
- setZoom: true,
- getZoom: true,
- getZoomLevelForBoundingBox: true,
- setMapType: true,
- getMapType: true,
- getBounds: true,
- setBounds: true,
- addTileLayer: true,
- toggleTileLayer: true,
- getPixelRatio: true,
- mousePosition: true
- },
-
- init: function(element, api) {
- var me = this;
- this.element = element;
- this.loaded[this.api] = false; // Loading will take a little
bit.
- F1.Maker.core_host = f1_core_host;
- F1.Maker.finder_host = f1_finder_host;
- F1.Maker.maker_host = f1_maker_host;
-
- new F1.Maker.Map({dom_id:this.element.id,
- flashvars: {},
- onload: function(map){
-
- me.maps[me.api] = map.swf; // Get the actual Flash
object
- me.loaded[me.api] = true;
- for (var i = 0; i < me.onload[me.api].length; i++) {
- me.onload[me.api][i]();
- }
- }});
-
- },
-
- applyOptions: function(){
- var map = this.maps[this.api];
-
- // TODO: Add provider code
- },
-
- resizeTo: function(width, height){
- var map = this.maps[this.api];
- map.setSize(width,height);
- },
-
- addControls: function( args ) {
- var map = this.maps[this.api];
- map.showControl("Zoom", args.zoom || false);
- map.showControl("Layers", args.layers || false);
- map.showControl("Styles", args.styles || false);
- map.showControl("Basemap", args.map_type || false);
- map.showControl("Legend", args.legend || false,
"open");
- // showControl("Legend", true, "close");
- },
-
- addSmallControls: function() {
- var map = this.maps[this.api];
- this.addControls({
- zoom: ''small'',
- legend: "open"
- });
- // showControl("Zoom", args.zoom);
- // showControl("Legend", args.legend, "open");
- },
-
- addLargeControls: function() {
- var map = this.maps[this.api];
- this.addControls({
- zoom: ''large'',
- layers: true,
- legend: "open"
- });
- },
-
- addMapTypeControls: function() {
- var map = this.maps[this.api];
-
- // TODO: Add provider code
- },
-
- dragging: function(on) {
- var map = this.maps[this.api];
-
- // TODO: Add provider code
- },
-
- setCenterAndZoom: function(point, zoom) {
- var map = this.maps[this.api];
- map.setCenterZoom(point.lat, point.lon,zoom);
- },
-
- getCenter: function() {
- var map = this.maps[this.api];
- var point = map.getCenterZoom()[0];
- return new mxn.LatLonPoint(point.lat,point.lon);
- },
-
- setCenter: function(point, options) {
- var map = this.maps[this.api];
- map.setCenter(point.lat, point.lon);
- },
-
- 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;
-
- // TODO: Add provider code
-
- return zoom;
- },
-
- setMapType: function(type) {
- var map = this.maps[this.api];
- switch(type) {
- case mxn.Mapstraction.ROAD:
- map.setMapProvider("OpenStreetMap (road)");
- break;
- case mxn.Mapstraction.SATELLITE:
- map.setMapProvider("BlueMarble");
- break;
- case mxn.Mapstraction.HYBRID:
- map.setMapProvider("Google Hybrid");
- break;
- default:
- map.setMapProvider(type);
- }
- },
-
- 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;
-
- },
-
- getBounds: function () {
- var map = this.maps[this.api];
- var extent = map.getExtent();
- return new mxn.BoundingBox( extent.northWest.lat,
extent.southEast.lon, extent.southEast.lat, extent.northWest.lon);
- },
-
- setBounds: function(bounds){
- var map = this.maps[this.api];
- var sw = bounds.getSouthWest();
- var ne = bounds.getNorthEast();
- map.setExtent(ne.lat,sw.lat,ne.lon,sw.lon);
-
- },
-
- addImageOverlay: function(id, src, opacity, west, south, east,
north, oContext) {
- var map = this.maps[this.api];
-
- // TODO: Add provider code
- },
-
- // URL in this case is either a Maker map ID or the full URL to
the Maker Map
- addOverlay: function(url, autoCenterAndZoom) {
- var map = this.maps[this.api];
- var match;
-
- if(typeof(url) === "number") {
- map.loadMap(url);
- 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(/^.*?maps\/(\d+)(\?\(\[?(.*?)\]?\))?$/);
- }
-
- map.loadMap(match[1]);
- },
-
- 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
- },
- addMarker: function(marker, old) {
- var map = this.maps[this.api];
- var pin = marker.toProprietary(this.api);
- // TODO: Add provider code
- // map.addOverlay(pin);
- return pin;
- },
-
- removeMarker: function(marker) {
- var map = this.maps[this.api];
- // TODO: Add provider code
-
- },
-
- removeAllMarkers: function() {
- // Done in mxn.core.js
- },
-
- 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
- // map.addOverlay(pl);
- return pl;
- },
-
- removePolyline: function(polyline) {
- var map = this.maps[this.api];
- // TODO: Add provider code
- }
-
-
- },
-
- LatLonPoint: {
-
- toProprietary: function() {
- // TODO: Add provider code
- return {};
- },
-
- fromProprietary: function(googlePoint) {
- // TODO: Add provider code
- }
-
- },
-
- Marker: {
-
- toProprietary: function() {
- // TODO: Add provider code
- return {};
- },
-
- 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() {
- return {};
- // TODO: Add provider code
- },
-
- show: function() {
- // TODO: Add provider code
- },
-
- hide: function() {
- // TODO: Add provider code
- }
-
- }
+ Mapstraction: {
+
+ // These methods can be called anytime but will only execute
+ // once the map has loaded.
+ deferrable: {
+ applyOptions: true,
+ resizeTo: true,
+ addControls: true,
+ addSmallControls: true,
+ addLargeControls: true,
+ addMapTypeControls: true,
+ dragging: true,
+ setCenterAndZoom: true,
+ getCenter: true,
+ setCenter: true,
+ setZoom: true,
+ getZoom: true,
+ getZoomLevelForBoundingBox: true,
+ setMapType: true,
+ getMapType: true,
+ getBounds: true,
+ setBounds: true,
+ addTileLayer: true,
+ toggleTileLayer: true,
+ getPixelRatio: true,
+ mousePosition: true
+ },
+
+ init: function(element, api) {
+ var me = this;
+ this.element = element;
+ this.loaded[this.api] = false; // Loading will take a little bit.
+ F1.Maker.core_host = f1_core_host;
+ F1.Maker.finder_host = f1_finder_host;
+ F1.Maker.maker_host = f1_maker_host;
+
+ new F1.Maker.Map({
+ dom_id: this.element.id,
+ flashvars: {},
+ onload: function(map){
+ me.maps[me.api] = map.swf; // Get the actual Flash object
+ me.loaded[me.api] = true;
+ for (var i = 0; i < me.onload[me.api].length; i++) {
+ me.onload[me.api][i]();
+ }
+ }
+ });
+
+ },
+
+ applyOptions: function(){
+ var map = this.maps[this.api];
+
+ // TODO: Add provider code
+ },
+
+ resizeTo: function(width, height){
+ var map = this.maps[this.api];
+ map.setSize(width,height);
+ },
+
+ addControls: function( args ) {
+ var map = this.maps[this.api];
+ map.showControl("Zoom", args.zoom || false);
+ map.showControl("Layers", args.layers || false);
+ map.showControl("Styles", args.styles || false);
+ map.showControl("Basemap", args.map_type || false);
+ map.showControl("Legend", args.legend || false, "open");
+ // showControl("Legend", true, "close");
+ },
+
+ addSmallControls: function() {
+ var map = this.maps[this.api];
+ this.addControls({
+ zoom: ''small'',
+ legend: "open"
+ });
+ // showControl("Zoom", args.zoom);
+ // showControl("Legend", args.legend, "open");
+ },
+
+ addLargeControls: function() {
+ var map = this.maps[this.api];
+ this.addControls({
+ zoom: ''large'',
+ layers: true,
+ legend: "open"
+ });
+ },
+
+ addMapTypeControls: function() {
+ var map = this.maps[this.api];
+
+ // TODO: Add provider code
+ },
+
+ dragging: function(on) {
+ var map = this.maps[this.api];
+
+ // TODO: Add provider code
+ },
+
+ setCenterAndZoom: function(point, zoom) {
+ var map = this.maps[this.api];
+ map.setCenterZoom(point.lat, point.lon,zoom);
+ },
+
+ getCenter: function() {
+ var map = this.maps[this.api];
+ var point = map.getCenterZoom()[0];
+ return new mxn.LatLonPoint(point.lat,point.lon);
+ },
+
+ setCenter: function(point, options) {
+ var map = this.maps[this.api];
+ map.setCenter(point.lat, point.lon);
+ },
+
+ 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;
+
+ // TODO: Add provider code
+
+ return zoom;
+ },
+
+ setMapType: function(type) {
+ var map = this.maps[this.api];
+ switch(type) {
+ case mxn.Mapstraction.ROAD:
+ map.setMapProvider("OpenStreetMap (road)");
+ break;
+ case mxn.Mapstraction.SATELLITE:
+ map.setMapProvider("BlueMarble");
+ break;
+ case mxn.Mapstraction.HYBRID:
+ map.setMapProvider("Google Hybrid");
+ break;
+ default:
+ map.setMapProvider(type);
+ }
+ },
+
+ 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;
+
+ },
+
+ getBounds: function () {
+ var map = this.maps[this.api];
+ var extent = map.getExtent();
+ return new mxn.BoundingBox( extent.northWest.lat, extent.southEast.lon,
extent.southEast.lat, extent.northWest.lon);
+ },
+
+ setBounds: function(bounds){
+ var map = this.maps[this.api];
+ var sw = bounds.getSouthWest();
+ var ne = bounds.getNorthEast();
+ map.setExtent(ne.lat,sw.lat,ne.lon,sw.lon);
+
+ },
+
+ addImageOverlay: function(id, src, opacity, west, south, east, north,
oContext) {
+ var map = this.maps[this.api];
+
+ // TODO: Add provider code
+ },
+
+ // URL in this case is either a Maker map ID or the full URL to the
Maker Map
+ addOverlay: function(url, autoCenterAndZoom) {
+ var map = this.maps[this.api];
+ var match;
+
+ if(typeof(url) === "number") {
+ map.loadMap(url);
+ 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(/^.*?maps\/(\d+)(\?\(\[?(.*?)\]?\))?$/);
+ }
+
+ map.loadMap(match[1]);
+ },
+
+ 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
+ },
+ addMarker: function(marker, old) {
+ var map = this.maps[this.api];
+ var pin = marker.toProprietary(this.api);
+ // TODO: Add provider code
+ // map.addOverlay(pin);
+ return pin;
+ },
+
+ removeMarker: function(marker) {
+ var map = this.maps[this.api];
+ // TODO: Add provider code
+
+ },
+
+ removeAllMarkers: function() {
+ // Done in mxn.core.js
+ },
+
+ 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
+ // map.addOverlay(pl);
+ return pl;
+ },
+
+ removePolyline: function(polyline) {
+ var map = this.maps[this.api];
+ // TODO: Add provider code
+ }
+
+
+ },
+
+ LatLonPoint: {
+
+ toProprietary: function() {
+ // TODO: Add provider code
+ return {};
+ },
+
+ fromProprietary: function(googlePoint) {
+ // TODO: Add provider code
+ }
+
+ },
+
+ Marker: {
+
+ toProprietary: function() {
+ // TODO: Add provider code
+ return {};
+ },
+
+ 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() {
+ return {};
+ // TODO: Add provider code
+ },
+
+ show: function() {
+ // TODO: Add provider code
+ },
+
+ hide: function() {
+ // TODO: Add provider code
+ }
+
+ }
});
======================================--- /trunk/source/mxn.google.core.js Thu
Oct 8 11:07:13 2009
+++ /trunk/source/mxn.google.core.js Mon Dec 14 17:04:05 2009
@@ -73,50 +73,51 @@
// remove old controls
if (this.controls) {
while ((ctl = this.controls.pop())) {
- // Google specific method
+ // Google specific method
map.removeControl(ctl);
}
- } else {
- this.controls = [];
- }
- c = this.controls;
+ }
+ else {
+ this.controls = [];
+ }
+ c = this.controls;
// Google has a combined zoom and pan control.
if (args.zoom || args.pan) {
- if (args.zoom == ''large''){
- this.addLargeControls();
- } else {
- this.addSmallControls();
- }
+ if (args.zoom == ''large''){
+ this.addLargeControls();
+ } else {
+ this.addSmallControls();
+ }
}
if (args.scale) {
- this.controls.unshift(new GScaleControl());
- map.addControl(this.controls[0]);
- this.addControlsArgs.scale = true;
+ this.controls.unshift(new GScaleControl());
+ map.addControl(this.controls[0]);
+ this.addControlsArgs.scale = true;
}
if (args.overview) {
- c.unshift(new GOverviewMapControl());
- map.addControl(c[0]);
- this.addControlsArgs.overview = true;
+ c.unshift(new GOverviewMapControl());
+ map.addControl(c[0]);
+ this.addControlsArgs.overview = true;
}
if (args.map_type) {
- this.addMapTypeControls();
+ this.addMapTypeControls();
}
},
addSmallControls: function() {
var map = this.maps[this.api];
- this.controls.unshift(new GSmallMapControl());
+ this.controls.unshift(new GSmallMapControl());
map.addControl(this.controls[0]);
this.addControlsArgs.zoom = ''small'';
this.addControlsArgs.pan = true;
},
addLargeControls: function() {
- var map = this.maps[this.api];
- this.controls.unshift(new GLargeMapControl());
+ var map = this.maps[this.api];
+ this.controls.unshift(new GLargeMapControl());
map.addControl(this.controls[0]);
this.addControlsArgs.zoom = ''large'';
this.addControlsArgs.pan = true;
@@ -124,7 +125,7 @@
addMapTypeControls: function() {
var map = this.maps[this.api];
- this.controls.unshift(new GMapTypeControl());
+ this.controls.unshift(new GMapTypeControl());
map.addControl(this.controls[0]);
this.addControlsArgs.map_type = true;
},
@@ -319,14 +320,14 @@
return url;
};
if(map_type) {
- var tileLayerOverlay = new GMapType(tilelayers, new
GMercatorProjection(19), copyright_text, {
- errorMessage:"More "+copyright_text+" tiles
coming soon"
- });
- this.maps[this.api].addMapType(tileLayerOverlay);
- } else {
- tileLayerOverlay = new GTileLayerOverlay(tilelayers[0]);
- this.maps[this.api].addOverlay(tileLayerOverlay);
- }
+ var tileLayerOverlay = new GMapType(tilelayers, new
GMercatorProjection(19), copyright_text, {
+ errorMessage:"More "+copyright_text+" tiles coming
soon"
+ });
+ this.maps[this.api].addMapType(tileLayerOverlay);
+ } else {
+ tileLayerOverlay = new GTileLayerOverlay(tilelayers[0]);
+ this.maps[this.api].addOverlay(tileLayerOverlay);
+ }
this.tileLayers.push( [tile_url, tileLayerOverlay, true] );
return tileLayerOverlay;
},
@@ -415,15 +416,15 @@
icon.shadowSize = new GSize(this.iconShadowSize[0],
this.iconShadowSize[1]);
}
} else { // turn off shadow
- icon.shadow = '''';
- icon.shadowSize = '''';
- }
+ icon.shadow = '''';
+ icon.shadowSize = '''';
+ }
if(this.transparent) {
- icon.transparent = this.transparent;
- }
+ icon.transparent = this.transparent;
+ }
if(this.imageMap) {
- icon.imageMap = this.imageMap;
- }
+ icon.imageMap = this.imageMap;
+ }
options.icon = icon;
}
if(this.draggable){
======================================--- /trunk/source/mxn.google.geocoder.js
Mon Nov 16 19:29:39 2009
+++ /trunk/source/mxn.google.geocoder.js Mon Dec 14 17:04:05 2009
@@ -24,7 +24,7 @@
* @constructor
*/
function MapstractionGeocoder(callback, api, error_callback) {
- this.api = api;
+ this.api = api;
this.callback = callback;
this.geocoders = new Object();
if(error_callback == null) {
@@ -33,11 +33,11 @@
this.error_callback = error_callback;
}
- // This is so that it is easy to tell which revision of this file
- // has been copied into other projects.
- this.svn_revision_string = ''$Revision: 107 $'';
-
- this.addAPI(api);
+ // This is so that it is easy to tell which revision of this file
+ // has been copied into other projects.
+ this.svn_revision_string = ''$Revision: 107 $'';
+
+ this.addAPI(api);
}
@@ -47,12 +47,12 @@
*/
MapstractionGeocoder.prototype.addAPI = function(api) {
- me = this;
- switch (api) {
+ me = this;
+ switch (api) {
case ''google'':
this.geocoders[api] = new GClientGeocoder();
break;
- case ''mapquest'':
+ case ''mapquest'':
//set up the connection to the geocode server
var proxyServerName = "";
var proxyServerPort = "";
@@ -61,25 +61,24 @@
var serverName = "geocode.access.mapquest.com";
var serverPort = "80";
var serverPath = "mq";
- this.geocoders[api] = new MQExec(serverName, serverPath, serverPort,
proxyServerName,
- ProxyServerPath, proxyServerPort );
-
- break;
- default:
- alert(api + '' not supported by mapstraction-geocoder'');
- }
+ this.geocoders[api] = new MQExec(serverName, serverPath, serverPort,
proxyServerName, ProxyServerPath, proxyServerPort );
+
+ break;
+ default:
+ alert(api + '' not supported by mapstraction-geocoder'');
+ }
}
/**
* Change the Routing API to use
* @param {String} api The API to swap to
*/
MapstractionGeocoder.prototype.swap = function(api) {
- if (this.api == api) { return; }
-
- this.api = api;
- if (this.geocoders[this.api] == undefined) {
- this.addAPI($(element),api);
- }
+ if (this.api == api) { return; }
+
+ this.api = api;
+ if (this.geocoders[this.api] == undefined) {
+ this.addAPI($(element),api);
+ }
}
/**
@@ -93,14 +92,14 @@
* Default handler for geocode request completion
*/
MapstractionGeocoder.prototype.geocode_callback = function(response,
mapstraction_geocoder) {
- var return_location = new Object();
+ var return_location = {};
// TODO: what if the api is switched during a geocode request?
// TODO: provide an option error callback
switch (mapstraction_geocoder.api) {
case ''google'':
- if (!response || response.Status.code != 200) {
- mapstraction_geocoder.error_callback(response);
+ if (!response || response.Status.code != 200) {
+ mapstraction_geocoder.error_callback(response);
} else {
return_location.street = "";
return_location.locality = "";
@@ -110,25 +109,25 @@
var place = response.Placemark[0];
if(place.AddressDetails.Country.AdministrativeArea != null) {
return_location.region =
place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
-
+
if(place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea !=
null) {
if(place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality
!=
null) {
return_location.locality =
place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
-
if(place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare
!=
null)
+
if(place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare
!=
null) {
return_location.street =
place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
- }
-
- }
-
+ }
+ }
+
+ }
+
}
return_location.country = place.AddressDetails.Country.CountryNameCode;
- return_location.address = place.address;
-
- return_location.point = new
mxn.LatLonPoint(place.Point.coordinates[1],
- place.Point.coordinates[0]);
- mapstraction_geocoder.callback(return_location);
- }
+ return_location.address = place.address;
+
+ return_location.point = new
mxn.LatLonPoint(place.Point.coordinates[1], place.Point.coordinates[0]);
+ mapstraction_geocoder.callback(return_location);
+ }
break;
case ''mapquest'':
break;
@@ -141,39 +140,40 @@
* @param {Object} address The address object to geocode
*/
MapstractionGeocoder.prototype.geocode = function(address) {
- var return_location = new Object();
-
- // temporary variable for later using in function closure
- var mapstraction_geocoder = this;
-
- switch (this.api) {
- case ''google'':
- if (address.address == null || address.address == "")
- address.address = address.street + ", " + address.locality +
", "
+ address.region + ", " + address.country
- this.geocoders[this.api].getLocations(address.address,
function(response) { mapstraction_geocoder.geocode_callback(response,
mapstraction_geocoder); });
- break;
- case ''mapquest'':
- var mqaddress = new MQAddress();
- var gaCollection = new MQLocationCollection("MQGeoAddress");
- //populate the address object with the information from the form
- mqaddress.setStreet(address.street);
- mqaddress.setCity(address.locality);
- mqaddress.setState(address.region);
- mqaddress.setPostalCode(address.postalcode);
- mqaddress.setCountry(address.country);
-
- this.geocoders[this.api].geocode(mqaddress, gaCollection);
- var geoAddr = gaCollection.get(0);
- var mqpoint = geoAddr.getMQLatLng();
- return_location.street = geoAddr.getStreet();
- return_location.locality = geoAddr.getCity();
- return_location.region = geoAddr.getState();
- return_location.country = geoAddr.getCountry();
- return_location.point = new
mxn.LatLonPoint(mqpoint.getLatitude(), mqpoint.getLongitude());
- this.callback(return_location, this);
- break;
- default:
- alert(api + '' not supported by
mapstraction-geocoder'');
- break;
- }
- }
+ var return_location = {};
+
+ // temporary variable for later using in function closure
+ var mapstraction_geocoder = this;
+
+ switch (this.api) {
+ case ''google'':
+ if (address.address == null || address.address == "") {
+ address.address = address.street + ", " + address.locality +
", " +
address.region + ", " + address.country;
+ }
+ this.geocoders[this.api].getLocations(address.address,
function(response) { mapstraction_geocoder.geocode_callback(response,
mapstraction_geocoder); });
+ break;
+ case ''mapquest'':
+ var mqaddress = new MQAddress();
+ var gaCollection = new MQLocationCollection("MQGeoAddress");
+ //populate the address object with the information from the form
+ mqaddress.setStreet(address.street);
+ mqaddress.setCity(address.locality);
+ mqaddress.setState(address.region);
+ mqaddress.setPostalCode(address.postalcode);
+ mqaddress.setCountry(address.country);
+
+ this.geocoders[this.api].geocode(mqaddress, gaCollection);
+ var geoAddr = gaCollection.get(0);
+ var mqpoint = geoAddr.getMQLatLng();
+ return_location.street = geoAddr.getStreet();
+ return_location.locality = geoAddr.getCity();
+ return_location.region = geoAddr.getState();
+ return_location.country = geoAddr.getCountry();
+ return_location.point = new mxn.LatLonPoint(mqpoint.getLatitude(),
mqpoint.getLongitude());
+ this.callback(return_location, this);
+ break;
+ default:
+ alert(api + '' not supported by mapstraction-geocoder'');
+ break;
+ }
+ }
======================================--- /trunk/source/mxn.googlev3.core.js Fri
Nov 6 09:38:24 2009
+++ /trunk/source/mxn.googlev3.core.js Mon Dec 14 17:04:05 2009
@@ -3,127 +3,127 @@
Mapstraction: {
init: function(element, api){
- var me = this;
- if ( google && google.maps ){
- // by default no controls and road map
- var myOptions = {
- disableDefaultUI: true,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- var map = new google.maps.Map(element, myOptions);
-
- // deal with click
- google.maps.event.addListener(map, ''click'',
function(location){
+ var me = this;
+ if ( google && google.maps ){
+ // by default no controls and road map
+ var myOptions = {
+ disableDefaultUI: true,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+ var map = new google.maps.Map(element, myOptions);
+
+ // deal with click
+ google.maps.event.addListener(map, ''click'',
function(location){
me.clickHandler(location.latLng.lat(),location.latLng.lng(),location,me);
- });
-
- // deal with zoom change
- google.maps.event.addListener(map,
''zoom_changed'',
function(){
- me.changeZoom.fire();
- });
- // deal with map movement
- 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'');
- }
+ });
+
+ // deal with zoom change
+ google.maps.event.addListener(map, ''zoom_changed'',
function(){
+ me.changeZoom.fire();
+ });
+ // deal with map movement
+ 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);
+ 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'');
+ 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];
- // remove old controls
-
- // Google has a combined zoom and pan control.
- 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;
- }
+ var map = this.maps[this.api];
+ // remove old controls
+
+ // Google has a combined zoom and pan control.
+ 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'';
+ 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'';
+ 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;
+ 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);
+ map.setZoom(zoom);
},
addMarker: function(marker, old) {
- return marker.toProprietary(this.api);
+ return marker.toProprietary(this.api);
},
removeMarker: function(marker) {
- // doesn''t really remove them, just hides them
- marker.hide();
+ // doesn''t really remove them, just hides them
+ marker.hide();
},
removeAllMarkers: function() {
@@ -145,21 +145,21 @@
var map = this.maps[this.api];
// TODO: Add provider code
},
-
+
getCenter: function() {
var map = this.maps[this.api];
- var pt = map.getCenter();
- return new mxn.LatLonPoint(pt.lat(),pt.lng());
+ 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);
+ map.panTo(pt);
}
else {
- map.setCenter(pt);
+ map.setCenter(pt);
}
},
@@ -179,49 +179,49 @@
var ne = bbox.getNorthEast().toProprietary(this.api);
var gLatLngBounds = new google.maps.LatLngBounds(sw, ne);
map.fitBounds(gLatLngBounds);
- return map.getZoom();
+ 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;
+ map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
+ break;
case mxn.Mapstraction.SATELLITE:
-
map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
- break;
+ map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
+ break;
case mxn.Mapstraction.HYBRID:
- map.setMapTypeId(google.maps.MapTypeId.HYBRID);
- break;
+ map.setMapTypeId(google.maps.MapTypeId.HYBRID);
+ break;
default:
-
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
+ 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;
- //case google.maps.MapTypeId.TERRAIN:
- // return something;
- default:
- return null;
- }
+ 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;
+ //case google.maps.MapTypeId.TERRAIN:
+ // return something;
+ 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());
+ 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){
@@ -285,7 +285,7 @@
LatLonPoint: {
toProprietary: function() {
- return new google.maps.LatLng(this.lat, this.lon);
+ return new google.maps.LatLng(this.lat, this.lon);
},
fromProprietary: function(googlePoint) {
@@ -300,54 +300,53 @@
toProprietary: function() {
var options = {};
- // do we have an Anchor?
- var ax = 0; // anchor x
+ // do we have an Anchor?
+ var ax = 0; // anchor x
var ay = 0; // anchor y
if (this.iconAnchor) {
- ax = this.iconAnchor[0];
- ay = this.iconAnchor[1];
- }
- var gAnchorPoint = new google.maps.Point(ax,ay);
+ 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
- );
-
- // do we have a Shadow?
- 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);
- }
- }
+ 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
+ );
+
+ // do we have a Shadow?
+ 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;
+ options.draggable = this.draggable;
}
if (this.labelText){
- options.title = this.labelText;
+ options.title = this.labelText;
}
if (this.imageMap){
- options.shape = {
- coord: this.imageMap,
- type: ''poly''
- };
- }
+ options.shape = {
+ coord: this.imageMap,
+ type: ''poly''
+ };
+ }
options.position = this.location.toProprietary(this.api);
options.map = this.map;
@@ -355,46 +354,45 @@
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); });
+ 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); }
- );
- }
+ 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();
@@ -405,17 +403,17 @@
openBubble: function() {
var infowindow = new google.maps.InfoWindow({
- content: this.infoBubble
- });
- infowindow.open(this.map,this.proprietary_marker);
+ content: this.infoBubble
+ });
+ infowindow.open(this.map,this.proprietary_marker);
},
hide: function() {
- this.proprietary_marker.setOptions({visible:false});
+ this.proprietary_marker.setOptions({visible:false});
},
show: function() {
- this.proprietary_marker.setOptions({visible:true});
+ this.proprietary_marker.setOptions({visible:true});
},
update: function() {
@@ -427,15 +425,15 @@
Polyline: {
toProprietary: function() {
- throw ''Not implemented'';
+ throw ''Not implemented'';
},
show: function() {
- throw ''Not implemented'';
+ throw ''Not implemented'';
},
hide: function() {
- throw ''Not implemented'';
+ throw ''Not implemented'';
}
}
======================================--- /trunk/source/mxn.js Sun Dec 13
11:10:14 2009
+++ /trunk/source/mxn.js Mon Dec 14 17:04:05 2009
@@ -32,7 +32,7 @@
}
}
- if (providers === null || providers == ''none'') {
+ if (providers === null || providers == ''none'') {
return; // Bail out if no auto-load has been found
}
providers = providers.replace(/ /g,
'''').split('','');
@@ -44,7 +44,7 @@
var scriptsAry = [];
for (i = 0; i < modules.length; i++) {
scriptsAry.push(scriptTagStart + modules[i] + scriptTagEnd);
- for (var j = 0; j < providers.length; j++) {
+ for (var j = 0; j < providers.length; j++) {
scriptsAry.push(scriptTagStart + providers[j] + ''.'' +
modules[i] +
scriptTagEnd);
}
}
@@ -68,12 +68,12 @@
if(!hasImplementation(sApiId, sObjName, sFnName)) {
throw ''Method '' + sFnName + '' of object
'' + sObjName + '' is not
supported by API '' + sApiId + ''. Are you missing a script
tag?'';
}
- if(typeof(apis[sApiId][sObjName].deferrable) !=
''undefined'' &&
apis[sApiId][sObjName].deferrable[sFnName] === true) {
- return mxn.deferUntilLoaded.call(oScope, function() {return
apis[sApiId][sObjName][sFnName].apply(oScope, args);} );
- }
- else {
- return apis[sApiId][sObjName][sFnName].apply(oScope, args);
- }
+ if(typeof(apis[sApiId][sObjName].deferrable) != ''undefined''
&&
apis[sApiId][sObjName].deferrable[sFnName] === true) {
+ mxn.deferUntilLoaded.call(oScope, function() {return
apis[sApiId][sObjName][sFnName].apply(oScope, args);} );
+ }
+ else {
+ return apis[sApiId][sObjName][sFnName].apply(oScope, args);
+ }
};
/**
@@ -138,14 +138,16 @@
}
return false;
},
- deferUntilLoaded: function(fnCall) {
- if(this.loaded[this.api] === false) {
- var scope = this;
- this.onload[this.api].push( fnCall );
- } else {
- return fnCall.call(this);
- }
- },
+
+ deferUntilLoaded: function(fnCall) {
+ if(this.loaded[this.api] === false) {
+ var scope = this;
+ this.onload[this.api].push( fnCall );
+ } else {
+ fnCall.call(this);
+ }
+ },
+
/**
* Bulk add some named events to an object.
* @function
======================================--- /trunk/source/mxn.microsoft.core.js
Thu Aug 27 10:43:39 2009
+++ /trunk/source/mxn.microsoft.core.js Mon Dec 14 17:04:05 2009
@@ -6,34 +6,23 @@
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);
+ 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();
-
-
+ 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();
-
-
+ me.endPan.fire();
});
this.maps[api].LoadMap();
document.getElementById("MSVE_obliqueNotification").style.visibility
= "hidden";
@@ -44,7 +33,6 @@
}
else{
alert(api + '' map script not imported'')
-
}
},
@@ -53,10 +41,8 @@
var map = this.maps[this.api];
if(this.options.enableScrollWheelZoom){
map.enableContinuousZoom();
- map.enableScrollWheelZoom();
-
- }
-
+ map.enableScrollWheelZoom();
+ }
},
resizeTo: function(width, height){
@@ -65,15 +51,15 @@
addControls: function( args ) {
var map = this.maps[this.api];
-
- if (args.pan) {
+
+ if (args.pan) {
map.SetDashboardSize(VEDashboardSize.Normal);
}
else {
map.SetDashboardSize(VEDashboardSize.Tiny)
}
- if (args.zoom == ''large'') {
+ if (args.zoom == ''large'') {
map.SetDashboardSize(VEDashboardSize.Small)
}
else if ( args.zoom == ''small'' ) {
@@ -83,14 +69,11 @@
map.HideDashboard();
map.HideScalebar();
}
-
-
},
addSmallControls: function() {
var map = this.maps[this.api];
map.SetDashboardSize(VEDashboardSize.Tiny);
-
},
addLargeControls: function() {
@@ -113,7 +96,6 @@
}
else{
map.disableDragMap();
-
}
},
@@ -121,21 +103,19 @@
var map = this.maps[this.api];
var pt = point.toProprietary(this.api);
var vzoom = zoom;
- map.SetCenterAndZoom(new VELatLong(point.lat,point.lon), vzoom)
-
+ 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)));
+ marker.pinID = "mspin-"+new
Date().getTime()+''-''+(Math.floor(Math.random()*Math.pow(2,16)));
var pin = marker.toProprietary(this.api);
- map.AddShape(pin);
+ map.AddShape(pin);
//give onclick event
//give on double click event
//give on close window
//return the marker
-
-
+
return pin;
},
@@ -186,21 +166,16 @@
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;
},
@@ -267,9 +242,6 @@
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) {
@@ -284,20 +256,17 @@
// TODO: Add provider code
- // oContext.pixels.top = ...;
- // oContext.pixels.left = ...;
- // oContext.pixels.bottom = ...;
- // oContext.pixels.right = ...;
+ // 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);
+ 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) {
@@ -320,7 +289,6 @@
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";
}
@@ -344,10 +312,7 @@
toProprietary: function() {
var mmarker = new VEShape(VEShapeType.Pushpin,
this.location.toProprietary(''microsoft''));
-
-
return mmarker;
-
},
openBubble: function() {
@@ -374,8 +339,7 @@
toProprietary: function() {
var mpoints =[];
- for(var i =0, length = this.points.length; i < length; i++)
- {
+ 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);
@@ -390,11 +354,11 @@
},
show: function() {
- this.proprietary_polyline.Show();
+ this.proprietary_polyline.Show();
},
hide: function() {
- this.proprietary_polyline.Hide();
+ this.proprietary_polyline.Hide();
}
}
======================================--- /trunk/source/mxn.openlayers.core.js
Sat Oct 3 09:29:58 2009
+++ /trunk/source/mxn.openlayers.core.js Mon Dec 14 17:04:05 2009
@@ -1,513 +1,515 @@
mxn.register(''openlayers'', {
- Mapstraction: {
-
- init: function(element, api){
- var me = this;
- this.maps[api] = new OpenLayers.Map(
- element.id,
- {
- maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
- maxResolution:156543,
- numZoomLevels:18,
- units:''meters'',
- projection: "EPSG:41001"
- }
- );
-
- this.layers[''osmmapnik''] = new
OpenLayers.Layer.TMS(
- ''OSM Mapnik'',
- [
- "http://a.tile.openstreetmap.org/",
- "http://b.tile.openstreetmap.org/",
- "http://c.tile.openstreetmap.org/"
- ],
- {
- type:''png'',
- getURL: function (bounds) {
- var res = this.map.getResolution();
- var x = Math.round ((bounds.left -
this.maxExtent.left) / (res * this.tileSize.w));
- var y = Math.round ((this.maxExtent.top -
bounds.top) / (res * this.tileSize.h));
- var z = this.map.getZoom();
- var limit = Math.pow(2, z);
- if (y < 0 || y >= limit) {
- return null;
- } else {
- x = ((x % limit) + limit) % limit;
- var path = z + "/" + x + "/" +
y + "." +
this.type;
- var url = this.url;
- if (url instanceof Array) {
- url = this.selectUrl(path, url);
- }
- return url + path;
- }
- },
- displayOutsideMaxExtent: true
- }
- );
-
- this.layers[''osm''] = new OpenLayers.Layer.TMS(
- ''OSM'',
- [
- "http://a.tah.openstreetmap.org/Tiles/tile.php/",
- "http://b.tah.openstreetmap.org/Tiles/tile.php/",
- "http://c.tah.openstreetmap.org/Tiles/tile.php/"
- ],
- {
- type:''png'',
- getURL: function (bounds) {
- var res = this.map.getResolution();
- var x = Math.round ((bounds.left -
this.maxExtent.left) / (res * this.tileSize.w));
- var y = Math.round ((this.maxExtent.top -
bounds.top) / (res * this.tileSize.h));
- var z = this.map.getZoom();
- var limit = Math.pow(2, z);
- if (y < 0 || y >= limit) {
- return null;
- } else {
- x = ((x % limit) + limit) % limit;
- var path = z + "/" + x + "/" +
y + "." +
this.type;
- var url = this.url;
- if (url instanceof Array) {
- url = this.selectUrl(path, url);
- }
- return url + path;
- }
- },
- displayOutsideMaxExtent: true
- }
- );
-
-
this.maps[api].addLayer(this.layers[''osmmapnik'']);
- this.maps[api].addLayer(this.layers[''osm'']);
- },
-
- 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;
- this.maps[this.api].updateSize();
- },
-
- addControls: function( args ) {
- var map = this.maps[this.api];
- // FIXME: OpenLayers has a bug removing all the controls says
crschmidt
- for (var i = map.controls.length; i>1; i--) {
- map.controls[i-1].deactivate();
- map.removeControl(map.controls[i-1]);
- }
- if ( args.zoom == ''large'' ) {
- map.addControl(new OpenLayers.Control.PanZoomBar());
- }
- else if ( args.zoom == ''small'' ) {
- map.addControl(new OpenLayers.Control.ZoomPanel());
- if ( args.pan) {
- map.addControl(new OpenLayers.Control.PanPanel());
- }
- }
- else {
- if ( args.pan){
- map.addControl(new OpenLayers.Control.PanPanel());
- }
- }
- if ( args.overview ) {
- map.addControl(new OpenLayers.Control.OverviewMap());
- }
- if ( args.map_type ) {
- map.addControl(new OpenLayers.Control.LayerSwitcher());
- }
- },
-
- addSmallControls: function() {
- var map = this.maps[this.api];
- this.addControlsArgs.pan = false;
- this.addControlsArgs.scale = false;
- this.addControlsArgs.zoom = ''small'';
- map.addControl(new OpenLayers.Control.ZoomBox());
- map.addControl(new OpenLayers.Control.LayerSwitcher({
- ''ascending'':false
- }));
- },
-
- addLargeControls: function() {
- var map = this.maps[this.api];
- map.addControl(new OpenLayers.Control.PanZoomBar());
- this.addControlsArgs.pan = true;
- this.addControlsArgs.zoom = ''large'';
- },
-
- addMapTypeControls: function() {
- var map = this.maps[this.api];
- map.addControl( new OpenLayers.Control.LayerSwitcher({
- ''ascending'':false
- }) );
- this.addControlsArgs.map_type = true;
- },
-
- setCenterAndZoom: function(point, zoom) {
- var map = this.maps[this.api];
- var pt = point.toProprietary(this.api);
- map.setCenter(point.toProprietary(this.api), zoom);
- },
-
- 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);
-
- return pin;
- },
-
- removeMarker: function(marker) {
- var map = this.maps[this.api];
- var pin = marker.toProprietary(this.api);
- this.layers[''markers''].removeMarker(pin);
- pin.destroy();
-
- },
-
- 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);
-
- 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]);
- return pl;
- },
-
- removePolyline: function(polyline) {
- var map = this.maps[this.api];
- var pl = polyline.toProprietary(this.api);
- 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);
- },
-
- getCenter: function() {
- var map = this.maps[this.api];
- pt = map.getCenter();
- return new mxn.LatLonPoint(pt.lat, pt.lon);
- },
-
- setCenter: function(point, options) {
- var map = this.maps[this.api];
- var pt = point.toProprietary(this.api);
- map.setCenter(pt);
-
- },
-
- setZoom: function(zoom) {
- var map = this.maps[this.api];
- map.zoomTo(zoom);
- },
-
- getZoom: function() {
- var map = this.maps[this.api];
- return map.zoom;
- },
-
- getZoomLevelForBoundingBox: function( bbox ) {
- var map = this.maps[this.api];
- // throw ''Not implemented'';
- return zoom;
- },
-
- setMapType: function(type) {
- var map = this.maps[this.api];
- throw ''Not implemented (setMapType)'';
-
- // 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];
- // TODO: implement actual layer support
- return mxn.Mapstraction.ROAD;
-
- // 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;
- // //case google.maps.MapTypeId.TERRAIN:
- // // return something;
- // default:
- // return null;
- // }
- },
-
- getBounds: function () {
- var map = this.maps[this.api];
- var olbox = map.calculateBounds();
- return new mxn.BoundingBox(olbox.bottom, olbox.left,
olbox.top, olbox.right);
- },
-
- 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 obounds = new OpenLayers.Bounds();
-
- 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];
-
- // TODO: Add provider code
- }
- },
-
- LatLonPoint: {
-
- toProprietary: function() {
- var ollon = this.lon * 20037508.34 / 180;
- var ollat = Math.log(Math.tan((90 + this.lat) * Math.PI /
360)) / (Math.PI / 180);
- ollat = ollat * 20037508.34 / 180;
- return new OpenLayers.LonLat(ollon, ollat);
- },
-
- fromProprietary: function(olPoint) {
- var lon = (olPoint.lon / 20037508.34) * 180;
- var lat = (olPoint.lat / 20037508.34) * 180;
- lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI /
180)) - Math.PI / 2);
- this.lon = lon;
- this.lat = 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(21,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 OpenLayers.Icon(this.iconUrl, size, anchor);
- }
- else {
- icon = new
OpenLayers.Icon(''http://openlayers.org/dev/img/marker-gold.png'',
size,
anchor);
- }
- var marker = new
OpenLayers.Marker(this.location.toProprietary("openlayers"), icon);
-
- if(this.infoBubble) {
- var popup = new OpenLayers.Popup(null,
- this.location.toProprietary("openlayers"),
- new OpenLayers.Size(100,100),
- this.infoBubble,
- true);
- popup.autoSize = true;
- var theMap = this.map;
- if(this.hover) {
- marker.events.register("mouseover", marker,
function(event) {
- theMap.addPopup(popup);
- popup.show();
- });
- marker.events.register("mouseout", marker,
function(event) {
- popup.hide();
- theMap.removePopup(popup);
- });
- }
- else {
- var shown = false;
- marker.events.register("mousedown", marker,
function(event) {
- if (shown) {
- popup.hide();
- theMap.removePopup(popup);
- shown = false;
- } else {
- theMap.addPopup(popup);
- popup.show();
- shown = true;
- }
- });
- }
- }
-
- if(this.hoverIconUrl) {
- // TODO
- }
-
- if(this.infoDiv){
- // TODO
- }
- return marker;
- },
-
- openBubble: function() {
- // TODO: Add provider code
- },
-
- hide: function() {
- this.proprietary_marker.setOptions({visible:false});
- },
-
- show: function() {
- this.proprietary_marker.setOptions({visible:true});
- },
-
- update: function() {
- // TODO: Add provider code
- }
-
- },
-
- Polyline: {
-
- toProprietary: function() {
- var olpolyline;
- var olpoints = [];
- var ring;
- var style = {
- strokeColor: this.color || "#000000",
- strokeOpacity: this.opacity || 1,
- strokeWidth: this.width || 1,
- fillColor: this.fillColor || "#000000",
- fillOpacity: this.getAttribute(''fillOpacity'')
|| 0.2
- };
-
- //TODO Handle closed attribute
-
- for (var i = 0, length = this.points.length ; i< length; i++){
- olpoint = this.points[i].toProprietary("openlayers");
- olpoints.push(new OpenLayers.Geometry.Point(olpoint.lon,
olpoint.lat));
- }
-
- if (this.closed) {
- // a closed polygon
- ring = new OpenLayers.Geometry.LinearRing(olpoints);
- } else {
- // a line
- ring = new OpenLayers.Geometry.LineString(olpoints);
- }
-
- olpolyline = new OpenLayers.Feature.Vector(ring, null, style);
-
- return olpolyline;
- },
-
- show: function() {
- throw ''Not implemented'';
- },
-
- hide: function() {
- throw ''Not implemented'';
- }
-
- }
+ Mapstraction: {
+
+ init: function(element, api){
+ var me = this;
+ this.maps[api] = new OpenLayers.Map(
+ element.id,
+ {
+ maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
+ maxResolution:156543,
+ numZoomLevels:18,
+ units:''meters'',
+ projection: "EPSG:41001"
+ }
+ );
+
+ this.layers[''osmmapnik''] = new OpenLayers.Layer.TMS(
+ ''OSM Mapnik'',
+ [
+ "http://a.tile.openstreetmap.org/",
+ "http://b.tile.openstreetmap.org/",
+ "http://c.tile.openstreetmap.org/"
+ ],
+ {
+ type:''png'',
+ getURL: function (bounds) {
+ var res = this.map.getResolution();
+ var x = Math.round ((bounds.left - this.maxExtent.left) / (res *
this.tileSize.w));
+ var y = Math.round ((this.maxExtent.top - bounds.top) / (res *
this.tileSize.h));
+ var z = this.map.getZoom();
+ var limit = Math.pow(2, z);
+ if (y < 0 || y >= limit) {
+ return null;
+ } else {
+ x = ((x % limit) + limit) % limit;
+ var path = z + "/" + x + "/" + y + "." +
this.type;
+ var url = this.url;
+ if (url instanceof Array) {
+ url = this.selectUrl(path, url);
+ }
+ return url + path;
+ }
+ },
+ displayOutsideMaxExtent: true
+ }
+ );
+
+ this.layers[''osm''] = new OpenLayers.Layer.TMS(
+ ''OSM'',
+ [
+ "http://a.tah.openstreetmap.org/Tiles/tile.php/",
+ "http://b.tah.openstreetmap.org/Tiles/tile.php/",
+ "http://c.tah.openstreetmap.org/Tiles/tile.php/"
+ ],
+ {
+ type:''png'',
+ getURL: function (bounds) {
+ var res = this.map.getResolution();
+ var x = Math.round ((bounds.left - this.maxExtent.left) / (res *
this.tileSize.w));
+ var y = Math.round ((this.maxExtent.top - bounds.top) / (res *
this.tileSize.h));
+ var z = this.map.getZoom();
+ var limit = Math.pow(2, z);
+ if (y < 0 || y >= limit) {
+ return null;
+ } else {
+ x = ((x % limit) + limit) % limit;
+ var path = z + "/" + x + "/" + y + "." +
this.type;
+ var url = this.url;
+ if (url instanceof Array) {
+ url = this.selectUrl(path, url);
+ }
+ return url + path;
+ }
+ },
+ displayOutsideMaxExtent: true
+ }
+ );
+
+ this.maps[api].addLayer(this.layers[''osmmapnik'']);
+ this.maps[api].addLayer(this.layers[''osm'']);
+ this.loaded[api] = true;
+ },
+
+ 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;
+ this.maps[this.api].updateSize();
+ },
+
+ addControls: function( args ) {
+ var map = this.maps[this.api];
+ // FIXME: OpenLayers has a bug removing all the controls says crschmidt
+ for (var i = map.controls.length; i>1; i--) {
+ map.controls[i-1].deactivate();
+ map.removeControl(map.controls[i-1]);
+ }
+ if ( args.zoom == ''large'' ) {
+ map.addControl(new OpenLayers.Control.PanZoomBar());
+ }
+ else if ( args.zoom == ''small'' ) {
+ map.addControl(new OpenLayers.Control.ZoomPanel());
+ if ( args.pan) {
+ map.addControl(new OpenLayers.Control.PanPanel());
+ }
+ }
+ else {
+ if ( args.pan){
+ map.addControl(new OpenLayers.Control.PanPanel());
+ }
+ }
+ if ( args.overview ) {
+ map.addControl(new OpenLayers.Control.OverviewMap());
+ }
+ if ( args.map_type ) {
+ map.addControl(new OpenLayers.Control.LayerSwitcher());
+ }
+ },
+
+ addSmallControls: function() {
+ var map = this.maps[this.api];
+ this.addControlsArgs.pan = false;
+ this.addControlsArgs.scale = false;
+ this.addControlsArgs.zoom = ''small'';
+ map.addControl(new OpenLayers.Control.ZoomBox());
+ map.addControl(new OpenLayers.Control.LayerSwitcher({
+ ''ascending'':false
+ }));
+ },
+
+ addLargeControls: function() {
+ var map = this.maps[this.api];
+ map.addControl(new OpenLayers.Control.PanZoomBar());
+ this.addControlsArgs.pan = true;
+ this.addControlsArgs.zoom = ''large'';
+ },
+
+ addMapTypeControls: function() {
+ var map = this.maps[this.api];
+ map.addControl( new OpenLayers.Control.LayerSwitcher({
+ ''ascending'':false
+ }) );
+ this.addControlsArgs.map_type = true;
+ },
+
+ setCenterAndZoom: function(point, zoom) {
+ var map = this.maps[this.api];
+ var pt = point.toProprietary(this.api);
+ map.setCenter(point.toProprietary(this.api), zoom);
+ },
+
+ 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);
+
+ return pin;
+ },
+
+ removeMarker: function(marker) {
+ var map = this.maps[this.api];
+ var pin = marker.toProprietary(this.api);
+ this.layers[''markers''].removeMarker(pin);
+ pin.destroy();
+
+ },
+
+ 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);
+
+ 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]);
+ return pl;
+ },
+
+ removePolyline: function(polyline) {
+ var map = this.maps[this.api];
+ var pl = polyline.toProprietary(this.api);
+ 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);
+ },
+
+ getCenter: function() {
+ var map = this.maps[this.api];
+ pt = map.getCenter();
+ return new mxn.LatLonPoint(pt.lat, pt.lon);
+ },
+
+ setCenter: function(point, options) {
+ var map = this.maps[this.api];
+ var pt = point.toProprietary(this.api);
+ map.setCenter(pt);
+
+ },
+
+ setZoom: function(zoom) {
+ var map = this.maps[this.api];
+ map.zoomTo(zoom);
+ },
+
+ getZoom: function() {
+ var map = this.maps[this.api];
+ return map.zoom;
+ },
+
+ getZoomLevelForBoundingBox: function( bbox ) {
+ var map = this.maps[this.api];
+ // throw ''Not implemented'';
+ return zoom;
+ },
+
+ setMapType: function(type) {
+ var map = this.maps[this.api];
+ throw ''Not implemented (setMapType)'';
+
+ // 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];
+ // TODO: implement actual layer support
+ return mxn.Mapstraction.ROAD;
+
+ // 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;
+ // //case google.maps.MapTypeId.TERRAIN:
+ // // return something;
+ // default:
+ // return null;
+ // }
+ },
+
+ getBounds: function () {
+ var map = this.maps[this.api];
+ var olbox = map.calculateBounds();
+ return new mxn.BoundingBox(olbox.bottom, olbox.left, olbox.top,
olbox.right);
+ },
+
+ 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 obounds = new OpenLayers.Bounds();
+
+ 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];
+
+ // TODO: Add provider code
+ }
+ },
+
+ LatLonPoint: {
+
+ toProprietary: function() {
+ var ollon = this.lon * 20037508.34 / 180;
+ var ollat = Math.log(Math.tan((90 + this.lat) * Math.PI / 360)) /
(Math.PI / 180);
+ ollat = ollat * 20037508.34 / 180;
+ return new OpenLayers.LonLat(ollon, ollat);
+ },
+
+ fromProprietary: function(olPoint) {
+ var lon = (olPoint.lon / 20037508.34) * 180;
+ var lat = (olPoint.lat / 20037508.34) * 180;
+ lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) -
Math.PI / 2);
+ this.lon = lon;
+ this.lat = 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(21,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 OpenLayers.Icon(this.iconUrl, size, anchor);
+ }
+ else {
+ icon = new
OpenLayers.Icon(''http://openlayers.org/dev/img/marker-gold.png'',
size,
anchor);
+ }
+ var marker = new
OpenLayers.Marker(this.location.toProprietary("openlayers"), icon);
+
+ if(this.infoBubble) {
+ var popup = new OpenLayers.Popup(null,
+ this.location.toProprietary("openlayers"),
+ new OpenLayers.Size(100,100),
+ this.infoBubble,
+ true
+ );
+ popup.autoSize = true;
+ var theMap = this.map;
+ if(this.hover) {
+ marker.events.register("mouseover", marker, function(event) {
+ theMap.addPopup(popup);
+ popup.show();
+ });
+ marker.events.register("mouseout", marker, function(event) {
+ popup.hide();
+ theMap.removePopup(popup);
+ });
+ }
+ else {
+ var shown = false;
+ marker.events.register("mousedown", marker, function(event) {
+ if (shown) {
+ popup.hide();
+ theMap.removePopup(popup);
+ shown = false;
+ } else {
+ theMap.addPopup(popup);
+ popup.show();
+ shown = true;
+ }
+ });
+ }
+ }
+
+ if(this.hoverIconUrl) {
+ // TODO
+ }
+
+ if(this.infoDiv){
+ // TODO
+ }
+ return marker;
+ },
+
+ openBubble: function() {
+ // TODO: Add provider code
+ },
+
+ hide: function() {
+ this.proprietary_marker.setOptions({visible:false});
+ },
+
+ show: function() {
+ this.proprietary_marker.setOptions({visible:true});
+ },
+
+ update: function() {
+ // TODO: Add provider code
+ }
+
+ },
+
+ Polyline: {
+
+ toProprietary: function() {
+ var olpolyline;
+ var olpoints = [];
+ var ring;
+ var style = {
+ strokeColor: this.color || "#000000",
+ strokeOpacity: this.opacity || 1,
+ strokeWidth: this.width || 1,
+ fillColor: this.fillColor || "#000000",
+ fillOpacity: this.getAttribute(''fillOpacity'') || 0.2
+ };
+
+ //TODO Handle closed attribute
+
+ for (var i = 0, length = this.points.length ; i< length; i++){
+ olpoint = this.points[i].toProprietary("openlayers");
+ olpoints.push(new OpenLayers.Geometry.Point(olpoint.lon, olpoint.lat));
***The diff for this file has been truncated for email.***
======================================--- /trunk/source/mxn.yahoo.core.js Sun
Aug 16 17:18:10 2009
+++ /trunk/source/mxn.yahoo.core.js Mon Dec 14 17:04:05 2009
@@ -38,7 +38,8 @@
map.enableDragMap();
} else {
map.disableDragMap();
- }*/
+ }
+ */
},
@@ -105,7 +106,7 @@
var pt = point.toProprietary(this.api);
var yzoom = 18 - zoom; // maybe?
- map.drawZoomAndCenter(pt,yzoom);
+ map.drawZoomAndCenter(pt,yzoom);
},
addMarker: function(marker, old) {
@@ -153,7 +154,7 @@
getCenter: function() {
var map = this.maps[this.api];
var pt = map.getCenterLatLon();
- var point = new mxn.LatLonPoint(pt.Lat, pt.Lon);
+ var point = new mxn.LatLonPoint(pt.Lat, pt.Lon);
return point;
},
@@ -214,7 +215,7 @@
getBounds: function () {
var map = this.maps[this.api];
var ybox = map.getBoundsLatLon();
- return new mxn.BoundingBox(ybox.LatMin, ybox.LonMin, ybox.LatMax,
ybox.LonMax);
+ return new mxn.BoundingBox(ybox.LatMin, ybox.LonMin, ybox.LatMax,
ybox.LonMax);
},
setBounds: function(bounds){
@@ -292,64 +293,64 @@
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;
+ 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);
+ ypin.openSmartWindow(this.infoBubble);
},
hide: function() {
@@ -370,12 +371,12 @@
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;
+ 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() {
======================================--- /trunk/tests/index.htm Sun Dec 13
11:10:10 2009
+++ /trunk/tests/index.htm Mon Dec 14 17:04:05 2009
@@ -1,20 +1,20 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html;
charset=utf-8"/>
- <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
src="http://openlayers.org/api/OpenLayers.js"></script>
-
- <script src="../source/mxn.js?(google,yahoo,openlayers)"
type="text/javascript"></script>
-
+<head>
+ <meta http-equiv="content-type" content="text/html;
charset=utf-8"/>
+ <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="domReady.js"
type="text/javascript"></script>-->
<script type="text/javascript">
- //<![CDATA[
+ //<![CDATA[
if(typeof(Enumerator) == ''undefined''){
function Enumerator(ary){
@@ -34,13 +34,13 @@
}
//WhenDomReady(function(){
- var m;
+ var m;
window.onload = function() {
var actionElm = document.getElementById(''actions'');
var infoElm = document.getElementById(''info'');
var eventsElm = document.getElementById(''events'');
- m = new mxn.Mapstraction(''map'',
''geocommons'');
+ m = new mxn.Mapstraction(''map'',
''google'');
m.endPan.addHandler(function(sEvtName, oEvtSource, oEvtArgs){
var center = oEvtSource.getCenter();
@@ -65,107 +65,109 @@
};
var ops = [
- {
- desc: ''Center map'',
- action: function(){
- m.setCenterAndZoom(new mxn.LatLonPoint(37.4419, -122.1419), 10);
- }
- },
- {
- desc: ''Pan map'',
- action: function(){
- m.setCenter(new mxn.LatLonPoint(37.3419, -122.0419), {pan:
true});
- }
- },
- {
- desc: ''Get info'',
- action: function(){
- infoElm.innerHTML = ''Info<br/>'';
- var bb = m.getBounds();
- infoElm.innerHTML += ''Bounds:<br/>SW('' +
bb.sw.lat.toFixed(5)
+ '',''+ bb.sw.lon.toFixed(5)
+'')<br/>NE('' + bb.ne.lat.toFixed(5) +
'',''+
bb.ne.lon.toFixed(5) +'')<br/>'';
- var ll = m.getCenter();
- infoElm.innerHTML += ''Center: ('' +
ll.lat.toFixed(5) + '',''+
ll.lon.toFixed(5) +'')<br/>'';
- infoElm.innerHTML += ''Map type: '' + m.getMapType()
+ ''<br/>'';
- infoElm.innerHTML += ''Zoom: '' + m.getZoom() +
''<br/>'';
- }
- },
- {
- desc: ''Set zoom'',
- action: function(){
- m.setZoom(8);
- }
- },
- {
- desc: ''Add marker'',
- action: function(){
- var mkr = new mxn.Marker(new mxn.LatLonPoint(37.3419,
-122.0419));
- mkr.setLabel(''Some random place'');
- mkr.setInfoBubble(''Some information about the random
place'');
- mkr.click.addHandler(markerEventHandler);
- mkr.openInfoBubble.addHandler(markerEventHandler);
- mkr.closeInfoBubble.addHandler(markerEventHandler);
- m.addMarker(mkr);
- }
- },
- {
- desc: ''Add marker offscreen'',
- action: function(){
- var mkr = new mxn.Marker(new mxn.LatLonPoint(37.3419,
-117.0419));
- mkr.setLabel(''Some other place'');
- m.addMarker(mkr);
- }
- },
- {
- desc: ''Auto center'',
- action: function(){
- m.autoCenterAndZoom();
- }
- },
- {
- desc: ''Add line'',
- action: function(){
- var pl = new mxn.Polyline([
- new mxn.LatLonPoint(37.3419, -122.0419),
- new mxn.LatLonPoint(36.3419, -120.0419),
- new mxn.LatLonPoint(38.3419, -119.0419),
- new mxn.LatLonPoint(37.3419, -117.0419)
- ]);
- pl.color = ''#00DD55'';
- m.addPolyline(pl);
- }
- },
- {
- desc: ''Add controls'',
- action: function() {
- m.addLargeControls();
- m.addControls({
- pan: true,
- zoom: ''small'',
- overview: true,
- scale: true,
- map_type: true,
- });
- }
- },
- {
- desc: ''Add Base map type'',
- action: function() {
-
m.addTileLayer("http://tile.openstreetmap.org/{Z}/{X}/{Y}.png",
1.0, "OSM", 1, 19, true);
- // m.setMapType("OSM");
- }
- },
- {
- desc: ''Swap API (yahoo)'',
- action: function(){
- m.swap(''map'', ''yahoo'');
- }
- },
- {
- desc: ''Swap API (openlayers)'',
- action: function(){
- m.swap(''map'',
''openlayers'');
- }
- },
+ {
+ desc: ''Center map'',
+ action: function(){
+ m.setCenterAndZoom(new mxn.LatLonPoint(37.4419, -122.1419), 10);
+ }
+ },
+ {
+ desc: ''Pan map'',
+ action: function(){
+ m.setCenter(new mxn.LatLonPoint(37.3419, -122.0419), {pan: true});
+ }
+ },
+ {
+ desc: ''Get info'',
+ action: function(){
+ infoElm.innerHTML = ''Info<br/>'';
+ var bb = m.getBounds();
+ infoElm.innerHTML += ''Bounds:<br/>SW('' +
bb.sw.lat.toFixed(5) + '',''+
bb.sw.lon.toFixed(5) +'')<br/>NE('' + bb.ne.lat.toFixed(5)
+ '',''+
bb.ne.lon.toFixed(5) +'')<br/>'';
+ var ll = m.getCenter();
+ infoElm.innerHTML += ''Center: ('' + ll.lat.toFixed(5) +
'',''+
ll.lon.toFixed(5) +'')<br/>'';
+ infoElm.innerHTML += ''Map type: '' + m.getMapType() +
''<br/>'';
+ infoElm.innerHTML += ''Zoom: '' + m.getZoom() +
''<br/>'';
+ }
+ },
+ {
+ desc: ''Set zoom'',
+ action: function(){
+ m.setZoom(8);
+ }
+ },
+ {
+ desc: ''Add marker'',
+ action: function(){
+ var mkr = new mxn.Marker(new mxn.LatLonPoint(37.3419, -122.0419));
+ mkr.setLabel(''Some random place'');
+ mkr.setInfoBubble(''Some information about the random
place'');
+ mkr.click.addHandler(markerEventHandler);
+ mkr.openInfoBubble.addHandler(markerEventHandler);
+ mkr.closeInfoBubble.addHandler(markerEventHandler);
+ m.addMarker(mkr);
+ }
+ },
+ {
+ desc: ''Add marker offscreen'',
+ action: function(){
+ var mkr = new mxn.Marker(new mxn.LatLonPoint(37.3419, -117.0419));
+ mkr.setLabel(''Some other place'');
+ m.addMarker(mkr);
+ }
+ },
+ {
+ desc: ''Auto center'',
+ action: function(){
+ m.autoCenterAndZoom();
+ }
+ },
+ {
+ desc: ''Add line'',
+ action: function(){
+ var pl = new mxn.Polyline([
+ new mxn.LatLonPoint(37.3419, -122.0419),
+ new mxn.LatLonPoint(36.3419, -120.0419),
+ new mxn.LatLonPoint(38.3419, -119.0419),
+ new mxn.LatLonPoint(37.3419, -117.0419)
+ ]);
+ pl.color = ''#00DD55'';
+ m.addPolyline(pl);
+ }
+ },
+ {
+ desc: ''Add controls'',
+ action: function() {
+ m.addLargeControls();
+ m.addControls({
+ pan: true,
+ zoom: ''small'',
+ overview: true,
+ scale: true,
+ map_type: true
+ });
+ }
+ },
+ /*
+ {
+ desc: ''Add Base map type'',
+ action: function() {
+ m.addTileLayer("http://tile.openstreetmap.org/{Z}/{X}/{Y}.png",
1.0, "OSM", 1, 19, true);
+ // m.setMapType("OSM");
+ }
+ },
+ */
+ {
+ desc: ''Swap API (yahoo)'',
+ action: function(){
+ m.swap(''map'', ''yahoo'');
+ }
+ },
+ {
+ desc: ''Swap API (openlayers)'',
+ action: function(){
+ m.swap(''map'', ''openlayers'');
+ }
+ },
{ desc: ''Done.'', action: function(){} }
];
@@ -200,11 +202,11 @@
e.moveNext();
}
}
- // intervalID = setInterval(doNextAction, 2000);
- }
-
- //]]>
- </script>
+ intervalID = setInterval(doNextAction, 2000);
+ }
+
+ //]]>
+ </script>
<style type="text/css">
.box {
float: left;
@@ -225,10 +227,10 @@
height:300px;
}
</style>
- </head>
- <body>
+</head>
+<body>
<div style="height: 400px; width: 1000px; margin: 20px;">
- <div id="map" style="position: relative; width: 500px;
height:
300px;"></div>
+ <div id="map" style="position: relative; width: 500px;
height:
300px;"></div>
<div style="margin-top: 20px;">
<div class="box">
@@ -248,6 +250,6 @@
</div>
</div>
- </body>
+</body>
</html>