Remove Google References
This removes most references to Google, with some remaining since they may point to things which are still relevant. References to Google Code, Google Buzz and Google Maps have been removed
This commit is contained in:
@@ -1,129 +1,129 @@
|
||||
mxn.register('{{api_id}}', {
|
||||
mxn.register('{{api_id}}', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
init: function(element, api) {
|
||||
|
||||
init: function(element, api) {
|
||||
var me = this;
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
applyOptions: function(){
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
applyOptions: function(){
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
addControls: function( args ) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
addSmallControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
addLargeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
addMapTypeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(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
|
||||
|
||||
|
||||
return pin;
|
||||
},
|
||||
|
||||
removeMarker: function(marker) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
removeAllMarkers: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
|
||||
declutterMarkers: function(opts) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
addPolyline: function(polyline, old) {
|
||||
var map = this.maps[this.api];
|
||||
var pl = polyline.toProprietary(this.api);
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
|
||||
return pl;
|
||||
},
|
||||
|
||||
removePolyline: function(polyline) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
|
||||
getCenter: function() {
|
||||
var point;
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
|
||||
return point;
|
||||
},
|
||||
|
||||
setCenter: function(point, options) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
if(options && options.pan) {
|
||||
if(options && options.pan) {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
else {
|
||||
else {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
},
|
||||
|
||||
setZoom: function(zoom) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
getZoom: function() {
|
||||
var map = this.maps[this.api];
|
||||
var zoom;
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
@@ -133,9 +133,9 @@ Mapstraction: {
|
||||
var ne = bbox.getNorthEast();
|
||||
var sw = bbox.getSouthWest();
|
||||
var zoom;
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
@@ -153,12 +153,12 @@ Mapstraction: {
|
||||
break;
|
||||
default:
|
||||
// TODO: Add provider code
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
//return mxn.Mapstraction.ROAD;
|
||||
@@ -169,9 +169,9 @@ Mapstraction: {
|
||||
|
||||
getBounds: function () {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
|
||||
//return new mxn.BoundingBox( , , , );
|
||||
},
|
||||
|
||||
@@ -179,14 +179,14 @@ Mapstraction: {
|
||||
var map = this.maps[this.api];
|
||||
var sw = bounds.getSouthWest();
|
||||
var ne = bounds.getNorthEast();
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
|
||||
},
|
||||
|
||||
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
@@ -201,58 +201,58 @@ Mapstraction: {
|
||||
//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
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
|
||||
mousePosition: function(element) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
// TODO: Add provider code
|
||||
}
|
||||
},
|
||||
|
||||
LatLonPoint: {
|
||||
|
||||
|
||||
toProprietary: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
fromProprietary: function(googlePoint) {
|
||||
fromProprietary: function(point) {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
Marker: {
|
||||
|
||||
|
||||
toProprietary: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
openBubble: function() {
|
||||
openBubble: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
@@ -267,7 +267,7 @@ Marker: {
|
||||
update: function() {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
Polyline: {
|
||||
@@ -275,7 +275,7 @@ Polyline: {
|
||||
toProprietary: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
|
||||
show: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
@@ -283,7 +283,7 @@ Polyline: {
|
||||
hide: function() {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
@@ -1,9 +1,9 @@
|
||||
mxn.register('cloudmade', {
|
||||
mxn.register('cloudmade', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
init: function(element, api) {
|
||||
var me = this;
|
||||
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;
|
||||
@@ -16,7 +16,7 @@ mxn.register('cloudmade', {
|
||||
me.click.fire({'location': new mxn.LatLonPoint(location.lat(), location.lng())});
|
||||
}
|
||||
|
||||
// If the user puts their own Google markers directly on the map
|
||||
// If the user puts their own 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);
|
||||
@@ -31,7 +31,7 @@ mxn.register('cloudmade', {
|
||||
}
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
resizeTo: function(width, height){
|
||||
this.maps[this.api].checkResize();
|
||||
},
|
||||
|
||||
@@ -86,7 +86,7 @@ mxn.register('cloudmade', {
|
||||
}
|
||||
},
|
||||
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
map.setCenter(pt, zoom);
|
||||
@@ -179,7 +179,7 @@ mxn.register('cloudmade', {
|
||||
break;
|
||||
default:
|
||||
// TODO: Add provider code
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
@@ -247,13 +247,13 @@ mxn.register('cloudmade', {
|
||||
getPixelRatio: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
mousePosition: function(element) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
// TODO: Add provider code
|
||||
}
|
||||
},
|
||||
|
||||
@@ -306,7 +306,7 @@ mxn.register('cloudmade', {
|
||||
return cmarker;
|
||||
},
|
||||
|
||||
openBubble: function() {
|
||||
openBubble: function() {
|
||||
var pin = this.proprietary_marker;
|
||||
pin.openInfoWindow(this.infoBubble);
|
||||
},
|
||||
|
@@ -6,7 +6,7 @@
|
||||
var $m = mxn.util.$m;
|
||||
|
||||
/**
|
||||
* Initialise our provider. This function should only be called
|
||||
* Initialise our provider. This function should only be called
|
||||
* from within mapstraction code, not exposed as part of the API.
|
||||
* @private
|
||||
*/
|
||||
@@ -20,7 +20,7 @@ var init = function() {
|
||||
* @name mxn.Mapstraction
|
||||
* @constructor
|
||||
* @param {String} element The HTML element to replace with a map
|
||||
* @param {String} api The API to use, one of 'google', 'googlev3', 'yahoo', 'microsoft', 'openstreetmap', 'multimap', 'map24', 'openlayers', 'mapquest'. If omitted, first loaded provider implementation is used.
|
||||
* @param {String} api The API to use, one of 'yahoo', 'microsoft', 'openstreetmap', 'multimap', 'map24', 'openlayers', 'mapquest'. If omitted, first loaded provider implementation is used.
|
||||
* @param {Bool} debug optional parameter to turn on debug support - this uses alert panels for unsupported actions
|
||||
* @exports Mapstraction as mxn.Mapstraction
|
||||
*/
|
||||
@@ -36,74 +36,74 @@ var Mapstraction = mxn.Mapstraction = function(element, api, debug) {
|
||||
this.layers = [];
|
||||
this.polylines = [];
|
||||
this.images = [];
|
||||
this.controls = [];
|
||||
this.controls = [];
|
||||
this.loaded = {};
|
||||
this.onload = {};
|
||||
this.element = element;
|
||||
|
||||
|
||||
// option defaults
|
||||
this.options = {
|
||||
enableScrollWheelZoom: false,
|
||||
enableDragging: true
|
||||
};
|
||||
|
||||
|
||||
this.addControlsArgs = {};
|
||||
|
||||
|
||||
// set up our invoker for calling API methods
|
||||
this.invoker = new mxn.Invoker(this, 'Mapstraction', function(){ return this.api; });
|
||||
|
||||
|
||||
// Adding our events
|
||||
mxn.addEvents(this, [
|
||||
|
||||
|
||||
/**
|
||||
* Map has loaded
|
||||
* @name mxn.Mapstraction#load
|
||||
* @event
|
||||
*/
|
||||
'load',
|
||||
|
||||
|
||||
/**
|
||||
* Map is clicked {location: LatLonPoint}
|
||||
* @name mxn.Mapstraction#click
|
||||
* @event
|
||||
*/
|
||||
'click',
|
||||
|
||||
|
||||
/**
|
||||
* Map is panned
|
||||
* @name mxn.Mapstraction#endPan
|
||||
* @event
|
||||
*/
|
||||
'endPan',
|
||||
|
||||
|
||||
/**
|
||||
* Zoom is changed
|
||||
* @name mxn.Mapstraction#changeZoom
|
||||
* @event
|
||||
*/
|
||||
'changeZoom',
|
||||
|
||||
|
||||
/**
|
||||
* Marker is removed {marker: Marker}
|
||||
* @name mxn.Mapstraction#markerAdded
|
||||
* @event
|
||||
*/
|
||||
'markerAdded',
|
||||
|
||||
|
||||
/**
|
||||
* Marker is removed {marker: Marker}
|
||||
* @name mxn.Mapstraction#markerRemoved
|
||||
* @event
|
||||
*/
|
||||
'markerRemoved',
|
||||
|
||||
|
||||
/**
|
||||
* Polyline is added {polyline: Polyline}
|
||||
* @name mxn.Mapstraction#polylineAdded
|
||||
* @event
|
||||
*/
|
||||
'polylineAdded',
|
||||
|
||||
|
||||
/**
|
||||
* Polyline is removed {polyline: Polyline}
|
||||
* @name mxn.Mapstraction#polylineRemoved
|
||||
@@ -111,7 +111,7 @@ var Mapstraction = mxn.Mapstraction = function(element, api, debug) {
|
||||
*/
|
||||
'polylineRemoved'
|
||||
]);
|
||||
|
||||
|
||||
// finally initialize our proper API map
|
||||
init.apply(this);
|
||||
};
|
||||
@@ -122,21 +122,21 @@ Mapstraction.SATELLITE = 2;
|
||||
Mapstraction.HYBRID = 3;
|
||||
|
||||
// methods that have no implementation in mapstraction core
|
||||
mxn.addProxyMethods(Mapstraction, [
|
||||
mxn.addProxyMethods(Mapstraction, [
|
||||
/**
|
||||
* Adds a large map panning control and zoom buttons to the map
|
||||
* @name mxn.Mapstraction#addLargeControls
|
||||
* @function
|
||||
*/
|
||||
'addLargeControls',
|
||||
|
||||
|
||||
/**
|
||||
* Adds a map type control to the map (streets, aerial imagery etc)
|
||||
* @name mxn.Mapstraction#addMapTypeControls
|
||||
* @function
|
||||
*/
|
||||
'addMapTypeControls',
|
||||
|
||||
'addMapTypeControls',
|
||||
|
||||
/**
|
||||
* Adds a GeoRSS or KML overlay to the map
|
||||
* some flavors of GeoRSS and KML are not supported by some of the Map providers
|
||||
@@ -145,38 +145,38 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* @param {String} url GeoRSS or KML feed URL
|
||||
* @param {Boolean} autoCenterAndZoom Set true to auto center and zoom after the feed is loaded
|
||||
*/
|
||||
'addOverlay',
|
||||
|
||||
'addOverlay',
|
||||
|
||||
/**
|
||||
* Adds a small map panning control and zoom buttons to the map
|
||||
* @name mxn.Mapstraction#addSmallControls
|
||||
* @function
|
||||
*/
|
||||
'addSmallControls',
|
||||
|
||||
'addSmallControls',
|
||||
|
||||
/**
|
||||
* Applies the current option settings
|
||||
* @name mxn.Mapstraction#applyOptions
|
||||
* @function
|
||||
*/
|
||||
'applyOptions',
|
||||
|
||||
|
||||
/**
|
||||
* Gets the BoundingBox of the map
|
||||
* @name mxn.Mapstraction#getBounds
|
||||
* @function
|
||||
* @returns {BoundingBox} The bounding box for the current map state
|
||||
*/
|
||||
'getBounds',
|
||||
|
||||
'getBounds',
|
||||
|
||||
/**
|
||||
* Gets the central point of the map
|
||||
* @name mxn.Mapstraction#getCenter
|
||||
* @function
|
||||
* @returns {LatLonPoint} The center point of the map
|
||||
*/
|
||||
'getCenter',
|
||||
|
||||
'getCenter',
|
||||
|
||||
/**
|
||||
* Gets the imagery type for the map.
|
||||
* The type can be one of:
|
||||
@@ -185,9 +185,9 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* mxn.Mapstraction.HYBRID
|
||||
* @name mxn.Mapstraction#getMapType
|
||||
* @function
|
||||
* @returns {Number}
|
||||
* @returns {Number}
|
||||
*/
|
||||
'getMapType',
|
||||
'getMapType',
|
||||
|
||||
/**
|
||||
* Returns a ratio to turn distance into pixels based on current projection
|
||||
@@ -195,16 +195,16 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* @function
|
||||
* @returns {Float} ratio
|
||||
*/
|
||||
'getPixelRatio',
|
||||
|
||||
'getPixelRatio',
|
||||
|
||||
/**
|
||||
* Returns the zoom level of the map
|
||||
* @name mxn.Mapstraction#getZoom
|
||||
* @function
|
||||
* @returns {Integer} The zoom level of the map
|
||||
*/
|
||||
'getZoom',
|
||||
|
||||
'getZoom',
|
||||
|
||||
/**
|
||||
* Returns the best zoom level for bounds given
|
||||
* @name mxn.Mapstraction#getZoomLevelForBoundingBox
|
||||
@@ -212,8 +212,8 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* @param {BoundingBox} bbox The bounds to fit
|
||||
* @returns {Integer} The closest zoom level that contains the bounding box
|
||||
*/
|
||||
'getZoomLevelForBoundingBox',
|
||||
|
||||
'getZoomLevelForBoundingBox',
|
||||
|
||||
/**
|
||||
* Displays the coordinates of the cursor in the HTML element
|
||||
* @name mxn.Mapstraction#mousePosition
|
||||
@@ -221,7 +221,7 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* @param {String} element ID of the HTML element to display the coordinates in
|
||||
*/
|
||||
'mousePosition',
|
||||
|
||||
|
||||
/**
|
||||
* Resize the current map to the specified width and height
|
||||
* (since it is actually on a child div of the mapElement passed
|
||||
@@ -232,16 +232,16 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* @param {Integer} width The width the map should be.
|
||||
* @param {Integer} height The width the map should be.
|
||||
*/
|
||||
'resizeTo',
|
||||
|
||||
'resizeTo',
|
||||
|
||||
/**
|
||||
* Sets the map to the appropriate location and zoom for a given BoundingBox
|
||||
* @name mxn.Mapstraction#setBounds
|
||||
* @function
|
||||
* @param {BoundingBox} bounds The bounding box you want the map to show
|
||||
*/
|
||||
'setBounds',
|
||||
|
||||
'setBounds',
|
||||
|
||||
/**
|
||||
* setCenter sets the central point of the map
|
||||
* @name mxn.Mapstraction#setCenter
|
||||
@@ -250,8 +250,8 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* @param {Object} options Optional parameters
|
||||
* @param {Boolean} options.pan Whether the map should move to the locations using a pan or just jump straight there
|
||||
*/
|
||||
'setCenter',
|
||||
|
||||
'setCenter',
|
||||
|
||||
/**
|
||||
* Centers the map to some place and zoom level
|
||||
* @name mxn.Mapstraction#setCenterAndZoom
|
||||
@@ -259,8 +259,8 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* @param {LatLonPoint} point Where the center of the map should be
|
||||
* @param {Integer} zoom The zoom level where 0 is all the way out.
|
||||
*/
|
||||
'setCenterAndZoom',
|
||||
|
||||
'setCenterAndZoom',
|
||||
|
||||
/**
|
||||
* Sets the imagery type for the map
|
||||
* The type can be one of:
|
||||
@@ -269,10 +269,10 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* mxn.Mapstraction.HYBRID
|
||||
* @name mxn.Mapstraction#setMapType
|
||||
* @function
|
||||
* @param {Number} type
|
||||
* @param {Number} type
|
||||
*/
|
||||
'setMapType',
|
||||
|
||||
'setMapType',
|
||||
|
||||
/**
|
||||
* Sets the zoom level for the map
|
||||
* MS doesn't seem to do zoom=0, and Gg's sat goes closer than it's maps, and MS's sat goes closer than Y!'s
|
||||
@@ -282,7 +282,7 @@ mxn.addProxyMethods(Mapstraction, [
|
||||
* @param {Number} zoom The (native to the map) level zoom the map to.
|
||||
*/
|
||||
'setZoom',
|
||||
|
||||
|
||||
/**
|
||||
* Turns a Tile Layer on or off
|
||||
* @name mxn.Mapstraction#toggleTileLayer
|
||||
@@ -505,7 +505,7 @@ Mapstraction.prototype.addMarker = function(marker, old) {
|
||||
marker.mapstraction = this;
|
||||
marker.api = this.api;
|
||||
marker.location.api = this.api;
|
||||
marker.map = this.maps[this.api];
|
||||
marker.map = this.maps[this.api];
|
||||
var propMarker = this.invoker.go('addMarker', arguments);
|
||||
marker.setChild(propMarker);
|
||||
if (!old) {
|
||||
@@ -538,7 +538,7 @@ Mapstraction.prototype.addPolylineWithData = function(polyline, data) {
|
||||
* removeMarker removes a Marker from the map
|
||||
* @param {Marker} marker The marker to remove
|
||||
*/
|
||||
Mapstraction.prototype.removeMarker = function(marker) {
|
||||
Mapstraction.prototype.removeMarker = function(marker) {
|
||||
var current_marker;
|
||||
for(var i = 0; i < this.markers.length; i++){
|
||||
current_marker = this.markers[i];
|
||||
@@ -583,9 +583,6 @@ Mapstraction.prototype.declutterMarkers = function(opts) {
|
||||
// case 'yahoo':
|
||||
//
|
||||
// break;
|
||||
// case 'google':
|
||||
//
|
||||
// break;
|
||||
// case 'openstreetmap':
|
||||
//
|
||||
// break;
|
||||
@@ -824,7 +821,7 @@ Mapstraction.prototype.polylineCenterAndZoom = function(radius) {
|
||||
* @param {north} north boundary
|
||||
*/
|
||||
Mapstraction.prototype.addImageOverlay = function(id, src, opacity, west, south, east, north) {
|
||||
|
||||
|
||||
var b = document.createElement("img");
|
||||
b.style.display = 'block';
|
||||
b.setAttribute('id',id);
|
||||
@@ -835,11 +832,11 @@ Mapstraction.prototype.addImageOverlay = function(id, src, opacity, west, south,
|
||||
b.setAttribute('south',south);
|
||||
b.setAttribute('east',east);
|
||||
b.setAttribute('north',north);
|
||||
|
||||
|
||||
var oContext = {
|
||||
imgElm: b
|
||||
};
|
||||
|
||||
|
||||
this.invoker.go('addImageOverlay', arguments, { context: oContext });
|
||||
};
|
||||
|
||||
@@ -869,7 +866,7 @@ Mapstraction.prototype.setImageOpacity = function(id, opacity) {
|
||||
Mapstraction.prototype.setImagePosition = function(id) {
|
||||
var imgElement = document.getElementById(id);
|
||||
var oContext = {
|
||||
latLng: {
|
||||
latLng: {
|
||||
top: imgElement.getAttribute('north'),
|
||||
left: imgElement.getAttribute('west'),
|
||||
bottom: imgElement.getAttribute('south'),
|
||||
@@ -877,7 +874,7 @@ Mapstraction.prototype.setImagePosition = function(id) {
|
||||
},
|
||||
pixels: { top: 0, right: 0, bottom: 0, left: 0 }
|
||||
};
|
||||
|
||||
|
||||
this.invoker.go('setImagePosition', arguments, { context: oContext });
|
||||
|
||||
imgElement.style.top = oContext.pixels.top.toString() + 'px';
|
||||
@@ -967,8 +964,8 @@ Mapstraction.prototype.addTileLayer = function(tile_url, opacity, copyright_text
|
||||
if(!tile_url) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.tileLayers = this.tileLayers || [];
|
||||
|
||||
this.tileLayers = this.tileLayers || [];
|
||||
opacity = opacity || 0.6;
|
||||
copyright_text = copyright_text || "Mapstraction";
|
||||
min_zoom = min_zoom || 1;
|
||||
@@ -1085,8 +1082,8 @@ Mapstraction.prototype.doFilter = function(showCallback, hideCallback) {
|
||||
else {
|
||||
this.markers[m].show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
if (hideCallback){
|
||||
hideCallback(this.markers[m]);
|
||||
}
|
||||
@@ -1185,11 +1182,11 @@ var LatLonPoint = mxn.LatLonPoint = function(lat, lon) {
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.lng = lon; // lets be lon/lng agnostic
|
||||
|
||||
this.invoker = new mxn.Invoker(this, 'LatLonPoint');
|
||||
|
||||
this.invoker = new mxn.Invoker(this, 'LatLonPoint');
|
||||
};
|
||||
|
||||
mxn.addProxyMethods(LatLonPoint, [
|
||||
mxn.addProxyMethods(LatLonPoint, [
|
||||
'fromProprietary', 'toProprietary'
|
||||
], true);
|
||||
|
||||
@@ -1212,10 +1209,10 @@ LatLonPoint.prototype.distance = function(otherPoint) {
|
||||
// Uses Haversine formula from http://www.movable-type.co.uk
|
||||
var rads = Math.PI / 180;
|
||||
var diffLat = (this.lat-otherPoint.lat) * rads;
|
||||
var diffLon = (this.lon-otherPoint.lon) * rads;
|
||||
var diffLon = (this.lon-otherPoint.lon) * rads;
|
||||
var a = Math.sin(diffLat / 2) * Math.sin(diffLat / 2) +
|
||||
Math.cos(this.lat*rads) * Math.cos(otherPoint.lat*rads) *
|
||||
Math.sin(diffLon/2) * Math.sin(diffLon/2);
|
||||
Math.cos(this.lat*rads) * Math.cos(otherPoint.lat*rads) *
|
||||
Math.sin(diffLon/2) * Math.sin(diffLon/2);
|
||||
return 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)) * 6371; // Earth's mean radius in km
|
||||
};
|
||||
|
||||
@@ -1354,14 +1351,14 @@ var Marker = mxn.Marker = function(point) {
|
||||
this.proprietary_marker = false;
|
||||
this.attributes = [];
|
||||
this.invoker = new mxn.Invoker(this, 'Marker', function(){return this.api;});
|
||||
mxn.addEvents(this, [
|
||||
mxn.addEvents(this, [
|
||||
'openInfoBubble', // Info bubble opened
|
||||
'closeInfoBubble', // Info bubble closed
|
||||
'click' // Marker clicked
|
||||
]);
|
||||
};
|
||||
|
||||
mxn.addProxyMethods(Marker, [
|
||||
mxn.addProxyMethods(Marker, [
|
||||
'fromProprietary',
|
||||
'hide',
|
||||
'openBubble',
|
||||
@@ -1572,8 +1569,8 @@ var Polyline = mxn.Polyline = function(points) {
|
||||
this.invoker = new mxn.Invoker(this, 'Polyline', function(){return this.api;});
|
||||
};
|
||||
|
||||
mxn.addProxyMethods(Polyline, [
|
||||
'fromProprietary',
|
||||
mxn.addProxyMethods(Polyline, [
|
||||
'fromProprietary',
|
||||
'hide',
|
||||
'show',
|
||||
'toProprietary',
|
||||
|
@@ -1,8 +1,8 @@
|
||||
mxn.register('geocommons', {
|
||||
mxn.register('geocommons', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
init: function(element, api) {
|
||||
init: function(element, api) {
|
||||
var me = this;
|
||||
this.element = element;
|
||||
Maker.maker_host='http://maker.geocommons.com';
|
||||
@@ -16,7 +16,7 @@ mxn.register('geocommons', {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
resizeTo: function(width, height){
|
||||
var map = this.maps[this.api];
|
||||
map.setSize(width,height);
|
||||
},
|
||||
@@ -25,23 +25,23 @@ mxn.register('geocommons', {
|
||||
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("Styles", args.styles || false);
|
||||
map.showControl("Basemap", args.map_type || false);
|
||||
map.showControl("Legend", args.legend || false, "open");
|
||||
// showControl("Legend", true, "close");
|
||||
map.showControl("Legend", args.legend || false, "open");
|
||||
// showControl("Legend", true, "close");
|
||||
},
|
||||
|
||||
addSmallControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
showControl("Zoom", args.zoom);
|
||||
showControl("Legend", args.legend, "open");
|
||||
showControl("Legend", args.legend, "open");
|
||||
},
|
||||
|
||||
addLargeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
showControl("Zoom", args.zoom);
|
||||
showControl("Layers", args.layers);
|
||||
showControl("Legend", args.legend, "open");
|
||||
showControl("Legend", args.legend, "open");
|
||||
},
|
||||
|
||||
addMapTypeControls: function() {
|
||||
@@ -56,7 +56,7 @@ mxn.register('geocommons', {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
var map = this.maps[this.api];
|
||||
map.setCenterZoom(point.lat, point.lon,zoom);
|
||||
},
|
||||
@@ -69,7 +69,7 @@ mxn.register('geocommons', {
|
||||
|
||||
setCenter: function(point, options) {
|
||||
var map = this.maps[this.api];
|
||||
map.setCenter(point.lat, point.lon);
|
||||
map.setCenter(point.lat, point.lon);
|
||||
},
|
||||
|
||||
setZoom: function(zoom) {
|
||||
@@ -103,12 +103,9 @@ mxn.register('geocommons', {
|
||||
case mxn.Mapstraction.SATELLITE:
|
||||
map.setMapProvider("BlueMarble");
|
||||
break;
|
||||
case mxn.Mapstraction.HYBRID:
|
||||
map.setMapProvider("Google Hybrid");
|
||||
break;
|
||||
default:
|
||||
map.setMapProvider(type);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
@@ -116,7 +113,7 @@ mxn.register('geocommons', {
|
||||
switch(map.getMapProvider) {
|
||||
case "OpenStreetMap (Road)":
|
||||
retu
|
||||
|
||||
|
||||
}
|
||||
// TODO: Add provider code
|
||||
|
||||
@@ -168,13 +165,13 @@ mxn.register('geocommons', {
|
||||
getPixelRatio: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
mousePosition: function(element) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
// TODO: Add provider code
|
||||
}
|
||||
},
|
||||
|
||||
@@ -184,7 +181,7 @@ mxn.register('geocommons', {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
fromProprietary: function(googlePoint) {
|
||||
fromProprietary: function(point) {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
@@ -196,7 +193,7 @@ mxn.register('geocommons', {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
openBubble: function() {
|
||||
openBubble: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
|
@@ -1,519 +0,0 @@
|
||||
mxn.register('google', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
init: function(element,api) {
|
||||
var me = this;
|
||||
if (GMap2) {
|
||||
if (GBrowserIsCompatible()) {
|
||||
this.maps[api] = new GMap2(element);
|
||||
|
||||
GEvent.addListener(this.maps[api], 'click', function(marker,location) {
|
||||
|
||||
if ( marker && marker.mapstraction_marker ) {
|
||||
marker.mapstraction_marker.click.fire();
|
||||
}
|
||||
else if ( location ) {
|
||||
me.click.fire({'location': new mxn.LatLonPoint(location.y, location.x)});
|
||||
}
|
||||
|
||||
// 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.y,location.x,location,me);
|
||||
}
|
||||
});
|
||||
|
||||
GEvent.addListener(this.maps[api], 'moveend', function() {
|
||||
me.moveendHandler(me);
|
||||
me.endPan.fire();
|
||||
});
|
||||
|
||||
GEvent.addListener(this.maps[api], 'zoomend', function() {
|
||||
me.changeZoom.fire();
|
||||
});
|
||||
|
||||
this.loaded[api] = true;
|
||||
me.load.fire();
|
||||
}
|
||||
else {
|
||||
alert('browser not compatible with Google Maps');
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert(api + ' map script not imported');
|
||||
}
|
||||
},
|
||||
|
||||
applyOptions: function(){
|
||||
var map = this.maps[this.api];
|
||||
|
||||
if(this.options.enableScrollWheelZoom){
|
||||
map.enableContinuousZoom();
|
||||
map.enableScrollWheelZoom();
|
||||
}
|
||||
|
||||
if (this.options.enableDragging) {
|
||||
map.enableDragging();
|
||||
} else {
|
||||
map.disableDragging();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
this.currentElement.style.width = width;
|
||||
this.currentElement.style.height = height;
|
||||
this.maps[this.api].checkResize();
|
||||
},
|
||||
|
||||
addControls: function( args ) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// remove old controls
|
||||
if (this.controls) {
|
||||
while ((ctl = this.controls.pop())) {
|
||||
// Google specific method
|
||||
map.removeControl(ctl);
|
||||
}
|
||||
} 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.scale) {
|
||||
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;
|
||||
}
|
||||
if (args.map_type) {
|
||||
this.addMapTypeControls();
|
||||
}
|
||||
},
|
||||
|
||||
addSmallControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
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());
|
||||
map.addControl(this.controls[0]);
|
||||
this.addControlsArgs.zoom = 'large';
|
||||
this.addControlsArgs.pan = true;
|
||||
},
|
||||
|
||||
addMapTypeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
this.controls.unshift(new GMapTypeControl());
|
||||
map.addControl(this.controls[0]);
|
||||
this.addControlsArgs.map_type = true;
|
||||
},
|
||||
|
||||
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 gpin = marker.toProprietary(this.api);
|
||||
map.addOverlay(gpin);
|
||||
|
||||
GEvent.addListener(gpin, 'infowindowopen', function() {
|
||||
marker.openInfoBubble.fire();
|
||||
});
|
||||
GEvent.addListener(gpin, 'infowindowclose', function() {
|
||||
marker.closeInfoBubble.fire();
|
||||
});
|
||||
return gpin;
|
||||
},
|
||||
|
||||
removeMarker: function(marker) {
|
||||
var map = this.maps[this.api];
|
||||
map.removeOverlay(marker.proprietary_marker);
|
||||
},
|
||||
|
||||
removeAllMarkers: function() {
|
||||
var map = this.maps[this.api];
|
||||
// FIXME: got a feeling this doesn't only delete markers
|
||||
map.clearOverlays();
|
||||
},
|
||||
|
||||
declutterMarkers: function(opts) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
addPolyline: function(polyline, old) {
|
||||
var map = this.maps[this.api];
|
||||
gpolyline = polyline.toProprietary(this.api);
|
||||
map.addOverlay(gpolyline);
|
||||
return gpolyline;
|
||||
},
|
||||
|
||||
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();
|
||||
var point = new mxn.LatLonPoint(pt.lat(),pt.lng());
|
||||
return point;
|
||||
},
|
||||
|
||||
setCenter: function(point, options) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
if(options && options.pan) {
|
||||
map.panTo(pt);
|
||||
}
|
||||
else {
|
||||
map.setCenter(pt);
|
||||
}
|
||||
},
|
||||
|
||||
setZoom: function(zoom) {
|
||||
var map = this.maps[this.api];
|
||||
map.setZoom(zoom);
|
||||
},
|
||||
|
||||
getZoom: function() {
|
||||
var map = this.maps[this.api];
|
||||
return map.getZoom();
|
||||
},
|
||||
|
||||
getZoomLevelForBoundingBox: function( bbox ) {
|
||||
var map = this.maps[this.api];
|
||||
// NE and SW points from the bounding box.
|
||||
var ne = bbox.getNorthEast();
|
||||
var sw = bbox.getSouthWest();
|
||||
var gbox = new GLatLngBounds( sw.toProprietary(this.api), ne.toProprietary(this.api) );
|
||||
var zoom = map.getBoundsZoomLevel( gbox );
|
||||
return zoom;
|
||||
},
|
||||
|
||||
setMapType: function(type) {
|
||||
var map = this.maps[this.api];
|
||||
switch(type) {
|
||||
case mxn.Mapstraction.ROAD:
|
||||
map.setMapType(G_NORMAL_MAP);
|
||||
break;
|
||||
case mxn.Mapstraction.SATELLITE:
|
||||
map.setMapType(G_SATELLITE_MAP);
|
||||
break;
|
||||
case mxn.Mapstraction.HYBRID:
|
||||
map.setMapType(G_HYBRID_MAP);
|
||||
break;
|
||||
default:
|
||||
map.setMapType(type || G_NORMAL_MAP);
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
var map = this.maps[this.api];
|
||||
var type = map.getCurrentMapType();
|
||||
switch(type) {
|
||||
case G_NORMAL_MAP:
|
||||
return mxn.Mapstraction.ROAD;
|
||||
case G_SATELLITE_MAP:
|
||||
return mxn.Mapstraction.SATELLITE;
|
||||
case G_HYBRID_MAP:
|
||||
return mxn.Mapstraction.HYBRID;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
getBounds: function () {
|
||||
var map = this.maps[this.api];
|
||||
var ne, sw, nw, se;
|
||||
var gbox = map.getBounds();
|
||||
sw = gbox.getSouthWest();
|
||||
ne = gbox.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();
|
||||
var gbounds = new GLatLngBounds(new GLatLng(sw.lat,sw.lon),new GLatLng(ne.lat,ne.lon));
|
||||
map.setCenter(gbounds.getCenter(), map.getBoundsZoomLevel(gbounds));
|
||||
},
|
||||
|
||||
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
|
||||
var map = this.maps[this.api];
|
||||
map.getPane(G_MAP_MAP_PANE).appendChild(oContext.imgElm);
|
||||
this.setImageOpacity(id, opacity);
|
||||
this.setImagePosition(id);
|
||||
GEvent.bind(map, "zoomend", this, function() {
|
||||
this.setImagePosition(id);
|
||||
});
|
||||
GEvent.bind(map, "moveend", this, function() {
|
||||
this.setImagePosition(id);
|
||||
});
|
||||
},
|
||||
|
||||
setImagePosition: function(id, oContext) {
|
||||
var map = this.maps[this.api];
|
||||
var topLeftPoint; var bottomRightPoint;
|
||||
|
||||
topLeftPoint = map.fromLatLngToDivPixel( new GLatLng(oContext.latLng.top, oContext.latLng.left) );
|
||||
bottomRightPoint = map.fromLatLngToDivPixel( new GLatLng(oContext.latLng.bottom, oContext.latLng.right) );
|
||||
|
||||
oContext.pixels.top = topLeftPoint.y;
|
||||
oContext.pixels.left = topLeftPoint.x;
|
||||
oContext.pixels.bottom = bottomRightPoint.y;
|
||||
oContext.pixels.right = bottomRightPoint.x;
|
||||
},
|
||||
|
||||
addOverlay: function(url, autoCenterAndZoom) {
|
||||
var map = this.maps[this.api];
|
||||
var geoXML = new GGeoXml(url);
|
||||
map.addOverlay(geoXML, function() {
|
||||
if(autoCenterAndZoom) {
|
||||
geoXML.gotoDefaultViewport(map);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom, map_type) {
|
||||
var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)), 0, "copyleft");
|
||||
var copyrightCollection = new GCopyrightCollection(copyright_text);
|
||||
copyrightCollection.addCopyright(copyright);
|
||||
var tilelayers = [];
|
||||
tilelayers[0] = new GTileLayer(copyrightCollection, min_zoom, max_zoom);
|
||||
tilelayers[0].isPng = function() {
|
||||
return true;
|
||||
};
|
||||
tilelayers[0].getOpacity = function() {
|
||||
return opacity;
|
||||
};
|
||||
tilelayers[0].getTileUrl = function (a, b) {
|
||||
url = tile_url;
|
||||
url = url.replace(/\{Z\}/g,b);
|
||||
url = url.replace(/\{X\}/g,a.x);
|
||||
url = url.replace(/\{Y\}/g,a.y);
|
||||
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);
|
||||
}
|
||||
this.tileLayers.push( [tile_url, tileLayerOverlay, true] );
|
||||
return tileLayerOverlay;
|
||||
},
|
||||
|
||||
toggleTileLayer: function(tile_url) {
|
||||
for (var f=0; f<this.tileLayers.length; f++) {
|
||||
if(this.tileLayers[f][0] == tile_url) {
|
||||
if(this.tileLayers[f][2]) {
|
||||
this.maps[this.api].removeOverlay(this.tileLayers[f][1]);
|
||||
this.tileLayers[f][2] = false;
|
||||
}
|
||||
else {
|
||||
this.maps[this.api].addOverlay(this.tileLayers[f][1]);
|
||||
this.tileLayers[f][2] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getPixelRatio: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
var projection = G_NORMAL_MAP.getProjection();
|
||||
var centerPoint = map.getCenter();
|
||||
var zoom = map.getZoom();
|
||||
var centerPixel = projection.fromLatLngToPixel(centerPoint, zoom);
|
||||
// distance is the distance in metres for 5 pixels (3-4-5 triangle)
|
||||
var distancePoint = projection.fromPixelToLatLng(new GPoint(centerPixel.x + 3, centerPixel.y + 4), zoom);
|
||||
//*1000(km to m), /5 (pythag), *2 (radius to diameter)
|
||||
return 10000/distancePoint.distanceFrom(centerPoint);
|
||||
|
||||
},
|
||||
|
||||
mousePosition: function(element) {
|
||||
var locDisp = document.getElementById(element);
|
||||
if (locDisp !== null) {
|
||||
var map = this.maps[this.api];
|
||||
GEvent.addListener(map, 'mousemove', function (point) {
|
||||
var loc = point.lat().toFixed(4) + ' / ' + point.lng().toFixed(4);
|
||||
locDisp.innerHTML = loc;
|
||||
});
|
||||
locDisp.innerHTML = '0.0000 / 0.0000';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
LatLonPoint: {
|
||||
|
||||
toProprietary: function() {
|
||||
return new GLatLng(this.lat,this.lon);
|
||||
},
|
||||
|
||||
fromProprietary: function(googlePoint) {
|
||||
this.lat = googlePoint.lat();
|
||||
this.lon = googlePoint.lng();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Marker: {
|
||||
|
||||
toProprietary: function() {
|
||||
var infoBubble, event_action, infoDiv, div;
|
||||
var options = {};
|
||||
if(this.labelText){
|
||||
options.title = this.labelText;
|
||||
}
|
||||
if(this.iconUrl){
|
||||
var icon = new GIcon(G_DEFAULT_ICON, this.iconUrl);
|
||||
icon.printImage = icon.mozPrintImage = icon.image;
|
||||
if(this.iconSize) {
|
||||
icon.iconSize = new GSize(this.iconSize[0], this.iconSize[1]);
|
||||
var anchor;
|
||||
if(this.iconAnchor) {
|
||||
anchor = new GPoint(this.iconAnchor[0], this.iconAnchor[1]);
|
||||
}
|
||||
else {
|
||||
// FIXME: hard-coding the anchor point
|
||||
anchor = new GPoint(this.iconSize[0]/2, this.iconSize[1]/2);
|
||||
}
|
||||
icon.iconAnchor = anchor;
|
||||
}
|
||||
if(typeof(this.iconShadowUrl) != 'undefined') {
|
||||
icon.shadow = this.iconShadowUrl;
|
||||
if(this.iconShadowSize) {
|
||||
icon.shadowSize = new GSize(this.iconShadowSize[0], this.iconShadowSize[1]);
|
||||
}
|
||||
} else { // turn off shadow
|
||||
icon.shadow = '';
|
||||
icon.shadowSize = '';
|
||||
}
|
||||
if(this.transparent) {
|
||||
icon.transparent = this.transparent;
|
||||
}
|
||||
if(this.imageMap) {
|
||||
icon.imageMap = this.imageMap;
|
||||
}
|
||||
options.icon = icon;
|
||||
}
|
||||
if(this.draggable){
|
||||
options.draggable = this.draggable;
|
||||
}
|
||||
var gmarker = new GMarker( this.location.toProprietary('google'),options);
|
||||
|
||||
if(this.infoBubble){
|
||||
infoBubble = this.infoBubble;
|
||||
if(this.hover) {
|
||||
event_action = "mouseover";
|
||||
}
|
||||
else {
|
||||
event_action = "click";
|
||||
}
|
||||
GEvent.addListener(gmarker, event_action, function() {
|
||||
gmarker.openInfoWindowHtml(infoBubble, {
|
||||
maxWidth: 100
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if(this.hoverIconUrl){
|
||||
GEvent.addListener(gmarker, "mouseover", function() {
|
||||
gmarker.setImage(this.hoverIconUrl);
|
||||
});
|
||||
GEvent.addListener(gmarker, "mouseout", function() {
|
||||
gmarker.setImage(this.iconUrl);
|
||||
});
|
||||
}
|
||||
|
||||
if(this.infoDiv){
|
||||
infoDiv = this.infoDiv;
|
||||
div = this.div;
|
||||
if(this.hover) {
|
||||
event_action = "mouseover";
|
||||
}
|
||||
else {
|
||||
event_action = "click";
|
||||
}
|
||||
GEvent.addListener(gmarker, event_action, function() {
|
||||
document.getElementById(div).innerHTML = infoDiv;
|
||||
});
|
||||
}
|
||||
|
||||
return gmarker;
|
||||
},
|
||||
|
||||
openBubble: function() {
|
||||
var gpin = this.proprietary_marker;
|
||||
gpin.openInfoWindowHtml(this.infoBubble);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.proprietary_marker.hide();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.proprietary_marker.show();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
point = new mxn.LatLonPoint();
|
||||
point.fromGoogle(this.proprietary_marker.getPoint());
|
||||
this.location = point;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Polyline: {
|
||||
|
||||
toProprietary: function() {
|
||||
var gpoints = [];
|
||||
for (var i = 0, length = this.points.length ; i< length; i++){
|
||||
gpoints.push(this.points[i].toProprietary('google'));
|
||||
}
|
||||
if (this.closed || gpoints[0].equals(gpoints[length-1])) {
|
||||
return new GPolygon(gpoints, this.color, this.width, this.opacity, this.fillColor || "#5462E3", this.opacity || "0.3");
|
||||
} else {
|
||||
return new GPolyline(gpoints, this.color, this.width, this.opacity);
|
||||
}
|
||||
},
|
||||
|
||||
show: function() {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
throw 'Not implemented';
|
||||
}
|
||||
}
|
||||
|
||||
});
|
@@ -1,179 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2007, Andrew Turner
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
// Use http://jsdoc.sourceforge.net/ to generate documentation
|
||||
|
||||
// TODO: add reverse geocoding support
|
||||
|
||||
/**
|
||||
* MapstractionGeocoder instantiates a geocoder with some API choice
|
||||
* @param {Function} callback The function to call when a geocode request returns (function(waypoint))
|
||||
* @param {String} api The API to use, currently only 'mapquest' is supported
|
||||
* @param {Function} error_callback The optional function to call when a geocode request fails
|
||||
* @constructor
|
||||
*/
|
||||
function MapstractionGeocoder(callback, api, error_callback) {
|
||||
this.api = api;
|
||||
this.callback = callback;
|
||||
this.geocoders = new Object();
|
||||
if(error_callback == null) {
|
||||
this.error_callback = this.geocode_error
|
||||
} else {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internal function to actually set the router specific parameters
|
||||
*/
|
||||
MapstractionGeocoder.prototype.addAPI = function(api) {
|
||||
|
||||
me = this;
|
||||
switch (api) {
|
||||
case 'google':
|
||||
this.geocoders[api] = new GClientGeocoder();
|
||||
break;
|
||||
case 'mapquest':
|
||||
//set up the connection to the geocode server
|
||||
var proxyServerName = "";
|
||||
var proxyServerPort = "";
|
||||
var ProxyServerPath = "mapquest_proxy/JSReqHandler.php";
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Geocode error function
|
||||
*/
|
||||
MapstractionGeocoder.prototype.geocode_error = function(response) {
|
||||
alert("Sorry, we were unable to geocode that address");
|
||||
}
|
||||
|
||||
/**
|
||||
* Default handler for geocode request completion
|
||||
*/
|
||||
MapstractionGeocoder.prototype.geocode_callback = function(response, mapstraction_geocoder) {
|
||||
var return_location = new Object();
|
||||
|
||||
// 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);
|
||||
} else {
|
||||
return_location.street = "";
|
||||
return_location.locality = "";
|
||||
return_location.region = "";
|
||||
return_location.country = "";
|
||||
|
||||
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)
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case 'mapquest':
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs a geocoding and then calls the specified callback function with the location
|
||||
* @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;
|
||||
}
|
||||
}
|
@@ -1,443 +0,0 @@
|
||||
mxn.register('googlev3', {
|
||||
|
||||
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){
|
||||
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');
|
||||
}
|
||||
},
|
||||
|
||||
applyOptions: function(){
|
||||
var map = this.maps[this.api];
|
||||
var myOptions = [];
|
||||
if (this.options.enableDragging) {
|
||||
myOptions.draggable = true;
|
||||
}
|
||||
if (this.options.enableScrollWheelZoom){
|
||||
myOptions.scrollwheel = true;
|
||||
}
|
||||
map.setOptions(myOptions);
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
this.currentElement.style.width = width;
|
||||
this.currentElement.style.height = height;
|
||||
var map = this.maps[this.api];
|
||||
google.maps.event.trigger(map,'resize');
|
||||
},
|
||||
|
||||
addControls: function( args ) {
|
||||
var map = this.maps[this.api];
|
||||
// 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';
|
||||
},
|
||||
|
||||
addLargeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
var myOptions = {
|
||||
navigationControl:true,
|
||||
navigationControlOptions: {style:google.maps.NavigationControlStyle.DEFAULT}
|
||||
};
|
||||
map.setOptions(myOptions);
|
||||
this.addControlsArgs.pan = true;
|
||||
this.addControlsArgs.zoom = 'large';
|
||||
},
|
||||
|
||||
addMapTypeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
var myOptions = {
|
||||
mapTypeControl: true,
|
||||
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DEFAULT}
|
||||
};
|
||||
map.setOptions(myOptions);
|
||||
this.addControlsArgs.map_type = true;
|
||||
},
|
||||
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
map.setCenter(pt);
|
||||
map.setZoom(zoom);
|
||||
},
|
||||
|
||||
addMarker: function(marker, old) {
|
||||
return marker.toProprietary(this.api);
|
||||
},
|
||||
|
||||
removeMarker: function(marker) {
|
||||
// doesn't really remove them, just hides them
|
||||
marker.hide();
|
||||
},
|
||||
|
||||
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];
|
||||
return polyline.toProprietary(this.api);
|
||||
},
|
||||
|
||||
removePolyline: function(polyline) {
|
||||
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());
|
||||
},
|
||||
|
||||
setCenter: function(point, options) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
if(options && options.pan) {
|
||||
map.panTo(pt);
|
||||
}
|
||||
else {
|
||||
map.setCenter(pt);
|
||||
}
|
||||
},
|
||||
|
||||
setZoom: function(zoom) {
|
||||
var map = this.maps[this.api];
|
||||
map.setZoom(zoom);
|
||||
},
|
||||
|
||||
getZoom: function() {
|
||||
var map = this.maps[this.api];
|
||||
return map.getZoom();
|
||||
},
|
||||
|
||||
getZoomLevelForBoundingBox: function( bbox ) {
|
||||
var map = this.maps[this.api];
|
||||
var sw = bbox.getSouthWest().toProprietary(this.api);
|
||||
var ne = bbox.getNorthEast().toProprietary(this.api);
|
||||
var gLatLngBounds = new google.maps.LatLngBounds(sw, ne);
|
||||
map.fitBounds(gLatLngBounds);
|
||||
return map.getZoom();
|
||||
},
|
||||
|
||||
setMapType: function(type) {
|
||||
var map = this.maps[this.api];
|
||||
switch(type) {
|
||||
case mxn.Mapstraction.ROAD:
|
||||
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
|
||||
break;
|
||||
case mxn.Mapstraction.SATELLITE:
|
||||
map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
|
||||
break;
|
||||
case mxn.Mapstraction.HYBRID:
|
||||
map.setMapTypeId(google.maps.MapTypeId.HYBRID);
|
||||
break;
|
||||
default:
|
||||
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
var map = this.maps[this.api];
|
||||
var type = map.getMapTypeId();
|
||||
switch(type) {
|
||||
case google.maps.MapTypeId.ROADMAP:
|
||||
return mxn.Mapstraction.ROAD;
|
||||
case google.maps.MapTypeId.SATELLITE:
|
||||
return mxn.Mapstraction.SATELLITE;
|
||||
case google.maps.MapTypeId.HYBRID:
|
||||
return mxn.Mapstraction.HYBRID;
|
||||
//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());
|
||||
},
|
||||
|
||||
setBounds: function(bounds){
|
||||
var map = this.maps[this.api];
|
||||
var sw = bounds.getSouthWest().toProprietary(this.api);
|
||||
var ne = bounds.getNorthEast().toProprietary(this.api);
|
||||
var gLatLngBounds = new google.maps.LatLngBounds(sw, ne);
|
||||
map.fitBounds(gLatLngBounds);
|
||||
},
|
||||
|
||||
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// 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, map_type) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
toggleTileLayer: function(tile_url) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
getPixelRatio: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
mousePosition: function(element) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
}
|
||||
},
|
||||
|
||||
LatLonPoint: {
|
||||
|
||||
toProprietary: function() {
|
||||
return new google.maps.LatLng(this.lat, this.lon);
|
||||
},
|
||||
|
||||
fromProprietary: function(googlePoint) {
|
||||
this.lat = googlePoint.lat();
|
||||
this.lon = googlePoint.lng();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Marker: {
|
||||
|
||||
toProprietary: function() {
|
||||
var options = {};
|
||||
|
||||
// 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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.draggable){
|
||||
options.draggable = this.draggable;
|
||||
}
|
||||
if (this.labelText){
|
||||
options.title = this.labelText;
|
||||
}
|
||||
if (this.imageMap){
|
||||
options.shape = {
|
||||
coord: this.imageMap,
|
||||
type: 'poly'
|
||||
};
|
||||
}
|
||||
|
||||
options.position = this.location.toProprietary(this.api);
|
||||
options.map = this.map;
|
||||
|
||||
var marker = new google.maps.Marker(options);
|
||||
|
||||
if (this.infoBubble){
|
||||
var infowindow = new google.maps.InfoWindow({
|
||||
content: this.infoBubble
|
||||
});
|
||||
|
||||
var event_action = "click";
|
||||
if (this.hover) {
|
||||
event_action = "mouseover";
|
||||
}
|
||||
google.maps.event.addListener(marker, event_action, function() { infowindow.open(this.map,marker); });
|
||||
}
|
||||
|
||||
if (this.hoverIconUrl){
|
||||
var gSize = new google.maps.Size(this.iconSize[0],
|
||||
this.iconSize[1]);
|
||||
var zerozero = new google.maps.Point(0,0);
|
||||
var hIcon = new google.maps.MarkerImage(
|
||||
this.hoverIconUrl,
|
||||
gSize,
|
||||
zerozero,
|
||||
gAnchorPoint
|
||||
);
|
||||
var Icon = new google.maps.MarkerImage(
|
||||
this.iconUrl,
|
||||
gSize,
|
||||
zerozero,
|
||||
gAnchorPoint
|
||||
);
|
||||
google.maps.event.addListener(
|
||||
marker,
|
||||
"mouseover",
|
||||
function(){
|
||||
marker.setIcon(hIcon);
|
||||
}
|
||||
);
|
||||
google.maps.event.addListener(
|
||||
marker,
|
||||
"mouseout",
|
||||
function(){ marker.setIcon(Icon); }
|
||||
);
|
||||
}
|
||||
|
||||
google.maps.event.addListener(marker, 'click', function() {
|
||||
marker.mapstraction_marker.click.fire();
|
||||
});
|
||||
|
||||
return marker;
|
||||
},
|
||||
|
||||
openBubble: function() {
|
||||
var infowindow = new google.maps.InfoWindow({
|
||||
content: this.infoBubble
|
||||
});
|
||||
infowindow.open(this.map,this.proprietary_marker);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.proprietary_marker.setOptions({visible:false});
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.proprietary_marker.setOptions({visible:true});
|
||||
},
|
||||
|
||||
update: function() {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Polyline: {
|
||||
|
||||
toProprietary: function() {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
show: function() {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
throw 'Not implemented';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
@@ -16,7 +16,7 @@
|
||||
var scriptBase;
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
|
||||
// Determine which scripts we need to load
|
||||
// Determine which scripts we need to load
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
var match = scripts[i].src.replace(/%20/g , '').match(/^(.*?)mxn\.js(\?\(\[?(.*?)\]?\))?$/);
|
||||
if (match != null) {
|
||||
@@ -29,7 +29,7 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (providers == null || providers == 'none') return; // Bail out if no auto-load has been found
|
||||
providers = providers.replace(/ /g, '').split(',');
|
||||
modules = modules.replace(/ /g, '').split(',');
|
||||
@@ -57,9 +57,9 @@ var invoke = function(sApiId, sObjName, sFnName, oScope, args){
|
||||
}
|
||||
return apis[sApiId][sObjName][sFnName].apply(oScope, args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether the specified API provides an implementation for the
|
||||
* Determines whether the specified API provides an implementation for the
|
||||
* specified object and function name.
|
||||
* @private
|
||||
*/
|
||||
@@ -68,7 +68,7 @@ var hasImplementation = function(sApiId, sObjName, sFnName){
|
||||
throw 'API ' + sApiId + ' not loaded. Are you missing a script tag?';
|
||||
}
|
||||
if(typeof(apis[sApiId][sObjName]) == 'undefined') {
|
||||
throw 'Object definition ' + sObjName + ' in API ' + sApiId + ' not loaded. Are you missing a script tag?';
|
||||
throw 'Object definition ' + sObjName + ' in API ' + sApiId + ' not loaded. Are you missing a script tag?';
|
||||
}
|
||||
return typeof(apis[sApiId][sObjName][sFnName]) == 'function';
|
||||
};
|
||||
@@ -78,7 +78,7 @@ var hasImplementation = function(sApiId, sObjName, sFnName){
|
||||
* @namespace
|
||||
*/
|
||||
var mxn = window.mxn = /** @lends mxn */ {
|
||||
|
||||
|
||||
/**
|
||||
* Registers a set of provider specific implementation functions.
|
||||
* @function
|
||||
@@ -90,10 +90,10 @@ var mxn = window.mxn = /** @lends mxn */ {
|
||||
apis[sApiId] = {};
|
||||
}
|
||||
mxn.util.merge(apis[sApiId], oApiImpl);
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a list of named proxy methods to the prototype of a
|
||||
* Adds a list of named proxy methods to the prototype of a
|
||||
* specified constructor function.
|
||||
* @function
|
||||
* @param {Function} func Constructor function to add methods to
|
||||
@@ -111,7 +111,7 @@ var mxn = window.mxn = /** @lends mxn */ {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
checkLoad: function(funcDetails){
|
||||
if(this.loaded[this.api] === false) {
|
||||
@@ -122,7 +122,7 @@ var mxn = window.mxn = /** @lends mxn */ {
|
||||
return false;
|
||||
},
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Bulk add some named events to an object.
|
||||
* @function
|
||||
@@ -138,11 +138,11 @@ var mxn = window.mxn = /** @lends mxn */ {
|
||||
oEvtSrc[sEvtName] = new mxn.Event(sEvtName, oEvtSrc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a new Event
|
||||
* Instantiates a new Event
|
||||
* @constructor
|
||||
* @param {String} sEvtName The name of the event.
|
||||
* @param {Object} oEvtSource The source object of the event.
|
||||
@@ -191,7 +191,7 @@ mxn.Event = function(sEvtName, oEvtSource){
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new Invoker, a class which helps with on-the-fly
|
||||
* Creates a new Invoker, a class which helps with on-the-fly
|
||||
* invocation of the correct API methods.
|
||||
* @constructor
|
||||
* @param {Object} aobj The core object whose methods will make cals to go()
|
||||
@@ -202,12 +202,12 @@ mxn.Invoker = function(aobj, asClassName, afnApiIdGetter){
|
||||
var obj = aobj;
|
||||
var sClassName = asClassName;
|
||||
var fnApiIdGetter = afnApiIdGetter;
|
||||
var defOpts = {
|
||||
var defOpts = {
|
||||
overrideApi: false, // {Boolean} API ID is overridden by value in first argument
|
||||
context: null, // {Object} Local vars can be passed from the body of the method to the API method within this object
|
||||
fallback: null // {Function} If an API implementation doesn't exist this function is run instead
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Invoke the API implementation of a specific method.
|
||||
* @param {String} sMethodName The method name to invoke
|
||||
@@ -218,40 +218,40 @@ mxn.Invoker = function(aobj, asClassName, afnApiIdGetter){
|
||||
* @param {Function} oOptions.fallback A fallback function to run if the provider implementation is missing.
|
||||
*/
|
||||
this.go = function(sMethodName, args, oOptions){
|
||||
|
||||
|
||||
if(typeof(oOptions) == 'undefined'){
|
||||
oOptions = defOpts;
|
||||
}
|
||||
|
||||
|
||||
var sApiId = oOptions.overrideApi ? args[0] : fnApiIdGetter.apply(obj);
|
||||
|
||||
|
||||
if(typeof(sApiId) != 'string'){
|
||||
throw 'API ID not available.';
|
||||
}
|
||||
|
||||
|
||||
if(typeof(oOptions.context) != 'undefined' && oOptions.context !== null){
|
||||
// make sure args is an array
|
||||
args = Array.prototype.slice.apply(args);
|
||||
args.push(oOptions.context);
|
||||
}
|
||||
|
||||
|
||||
if(typeof(oOptions.fallback) == 'function' && !hasImplementation(sApiId, sClassName, sMethodName)){
|
||||
// we've got no implementation but have got a fallback function
|
||||
return oOptions.fallback.apply(obj, args);
|
||||
}
|
||||
else {
|
||||
else {
|
||||
return invoke(sApiId, sClassName, sMethodName, obj, args);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
*/
|
||||
mxn.util = {
|
||||
|
||||
|
||||
/**
|
||||
* Merges properties of one object into another recursively.
|
||||
* @param {Object} oRecv The object receiveing properties
|
||||
@@ -269,7 +269,7 @@ mxn.util = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* $m, the dollar function, elegantising getElementById()
|
||||
* @return An HTML element or array of HTML elements
|
||||
@@ -310,7 +310,7 @@ mxn.util = {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
var h = document.getElementsByTagName('head')[0];
|
||||
h.appendChild( script );
|
||||
@@ -403,29 +403,6 @@ mxn.util = {
|
||||
return miles * 1.609344;
|
||||
},
|
||||
|
||||
// stuff to convert google zoom levels to/from degrees
|
||||
// assumes zoom 0 = 256 pixels = 360 degrees
|
||||
// zoom 1 = 256 pixels = 180 degrees
|
||||
// etc.
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Object} pixels
|
||||
* @param {Object} zoom
|
||||
*/
|
||||
getDegreesFromGoogleZoomLevel: function(pixels, zoom) {
|
||||
return (360 * pixels) / (Math.pow(2, zoom + 8));
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Object} pixels
|
||||
* @param {Object} degrees
|
||||
*/
|
||||
getGoogleZoomLevelFromDegrees: function(pixels, degrees) {
|
||||
return mxn.util.logN((360 * pixels) / degrees, 2) - 8;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Object} number
|
||||
@@ -434,7 +411,7 @@ mxn.util = {
|
||||
logN: function(number, base) {
|
||||
return Math.log(number) / Math.log(base);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Returns array of loaded provider apis
|
||||
* @returns {Array} providers
|
||||
@@ -448,7 +425,7 @@ mxn.util = {
|
||||
}
|
||||
return providers;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -456,7 +433,7 @@ mxn.util = {
|
||||
* Accepts either a HTML color string argument or three integers for R, G and B.
|
||||
* @constructor
|
||||
*/
|
||||
mxn.util.Color = function() {
|
||||
mxn.util.Color = function() {
|
||||
if(arguments.length == 3) {
|
||||
this.red = arguments[0];
|
||||
this.green = arguments[1];
|
||||
|
@@ -1,4 +1,4 @@
|
||||
mxn.register('openlayers', {
|
||||
mxn.register('openlayers', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
@@ -86,21 +86,21 @@ mxn.register('openlayers', {
|
||||
// var myOptions = [];
|
||||
// if (this.options.enableDragging) {
|
||||
// myOptions.draggable = true;
|
||||
// }
|
||||
// }
|
||||
// if (this.options.enableScrollWheelZoom){
|
||||
// myOptions.scrollwheel = true;
|
||||
// }
|
||||
// }
|
||||
// map.setOptions(myOptions);
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
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];
|
||||
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();
|
||||
@@ -112,12 +112,12 @@ mxn.register('openlayers', {
|
||||
else if ( args.zoom == 'small' ) {
|
||||
map.addControl(new OpenLayers.Control.ZoomPanel());
|
||||
if ( args.pan) {
|
||||
map.addControl(new OpenLayers.Control.PanPanel());
|
||||
map.addControl(new OpenLayers.Control.PanPanel());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( args.pan){
|
||||
map.addControl(new OpenLayers.Control.PanPanel());
|
||||
map.addControl(new OpenLayers.Control.PanPanel());
|
||||
}
|
||||
}
|
||||
if ( args.overview ) {
|
||||
@@ -131,12 +131,12 @@ mxn.register('openlayers', {
|
||||
addSmallControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
this.addControlsArgs.pan = false;
|
||||
this.addControlsArgs.scale = 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() {
|
||||
@@ -154,7 +154,7 @@ mxn.register('openlayers', {
|
||||
this.addControlsArgs.map_type = true;
|
||||
},
|
||||
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
map.setCenter(point.toProprietary(this.api), zoom);
|
||||
@@ -215,7 +215,7 @@ mxn.register('openlayers', {
|
||||
for(var i = 0, length = this.polylines.length; i < length; i++){
|
||||
olpolylines.push(this.polylines[i].toProprietary(this.api));
|
||||
}
|
||||
if (this.layers['polylines']) this.layers['polylines'].removeFeatures(olpolylines);
|
||||
if (this.layers['polylines']) this.layers['polylines'].removeFeatures(olpolylines);
|
||||
},
|
||||
|
||||
getCenter: function() {
|
||||
@@ -228,7 +228,7 @@ mxn.register('openlayers', {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
map.setCenter(pt);
|
||||
|
||||
|
||||
},
|
||||
|
||||
setZoom: function(zoom) {
|
||||
@@ -250,46 +250,18 @@ mxn.register('openlayers', {
|
||||
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);
|
||||
return new mxn.BoundingBox(olbox.bottom, olbox.left, olbox.top, olbox.right);
|
||||
},
|
||||
|
||||
setBounds: function(bounds){
|
||||
@@ -302,7 +274,7 @@ mxn.register('openlayers', {
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -348,13 +320,13 @@ mxn.register('openlayers', {
|
||||
getPixelRatio: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
mousePosition: function(element) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
// TODO: Add provider code
|
||||
}
|
||||
},
|
||||
|
||||
@@ -364,7 +336,7 @@ mxn.register('openlayers', {
|
||||
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);
|
||||
return new OpenLayers.LonLat(ollon, ollat);
|
||||
},
|
||||
|
||||
fromProprietary: function(olPoint) {
|
||||
@@ -448,7 +420,7 @@ mxn.register('openlayers', {
|
||||
return marker;
|
||||
},
|
||||
|
||||
openBubble: function() {
|
||||
openBubble: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user