[CORE][COMPOSER] Move extlib packages with immediate composer correspondent to composer dependencies
This adds a composer.json for all dependencies that are available
15
public/plugins/Mapstraction/OpenLayers/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
.fake: clean all
|
||||
|
||||
TARGET=OpenLayers.js
|
||||
SOURCEDIR=OpenLayers-2.10/
|
||||
HERE=`pwd`
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
|
||||
$(TARGET): statusnet.cfg
|
||||
cp -f statusnet.cfg $(SOURCEDIR)/build/statusnet.cfg
|
||||
(cd $(SOURCEDIR)/build && ./build.py statusnet.cfg)
|
||||
yui-compressor $(SOURCEDIR)/build/OpenLayers.js -o $(TARGET)
|
1
public/plugins/Mapstraction/OpenLayers/OpenLayers.js
Normal file
14
public/plugins/Mapstraction/OpenLayers/README
Normal file
@@ -0,0 +1,14 @@
|
||||
The default OpenLayers.js file, minified, weighs in at a whopping 943kb uncompressed.
|
||||
With gzip compression it's still over 200kb, so we're building a stripped-down copy
|
||||
with just what we need.
|
||||
|
||||
Docs on how the stripping process works:
|
||||
http://docs.openlayers.org/library/deploying.html
|
||||
|
||||
To recreate this OpenLayers.js file:
|
||||
|
||||
# get yui-compressor (install from apt, or set up a shell script or alias to the jar)
|
||||
# download and decompress OpenLayers-2.10 zip or tgz
|
||||
make clean && make
|
||||
|
||||
If necessary, change the relative path to the OpenLayers source directory in the Makefile.
|
BIN
public/plugins/Mapstraction/OpenLayers/img/blank.gif
Normal file
After Width: | Height: | Size: 42 B |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
BIN
public/plugins/Mapstraction/OpenLayers/img/drag-rectangle-on.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
public/plugins/Mapstraction/OpenLayers/img/east-mini.png
Normal file
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 249 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/marker-blue.png
Normal file
After Width: | Height: | Size: 992 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/marker-gold.png
Normal file
After Width: | Height: | Size: 831 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/marker-green.png
Normal file
After Width: | Height: | Size: 967 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/marker.png
Normal file
After Width: | Height: | Size: 606 B |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 3.7 KiB |
BIN
public/plugins/Mapstraction/OpenLayers/img/north-mini.png
Normal file
After Width: | Height: | Size: 484 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/panning-hand-off.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
public/plugins/Mapstraction/OpenLayers/img/panning-hand-on.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
public/plugins/Mapstraction/OpenLayers/img/slider.png
Normal file
After Width: | Height: | Size: 285 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/south-mini.png
Normal file
After Width: | Height: | Size: 481 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/west-mini.png
Normal file
After Width: | Height: | Size: 453 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/zoom-minus-mini.png
Normal file
After Width: | Height: | Size: 359 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/zoom-plus-mini.png
Normal file
After Width: | Height: | Size: 489 B |
BIN
public/plugins/Mapstraction/OpenLayers/img/zoom-world-mini.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
public/plugins/Mapstraction/OpenLayers/img/zoombar.png
Normal file
After Width: | Height: | Size: 463 B |
43
public/plugins/Mapstraction/OpenLayers/statusnet.cfg
Normal file
@@ -0,0 +1,43 @@
|
||||
# Modified lite.cfg for building an OpenLayers subset for StatusNet's Mapstraction plugin.
|
||||
|
||||
# This file includes a small subset of OpenLayers code, designed to be
|
||||
# integrated into another application. It includes only the Layer types
|
||||
# neccesary to create tiled or untiled WMS, and does not include any Controls.
|
||||
# This is the result of what was at the time called "Webmap.js" at the FOSS4G
|
||||
# Web Mapping BOF.
|
||||
|
||||
[first]
|
||||
OpenLayers/SingleFile.js
|
||||
OpenLayers.js
|
||||
OpenLayers/BaseTypes.js
|
||||
OpenLayers/BaseTypes/Class.js
|
||||
OpenLayers/Util.js
|
||||
|
||||
[last]
|
||||
|
||||
[include]
|
||||
OpenLayers/Map.js
|
||||
OpenLayers/Layer/WMS.js
|
||||
|
||||
# Needed for Mapstraction on StatusNet
|
||||
OpenLayers/Feature.js
|
||||
OpenLayers/Feature/Vector.js
|
||||
OpenLayers/Geometry.js
|
||||
OpenLayers/Geometry/Point.js
|
||||
OpenLayers/Geometry/LinearRing.js
|
||||
OpenLayers/Geometry/LineString.js
|
||||
OpenLayers/Icon.js
|
||||
OpenLayers/Layer/Markers.js
|
||||
OpenLayers/Layer/TMS.js
|
||||
OpenLayers/Marker.js
|
||||
OpenLayers/Popup.js
|
||||
|
||||
# Default controls, needed to keep the map dynamic
|
||||
OpenLayers/Control/ArgParser.js
|
||||
OpenLayers/Control/Attribution.js
|
||||
OpenLayers/Control/Navigation.js
|
||||
OpenLayers/Control/PanZoom.js
|
||||
|
||||
[exclude]
|
||||
|
||||
|
@@ -0,0 +1,7 @@
|
||||
.olControlZoomPanel div {
|
||||
background-image: url(img/zoom-panel-NOALPHA.png);
|
||||
}
|
||||
.olControlPanPanel div {
|
||||
background-image: url(img/pan-panel-NOALPHA.png);
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 42 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 79 B |
After Width: | Height: | Size: 566 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 357 B |
After Width: | Height: | Size: 364 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.6 KiB |
389
public/plugins/Mapstraction/OpenLayers/theme/default/style.css
Normal file
@@ -0,0 +1,389 @@
|
||||
div.olMap {
|
||||
z-index: 0;
|
||||
padding: 0px!important;
|
||||
margin: 0px!important;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
div.olMapViewport {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.olLayerDiv {
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.olControlAttribution {
|
||||
font-size: smaller;
|
||||
right: 3px;
|
||||
bottom: 4.5em;
|
||||
position: absolute;
|
||||
display: block;
|
||||
}
|
||||
.olControlScale {
|
||||
right: 3px;
|
||||
bottom: 3em;
|
||||
display: block;
|
||||
position: absolute;
|
||||
font-size: smaller;
|
||||
}
|
||||
.olControlScaleLine {
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
bottom: 15px;
|
||||
font-size: xx-small;
|
||||
}
|
||||
.olControlScaleLineBottom {
|
||||
border: solid 2px black;
|
||||
border-bottom: none;
|
||||
margin-top:-2px;
|
||||
text-align: center;
|
||||
}
|
||||
.olControlScaleLineTop {
|
||||
border: solid 2px black;
|
||||
border-top: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.olControlPermalink {
|
||||
right: 3px;
|
||||
bottom: 1.5em;
|
||||
display: block;
|
||||
position: absolute;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
div.olControlMousePosition {
|
||||
bottom: 0em;
|
||||
right: 3px;
|
||||
display: block;
|
||||
position: absolute;
|
||||
font-family: Arial;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.olControlOverviewMapContainer {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.olControlOverviewMapElement {
|
||||
padding: 10px 18px 10px 10px;
|
||||
background-color: #00008B;
|
||||
-moz-border-radius: 1em 0 0 0;
|
||||
}
|
||||
|
||||
.olControlOverviewMapMinimizeButton {
|
||||
right: 0px;
|
||||
bottom: 80px;
|
||||
}
|
||||
|
||||
.olControlOverviewMapMaximizeButton {
|
||||
right: 0px;
|
||||
bottom: 80px;
|
||||
}
|
||||
|
||||
.olControlOverviewMapExtentRectangle {
|
||||
overflow: hidden;
|
||||
background-image: url("img/blank.gif");
|
||||
cursor: move;
|
||||
border: 2px dotted red;
|
||||
}
|
||||
.olControlOverviewMapRectReplacement {
|
||||
overflow: hidden;
|
||||
cursor: move;
|
||||
background-image: url("img/overview_replacement.gif");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.olLayerGeoRSSDescription {
|
||||
float:left;
|
||||
width:100%;
|
||||
overflow:auto;
|
||||
font-size:1.0em;
|
||||
}
|
||||
.olLayerGeoRSSClose {
|
||||
float:right;
|
||||
color:gray;
|
||||
font-size:1.2em;
|
||||
margin-right:6px;
|
||||
font-family:sans-serif;
|
||||
}
|
||||
.olLayerGeoRSSTitle {
|
||||
float:left;font-size:1.2em;
|
||||
}
|
||||
|
||||
.olPopupContent {
|
||||
padding:5px;
|
||||
overflow: auto;
|
||||
}
|
||||
.olControlNavToolbar {
|
||||
width:0px;
|
||||
height:0px;
|
||||
}
|
||||
.olControlNavToolbar div {
|
||||
display:block;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
top: 300px;
|
||||
left: 6px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.olControlNavigationHistory {
|
||||
background-image: url("img/navigation_history.png");
|
||||
background-repeat: no-repeat;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
|
||||
}
|
||||
.olControlNavigationHistoryPreviousItemActive {
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
.olControlNavigationHistoryPreviousItemInactive {
|
||||
background-position: 0px -24px;
|
||||
}
|
||||
.olControlNavigationHistoryNextItemActive {
|
||||
background-position: -24px 0px;
|
||||
}
|
||||
.olControlNavigationHistoryNextItemInactive {
|
||||
background-position: -24px -24px;
|
||||
}
|
||||
|
||||
.olControlNavToolbar .olControlNavigationItemActive {
|
||||
background-image: url("img/panning-hand-on.png");
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.olControlNavToolbar .olControlNavigationItemInactive {
|
||||
background-image: url("img/panning-hand-off.png");
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.olControlNavToolbar .olControlZoomBoxItemActive {
|
||||
background-image: url("img/drag-rectangle-on.png");
|
||||
background-color: orange;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.olControlNavToolbar .olControlZoomBoxItemInactive {
|
||||
background-image: url("img/drag-rectangle-off.png");
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.olControlEditingToolbar {
|
||||
float:right;
|
||||
right: 0px;
|
||||
height: 30px;
|
||||
width: 200px;
|
||||
}
|
||||
.olControlEditingToolbar div {
|
||||
background-image: url("img/editing_tool_bar.png");
|
||||
background-repeat: no-repeat;
|
||||
float:right;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin: 5px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlNavigationItemActive {
|
||||
background-position: -103px -23px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlNavigationItemInactive {
|
||||
background-position: -103px -0px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlDrawFeaturePointItemActive {
|
||||
background-position: -77px -23px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlDrawFeaturePointItemInactive {
|
||||
background-position: -77px -0px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlDrawFeaturePathItemInactive {
|
||||
background-position: -51px 0px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlDrawFeaturePathItemActive {
|
||||
background-position: -51px -23px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlDrawFeaturePolygonItemInactive {
|
||||
background-position: -26px 0px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlDrawFeaturePolygonItemActive {
|
||||
background-position: -26px -23px ;
|
||||
}
|
||||
div.olControlSaveFeaturesItemActive {
|
||||
background-image: url(img/save_features_on.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0px 1px;
|
||||
}
|
||||
div.olControlSaveFeaturesItemInactive {
|
||||
background-image: url(img/save_features_off.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0px 1px;
|
||||
}
|
||||
|
||||
.olHandlerBoxZoomBox {
|
||||
border: 2px solid red;
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
opacity: 0.50;
|
||||
font-size: 1px;
|
||||
filter: alpha(opacity=50);
|
||||
}
|
||||
.olHandlerBoxSelectFeature {
|
||||
border: 2px solid blue;
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
opacity: 0.50;
|
||||
font-size: 1px;
|
||||
filter: alpha(opacity=50);
|
||||
}
|
||||
|
||||
.olControlPanPanel {
|
||||
top: 10px;
|
||||
left: 5px;
|
||||
}
|
||||
|
||||
.olControlPanPanel div {
|
||||
background-image: url(img/pan-panel.png);
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.olControlPanPanel .olControlPanNorthItemInactive {
|
||||
top: 0px;
|
||||
left: 9px;
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
.olControlPanPanel .olControlPanSouthItemInactive {
|
||||
top: 36px;
|
||||
left: 9px;
|
||||
background-position: 18px 0px;
|
||||
}
|
||||
.olControlPanPanel .olControlPanWestItemInactive {
|
||||
position: absolute;
|
||||
top: 18px;
|
||||
left: 0px;
|
||||
background-position: 0px 18px;
|
||||
}
|
||||
.olControlPanPanel .olControlPanEastItemInactive {
|
||||
top: 18px;
|
||||
left: 18px;
|
||||
background-position: 18px 18px;
|
||||
}
|
||||
|
||||
.olControlZoomPanel {
|
||||
top: 71px;
|
||||
left: 14px;
|
||||
}
|
||||
|
||||
.olControlZoomPanel div {
|
||||
background-image: url(img/zoom-panel.png);
|
||||
position: absolute;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.olControlZoomPanel .olControlZoomInItemInactive {
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
|
||||
.olControlZoomPanel .olControlZoomToMaxExtentItemInactive {
|
||||
top: 18px;
|
||||
left: 0px;
|
||||
background-position: 0px -18px;
|
||||
}
|
||||
|
||||
.olControlZoomPanel .olControlZoomOutItemInactive {
|
||||
top: 36px;
|
||||
left: 0px;
|
||||
background-position: 0px 18px;
|
||||
}
|
||||
|
||||
.olPopupCloseBox {
|
||||
background: url("img/close.gif") no-repeat;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.olFramedCloudPopupContent {
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.olControlNoSelect {
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.olImageLoadError {
|
||||
background-color: pink;
|
||||
opacity: 0.5;
|
||||
filter: alpha(opacity=50); /* IE */
|
||||
}
|
||||
|
||||
/**
|
||||
* Cursor styles
|
||||
*/
|
||||
|
||||
.olCursorWait {
|
||||
cursor: wait;
|
||||
}
|
||||
.olDragDown {
|
||||
cursor: move;
|
||||
}
|
||||
.olDrawBox {
|
||||
cursor: crosshair;
|
||||
}
|
||||
.olControlDragFeatureOver {
|
||||
cursor: move;
|
||||
}
|
||||
.olControlDragFeatureActive.olControlDragFeatureOver.olDragDown {
|
||||
cursor: -moz-grabbing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Layer switcher
|
||||
*/
|
||||
.olControlLayerSwitcher {
|
||||
position: absolute;
|
||||
top: 25px;
|
||||
right: 0px;
|
||||
width: 20em;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
margin-top: 3px;
|
||||
margin-left: 3px;
|
||||
margin-bottom: 3px;
|
||||
font-size: smaller;
|
||||
color: white;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.olControlLayerSwitcher .layersDiv {
|
||||
padding-top: 5px;
|
||||
padding-left: 10px;
|
||||
padding-bottom: 5px;
|
||||
padding-right: 75px;
|
||||
background-color: darkblue;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.olControlLayerSwitcher .layersDiv .baseLbl,
|
||||
.olControlLayerSwitcher .layersDiv .dataLbl {
|
||||
margin-top: 3px;
|
||||
margin-left: 3px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.olControlLayerSwitcher .layersDiv .baseLayersDiv,
|
||||
.olControlLayerSwitcher .layersDiv .dataLayersDiv {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.olControlLayerSwitcher .maximizeDiv,
|
||||
.olControlLayerSwitcher .minimizeDiv {
|
||||
top: 5px;
|
||||
right: 0px;
|
||||
}
|
289
public/plugins/Mapstraction/js/mxn.(provider).core.js
Normal file
@@ -0,0 +1,289 @@
|
||||
mxn.register('{{api_id}}', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
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){
|
||||
// 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) {
|
||||
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) {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
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;
|
||||
},
|
||||
|
||||
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:
|
||||
// TODO: Add provider code
|
||||
break;
|
||||
case mxn.Mapstraction.SATELLITE:
|
||||
// TODO: Add provider code
|
||||
break;
|
||||
case mxn.Mapstraction.HYBRID:
|
||||
// TODO: Add provider code
|
||||
break;
|
||||
default:
|
||||
// TODO: Add provider code
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
//return mxn.Mapstraction.ROAD;
|
||||
//return mxn.Mapstraction.SATELLITE;
|
||||
//return mxn.Mapstraction.HYBRID;
|
||||
|
||||
},
|
||||
|
||||
getBounds: function () {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
//return new mxn.BoundingBox( , , , );
|
||||
},
|
||||
|
||||
setBounds: function(bounds){
|
||||
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
|
||||
},
|
||||
|
||||
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() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
fromProprietary: function(point) {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Marker: {
|
||||
|
||||
toProprietary: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
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() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
show: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
357
public/plugins/Mapstraction/js/mxn.cloudmade.core.js
Normal file
@@ -0,0 +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 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
1755
public/plugins/Mapstraction/js/mxn.core.js
Normal file
230
public/plugins/Mapstraction/js/mxn.geocommons.core.js
Normal file
@@ -0,0 +1,230 @@
|
||||
mxn.register('geocommons', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
init: function(element, api) {
|
||||
var me = this;
|
||||
this.element = element;
|
||||
Maker.maker_host='http://maker.geocommons.com';
|
||||
Maker.finder_host='http://finder.geocommons.com';
|
||||
Maker.core_host='http://geocommons.com';
|
||||
},
|
||||
|
||||
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];
|
||||
showControl("Zoom", args.zoom);
|
||||
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");
|
||||
},
|
||||
|
||||
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 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;
|
||||
default:
|
||||
map.setMapProvider(type);
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
var map = this.maps[this.api];
|
||||
switch(map.getMapProvider) {
|
||||
case "OpenStreetMap (Road)":
|
||||
retu
|
||||
|
||||
}
|
||||
// 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
|
||||
},
|
||||
|
||||
addOverlay: function(url, autoCenterAndZoom) {
|
||||
var map = this.maps[this.api];
|
||||
var me = this;
|
||||
Maker.load_map(this.element.id, url);
|
||||
setTimeout(function() { me.maps[me.api] = swfobject.getObjectById(FlashMap.dom_id);}, 500);
|
||||
},
|
||||
|
||||
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() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
fromProprietary: function(point) {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Marker: {
|
||||
|
||||
toProprietary: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
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() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
show: function() {
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
// TODO: Add provider code
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
482
public/plugins/Mapstraction/js/mxn.js
Normal file
@@ -0,0 +1,482 @@
|
||||
// Auto-load scripts
|
||||
//
|
||||
// specify which map providers to load by using
|
||||
// <script src="mxn.js?(provider1,provider2,[module1,module2])" ...
|
||||
// in your HTML
|
||||
//
|
||||
// for each provider mxn.provider.module.js and mxn.module.js will be loaded
|
||||
// module 'core' is always loaded
|
||||
//
|
||||
// NOTE: if you call without providers
|
||||
// <script src="mxn.js" ...
|
||||
// no scripts will be loaded at all and it is then up to you to load the scripts independently
|
||||
(function() {
|
||||
var providers = null;
|
||||
var modules = 'core';
|
||||
var scriptBase;
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
|
||||
// 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) {
|
||||
scriptBase = match[1];
|
||||
if (match[3]) {
|
||||
var settings = match[3].split(',[');
|
||||
providers = settings[0].replace(']' , '');
|
||||
if (settings[1]) modules += ',' + settings[1];
|
||||
}
|
||||
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(',');
|
||||
|
||||
// Actually load the scripts
|
||||
for (i = 0; i < modules.length; i++) {
|
||||
document.write("<script type='text/javascript' src='" + scriptBase + 'mxn.' + modules[i] + '.js' + "'></script>");
|
||||
for (var j = 0; j < providers.length; j++) document.write("<script type='text/javascript' src='" + scriptBase + 'mxn.' + providers[j] + '.' + modules[i] + '.js' + "'></script>");
|
||||
}
|
||||
})();
|
||||
|
||||
(function(){
|
||||
|
||||
// holds all our implementing functions
|
||||
var apis = {};
|
||||
|
||||
// Our special private methods
|
||||
/**
|
||||
* Calls the API specific implementation of a particular method.
|
||||
* @private
|
||||
*/
|
||||
var invoke = function(sApiId, sObjName, sFnName, oScope, args){
|
||||
if(!hasImplementation(sApiId, sObjName, sFnName)) {
|
||||
throw 'Method ' + sFnName + ' of object ' + sObjName + ' is not supported by API ' + sApiId + '. Are you missing a script tag?';
|
||||
}
|
||||
return apis[sApiId][sObjName][sFnName].apply(oScope, args);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the specified API provides an implementation for the
|
||||
* specified object and function name.
|
||||
* @private
|
||||
*/
|
||||
var hasImplementation = function(sApiId, sObjName, sFnName){
|
||||
if(typeof(apis[sApiId]) == 'undefined') {
|
||||
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?';
|
||||
}
|
||||
return typeof(apis[sApiId][sObjName][sFnName]) == 'function';
|
||||
};
|
||||
|
||||
/**
|
||||
* @name mxn
|
||||
* @namespace
|
||||
*/
|
||||
var mxn = window.mxn = /** @lends mxn */ {
|
||||
|
||||
/**
|
||||
* Registers a set of provider specific implementation functions.
|
||||
* @function
|
||||
* @param {String} sApiId The API ID to register implementing functions for.
|
||||
* @param {Object} oApiImpl An object containing the API implementation.
|
||||
*/
|
||||
register: function(sApiId, oApiImpl){
|
||||
if(!apis.hasOwnProperty(sApiId)){
|
||||
apis[sApiId] = {};
|
||||
}
|
||||
mxn.util.merge(apis[sApiId], oApiImpl);
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param {Array} aryMethods Array of method names to create
|
||||
* @param {Boolean} bWithApiArg Optional. Whether the proxy methods will use an API argument
|
||||
*/
|
||||
addProxyMethods: function(func, aryMethods, bWithApiArg){
|
||||
for(var i = 0; i < aryMethods.length; i++) {
|
||||
var sMethodName = aryMethods[i];
|
||||
if(bWithApiArg){
|
||||
func.prototype[sMethodName] = new Function('return this.invoker.go(\'' + sMethodName + '\', arguments, { overrideApi: true } );');
|
||||
}
|
||||
else {
|
||||
func.prototype[sMethodName] = new Function('return this.invoker.go(\'' + sMethodName + '\', arguments);');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
checkLoad: function(funcDetails){
|
||||
if(this.loaded[this.api] === false) {
|
||||
var scope = this;
|
||||
this.onload[this.api].push( function() { funcDetails.callee.apply(scope, funcDetails); } );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bulk add some named events to an object.
|
||||
* @function
|
||||
* @param {Object} oEvtSrc The event source object.
|
||||
* @param {String[]} aEvtNames Event names to add.
|
||||
*/
|
||||
addEvents: function(oEvtSrc, aEvtNames){
|
||||
for(var i = 0; i < aEvtNames.length; i++){
|
||||
var sEvtName = aEvtNames[i];
|
||||
if(sEvtName in oEvtSrc){
|
||||
throw 'Event or method ' + sEvtName + ' already declared.';
|
||||
}
|
||||
oEvtSrc[sEvtName] = new mxn.Event(sEvtName, oEvtSrc);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a new Event
|
||||
* @constructor
|
||||
* @param {String} sEvtName The name of the event.
|
||||
* @param {Object} oEvtSource The source object of the event.
|
||||
*/
|
||||
mxn.Event = function(sEvtName, oEvtSource){
|
||||
var handlers = [];
|
||||
if(!sEvtName){
|
||||
throw 'Event name must be provided';
|
||||
}
|
||||
/**
|
||||
* Add a handler to the Event.
|
||||
* @param {Function} fn The handler function.
|
||||
* @param {Object} ctx The context of the handler function.
|
||||
*/
|
||||
this.addHandler = function(fn, ctx){
|
||||
handlers.push({context: ctx, handler: fn});
|
||||
};
|
||||
/**
|
||||
* Remove a handler from the Event.
|
||||
* @param {Function} fn The handler function.
|
||||
* @param {Object} ctx The context of the handler function.
|
||||
*/
|
||||
this.removeHandler = function(fn, ctx){
|
||||
for(var i = 0; i < handlers.length; i++){
|
||||
if(handlers[i].handler == fn && handlers[i].context == ctx){
|
||||
handlers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Remove all handlers from the Event.
|
||||
*/
|
||||
this.removeAllHandlers = function(){
|
||||
handlers = [];
|
||||
};
|
||||
/**
|
||||
* Fires the Event.
|
||||
* @param {Object} oEvtArgs Event arguments object to be passed to the handlers.
|
||||
*/
|
||||
this.fire = function(oEvtArgs){
|
||||
var args = [sEvtName, oEvtSource, oEvtArgs];
|
||||
for(var i = 0; i < handlers.length; i++){
|
||||
handlers[i].handler.apply(handlers[i].context, args);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 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()
|
||||
* @param {String} asClassName The name of the Mapstraction class to be invoked, normally the same name as aobj's constructor function
|
||||
* @param {Function} afnApiIdGetter The function on object aobj which will return the active API ID
|
||||
*/
|
||||
mxn.Invoker = function(aobj, asClassName, afnApiIdGetter){
|
||||
var obj = aobj;
|
||||
var sClassName = asClassName;
|
||||
var fnApiIdGetter = afnApiIdGetter;
|
||||
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
|
||||
* @param {Array} args Arguments to pass on
|
||||
* @param {Object} oOptions Optional. Extra options for invocation
|
||||
* @param {Boolean} oOptions.overrideApi When true the first argument is used as the API ID.
|
||||
* @param {Object} oOptions.context A context object for passing extra information on to the provider implementation.
|
||||
* @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 {
|
||||
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
|
||||
* @param {Object} oGive The object donating properties
|
||||
*/
|
||||
merge: function(oRecv, oGive){
|
||||
for (var sPropName in oGive){
|
||||
if (oGive.hasOwnProperty(sPropName)) {
|
||||
if(!oRecv.hasOwnProperty(sPropName)){
|
||||
oRecv[sPropName] = oGive[sPropName];
|
||||
}
|
||||
else {
|
||||
mxn.util.merge(oRecv[sPropName], oGive[sPropName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* $m, the dollar function, elegantising getElementById()
|
||||
* @return An HTML element or array of HTML elements
|
||||
*/
|
||||
$m: function() {
|
||||
var elements = [];
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = arguments[i];
|
||||
if (typeof(element) == 'string') {
|
||||
element = document.getElementById(element);
|
||||
}
|
||||
if (arguments.length == 1) {
|
||||
return element;
|
||||
}
|
||||
elements.push(element);
|
||||
}
|
||||
return elements;
|
||||
},
|
||||
|
||||
/**
|
||||
* loadScript is a JSON data fetcher
|
||||
* @param {String} src URL to JSON file
|
||||
* @param {Function} callback Callback function
|
||||
*/
|
||||
loadScript: function(src, callback) {
|
||||
var script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = src;
|
||||
if (callback) {
|
||||
if(script.addEventListener){
|
||||
script.addEventListener('load', callback, true);
|
||||
}
|
||||
else if(script.attachEvent){
|
||||
var done = false;
|
||||
script.attachEvent("onreadystatechange",function(){
|
||||
if ( !done && document.readyState === "complete" ) {
|
||||
done = true;
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var h = document.getElementsByTagName('head')[0];
|
||||
h.appendChild( script );
|
||||
return;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Object} point
|
||||
* @param {Object} level
|
||||
*/
|
||||
convertLatLonXY_Yahoo: function(point, level) { //Mercator
|
||||
var size = 1 << (26 - level);
|
||||
var pixel_per_degree = size / 360.0;
|
||||
var pixel_per_radian = size / (2 * Math.PI);
|
||||
var origin = new YCoordPoint(size / 2 , size / 2);
|
||||
var answer = new YCoordPoint();
|
||||
answer.x = Math.floor(origin.x + point.lon * pixel_per_degree);
|
||||
var sin = Math.sin(point.lat * Math.PI / 180.0);
|
||||
answer.y = Math.floor(origin.y + 0.5 * Math.log((1 + sin) / (1 - sin)) * -pixel_per_radian);
|
||||
return answer;
|
||||
},
|
||||
|
||||
/**
|
||||
* Load a stylesheet from a remote file.
|
||||
* @param {String} href URL to the CSS file
|
||||
*/
|
||||
loadStyle: function(href) {
|
||||
var link = document.createElement('link');
|
||||
link.type = 'text/css';
|
||||
link.rel = 'stylesheet';
|
||||
link.href = href;
|
||||
document.getElementsByTagName('head')[0].appendChild(link);
|
||||
return;
|
||||
},
|
||||
|
||||
/**
|
||||
* getStyle provides cross-browser access to css
|
||||
* @param {Object} el HTML Element
|
||||
* @param {String} prop Style property name
|
||||
*/
|
||||
getStyle: function(el, prop) {
|
||||
var y;
|
||||
if (el.currentStyle) {
|
||||
y = el.currentStyle[prop];
|
||||
}
|
||||
else if (window.getComputedStyle) {
|
||||
y = window.getComputedStyle( el, '').getPropertyValue(prop);
|
||||
}
|
||||
return y;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert longitude to metres
|
||||
* http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM
|
||||
* "A degree of longitude at the equator is 111.2km... For other latitudes,
|
||||
* multiply by cos(lat)"
|
||||
* assumes the earth is a sphere but good enough for our purposes
|
||||
* @param {Float} lon
|
||||
* @param {Float} lat
|
||||
*/
|
||||
lonToMetres: function(lon, lat) {
|
||||
return lon * (111200 * Math.cos(lat * (Math.PI / 180)));
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert metres to longitude
|
||||
* @param {Object} m
|
||||
* @param {Object} lat
|
||||
*/
|
||||
metresToLon: function(m, lat) {
|
||||
return m / (111200 * Math.cos(lat * (Math.PI / 180)));
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert kilometres to miles
|
||||
* @param {Float} km
|
||||
* @returns {Float} miles
|
||||
*/
|
||||
KMToMiles: function(km) {
|
||||
return km / 1.609344;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert miles to kilometres
|
||||
* @param {Float} miles
|
||||
* @returns {Float} km
|
||||
*/
|
||||
milesToKM: function(miles) {
|
||||
return miles * 1.609344;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Object} number
|
||||
* @param {Object} base
|
||||
*/
|
||||
logN: function(number, base) {
|
||||
return Math.log(number) / Math.log(base);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns array of loaded provider apis
|
||||
* @returns {Array} providers
|
||||
*/
|
||||
getAvailableProviders : function () {
|
||||
var providers = [];
|
||||
for (var propertyName in apis){
|
||||
if (apis.hasOwnProperty(propertyName)) {
|
||||
providers.push(propertyName);
|
||||
}
|
||||
}
|
||||
return providers;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Class for converting between HTML and RGB integer color formats.
|
||||
* Accepts either a HTML color string argument or three integers for R, G and B.
|
||||
* @constructor
|
||||
*/
|
||||
mxn.util.Color = function() {
|
||||
if(arguments.length == 3) {
|
||||
this.red = arguments[0];
|
||||
this.green = arguments[1];
|
||||
this.blue = arguments[2];
|
||||
}
|
||||
else if(arguments.length == 1) {
|
||||
this.setHexColor(arguments[0]);
|
||||
}
|
||||
};
|
||||
|
||||
mxn.util.Color.prototype.reHex = /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
||||
|
||||
/**
|
||||
* Set the color from the supplied HTML hex string.
|
||||
* @param {String} strHexColor A HTML hex color string e.g. '#00FF88'.
|
||||
*/
|
||||
mxn.util.Color.prototype.setHexColor = function(strHexColor) {
|
||||
var match = strHexColor.match(this.reHex);
|
||||
if(match) {
|
||||
strHexColor = match[1];
|
||||
}
|
||||
else {
|
||||
throw 'Invalid HEX color format, expected #000, 000, #000000 or 000000';
|
||||
}
|
||||
if(strHexColor.length == 3) {
|
||||
strHexColor = strHexColor.replace(/\w/g, function(str){return str.concat(str);});
|
||||
}
|
||||
this.red = parseInt(strHexColor.substr(0,2), 16);
|
||||
this.green = parseInt(strHexColor.substr(2,2), 16);
|
||||
this.blue = parseInt(strHexColor.substr(4,2), 16);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the color value as an HTML hex string.
|
||||
* @returns {String} Format '00FF88' - note no preceding #.
|
||||
*/
|
||||
mxn.util.Color.prototype.getHexColor = function() {
|
||||
var vals = [this.red.toString(16), this.green.toString(16), this.blue.toString(16)];
|
||||
for(var i = 0; i < vals.length; i++) {
|
||||
vals[i] = (vals[i].length == 1) ? '0' + vals[i] : vals[i];
|
||||
vals[i] = vals[i].toUpperCase();
|
||||
}
|
||||
return vals.join('');
|
||||
};
|
||||
|
||||
})();
|
402
public/plugins/Mapstraction/js/mxn.microsoft.core.js
Normal file
@@ -0,0 +1,402 @@
|
||||
mxn.register('microsoft', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
init: function(element, api) {
|
||||
var me = this;
|
||||
if (VEMap){
|
||||
this.maps[api] = new VEMap(element.id);
|
||||
|
||||
|
||||
|
||||
this.maps[api].AttachEvent('onclick', function(event){
|
||||
me.clickHandler();
|
||||
var x = event.mapX;
|
||||
var y = event.mapY;
|
||||
var pixel = new VEPixel(x,y);
|
||||
me.click.fire({'location': new mxn.LatLonPoint(pixel.Latitude, pixel.Longitude)});
|
||||
|
||||
|
||||
});
|
||||
this.maps[api].AttachEvent('onendzoom', function(event){
|
||||
me.moveendHandler(me);
|
||||
me.changeZoom.fire();
|
||||
|
||||
|
||||
});
|
||||
this.maps[api].AttachEvent('onendpan', function(event){
|
||||
me.moveendHandler(me);
|
||||
me.endPan.fire();
|
||||
|
||||
|
||||
});
|
||||
this.maps[api].AttachEvent('onchangeview', function(event){
|
||||
me.endPan.fire();
|
||||
|
||||
|
||||
});
|
||||
this.maps[api].LoadMap();
|
||||
document.getElementById("MSVE_obliqueNotification").style.visibility = "hidden";
|
||||
|
||||
//removes the bird's eye pop-up
|
||||
this.loaded[api] = true;
|
||||
me.load.fire();
|
||||
}
|
||||
else{
|
||||
alert(api + ' map script not imported')
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
applyOptions: function(){
|
||||
var map = this.maps[this.api];
|
||||
if(this.options.enableScrollWheelZoom){
|
||||
map.enableContinuousZoom();
|
||||
map.enableScrollWheelZoom();
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
this.maps[this.api].Resize(width, height);
|
||||
},
|
||||
|
||||
addControls: function( args ) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
if (args.pan) {
|
||||
map.SetDashboardSize(VEDashboardSize.Normal);
|
||||
}
|
||||
else {
|
||||
map.SetDashboardSize(VEDashboardSize.Tiny)
|
||||
}
|
||||
|
||||
if (args.zoom == 'large') {
|
||||
map.SetDashboardSize(VEDashboardSize.Small)
|
||||
}
|
||||
else if ( args.zoom == 'small' ) {
|
||||
map.SetDashboardSize(VEDashboardSize.Tiny)
|
||||
}
|
||||
else {
|
||||
map.HideDashboard();
|
||||
map.HideScalebar();
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
addSmallControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
map.SetDashboardSize(VEDashboardSize.Tiny);
|
||||
|
||||
},
|
||||
|
||||
addLargeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
map.SetDashboardSize(VEDashboardSize.Normal);
|
||||
this.addControlsArgs.pan=true;
|
||||
this.addControlsArgs.zoom = 'large';
|
||||
},
|
||||
|
||||
addMapTypeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
map.addTypeControl();
|
||||
|
||||
},
|
||||
|
||||
dragging: function(on) {
|
||||
var map = this.maps[this.api];
|
||||
if(on){
|
||||
map.enableDragMap();
|
||||
}
|
||||
else{
|
||||
map.disableDragMap();
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
var vzoom = zoom;
|
||||
map.SetCenterAndZoom(new VELatLong(point.lat,point.lon), vzoom)
|
||||
|
||||
},
|
||||
|
||||
addMarker: function(marker, old) {
|
||||
var map = this.maps[this.api];
|
||||
marker.pinID = "mspin-"+new Date().getTime()+'-'+(Math.floor(Math.random()*Math.pow(2,16)));
|
||||
var pin = marker.toProprietary(this.api);
|
||||
map.AddShape(pin);
|
||||
//give onclick event
|
||||
//give on double click event
|
||||
//give on close window
|
||||
//return the marker
|
||||
|
||||
|
||||
return pin;
|
||||
},
|
||||
|
||||
removeMarker: function(marker) {
|
||||
var map = this.maps[this.api];
|
||||
var id = marker.proprietary_marker.GetID();
|
||||
var microsoftShape = map.GetShapeByID(id);
|
||||
map.DeleteShape(microsoftShape);
|
||||
},
|
||||
|
||||
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);
|
||||
pl.HideIcon();//hide the icon VE automatically displays
|
||||
map.AddShape(pl);
|
||||
|
||||
return pl;
|
||||
},
|
||||
|
||||
removePolyline: function(polyline) {
|
||||
var map = this.maps[this.api];
|
||||
var id = polyline.proprietary_polyline.GetID();
|
||||
var microsoftShape = map.GetShapeByID(id);
|
||||
map.DeleteShape(microsoftShape);
|
||||
},
|
||||
|
||||
getCenter: function() {
|
||||
var map = this.maps[this.api];
|
||||
var LL = map.GetCenter();
|
||||
var point = new mxn.LatLonPoint(LL.Latitude, LL.Longitude);
|
||||
return point;
|
||||
|
||||
},
|
||||
|
||||
setCenter: function(point, options) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
map.SetCenter(new VELatLong(point.lat, point.lon));
|
||||
|
||||
|
||||
},
|
||||
|
||||
setZoom: function(zoom) {
|
||||
var map = this.maps[this.api];
|
||||
map.SetZoomLevel(zoom);
|
||||
|
||||
|
||||
},
|
||||
|
||||
getZoom: function() {
|
||||
var map = this.maps[this.api];
|
||||
var zoom = map.GetZoomLevel();
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
getZoomLevelForBoundingBox: function( bbox ) {
|
||||
var map = this.maps[this.api];
|
||||
// NE and SW points from the bounding box.
|
||||
var ne = bbox.getNorthEast();
|
||||
var sw = bbox.getSouthWest();
|
||||
var zoom;
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
setMapType: function(type) {
|
||||
var map = this.maps[this.api];
|
||||
switch(type) {
|
||||
case mxn.Mapstraction.ROAD:
|
||||
map.SetMapStyle(VEMapStyle.Road);
|
||||
break;
|
||||
case mxn.Mapstraction.SATELLITE:
|
||||
map.SetMapStyle(VEMapStyle.Aerial);
|
||||
break;
|
||||
case mxn.Mapstraction.HYBRID:
|
||||
map.SetMapStyle(VEMapStyle.Hybrid);
|
||||
break;
|
||||
default:
|
||||
map.SetMapStyle(VEMapStyle.Road);
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
var map = this.maps[this.api];
|
||||
var mode = map.GetMapStyle();
|
||||
switch(mode){
|
||||
case VEMapStyle.Aerial:
|
||||
return mxn.Mapstraction.SATELLITE;
|
||||
case VEMapStyle.Road:
|
||||
return mxn.Mapstraction.ROAD;
|
||||
case VEMapStyle.Hybrid:
|
||||
return mxn.Mapstraction.HYBRID;
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getBounds: function () {
|
||||
var map = this.maps[this.api];
|
||||
view = map.GetMapView();
|
||||
var topleft = view.TopLeftLatLong;
|
||||
var bottomright = view.BottomRightLatLong;
|
||||
|
||||
return new mxn.BoundingBox(bottomright.Latitude,topleft.Longitude,topleft.Latitude, bottomright.Longitude );
|
||||
},
|
||||
|
||||
setBounds: function(bounds){
|
||||
var map = this.maps[this.api];
|
||||
var sw = bounds.getSouthWest();
|
||||
var ne = bounds.getNorthEast();
|
||||
|
||||
var rec = new VELatLongRectangle(new VELatLong(ne.lat, ne.lon), new VELatLong(sw.lat, sw.lon));
|
||||
map.SetMapView(rec);
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
// TODO: Add provider code
|
||||
},
|
||||
|
||||
setImagePosition: function(id, oContext) {
|
||||
var map = this.maps[this.api];
|
||||
var topLeftPoint; var bottomRightPoint;
|
||||
|
||||
// TODO: Add provider code
|
||||
|
||||
// oContext.pixels.top = ...;
|
||||
// oContext.pixels.left = ...;
|
||||
// oContext.pixels.bottom = ...;
|
||||
// oContext.pixels.right = ...;
|
||||
},
|
||||
|
||||
addOverlay: function(url, autoCenterAndZoom) {
|
||||
var map = this.maps[this.api];
|
||||
var layer = new VEShapeLayer();
|
||||
var mlayerspec = new VEShapeSourceSpecification(VEDataType.GeoRSS, url, layer);
|
||||
map.AddShapeLayer(layer);
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
toggleTileLayer: function(tile_url) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
getPixelRatio: function() {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
mousePosition: function(element) {
|
||||
var locDisp = document.getElementById(element);
|
||||
if (locDisp != null) {
|
||||
var map = this.maps[this.api];
|
||||
map.AttachEvent("onmousemove", function(veEvent){
|
||||
var latlon = map.PixelToLatLong(new VEPixel(veEvent.mapX, veEvent.mapY));
|
||||
var loc = latlon.Latitude.toFixed(4) + " / " + latlon.Longitude.toFixed(4);
|
||||
locDisp.innerHTML = loc;
|
||||
|
||||
});
|
||||
locDisp.innerHTML = "0.0000 / 0.0000";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
LatLonPoint: {
|
||||
|
||||
toProprietary: function() {
|
||||
return new VELatLong(this.lat, this.lon);
|
||||
},
|
||||
|
||||
fromProprietary: function(mpoint) {
|
||||
this.lat =mpoint.Latitude;
|
||||
this.lon =mpoint.Longitude;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Marker: {
|
||||
|
||||
toProprietary: function() {
|
||||
var mmarker = new VEShape(VEShapeType.Pushpin, this.location.toProprietary('microsoft'));
|
||||
|
||||
|
||||
return mmarker;
|
||||
|
||||
},
|
||||
|
||||
openBubble: function() {
|
||||
var mmarker = this.proprietary_marker;
|
||||
map.ClearInfoBoxStyles();
|
||||
mmarker.SetTitle(this.infoBubble);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.proprietary_marker.hide();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.proprietary_marker_unhide();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
throw 'Not implemented';
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Polyline: {
|
||||
|
||||
toProprietary: function() {
|
||||
var mpoints =[];
|
||||
for(var i =0, length = this.points.length; i < length; i++)
|
||||
{
|
||||
mpoints.push(this.points[i].toProprietary('microsoft'));
|
||||
}
|
||||
var mpolyline = new VEShape(VEShapeType.Polyline, mpoints);
|
||||
if(this.color){
|
||||
var color = new mxn.util.Color(this.color);
|
||||
var opacity = (typeof(this.opacity) == 'undefined' || this.opacity === null) ? 1.0 : this.opacity;
|
||||
var vecolor = new VEColor(color.red, color.green, color.blue, opacity);
|
||||
mpolyline.SetLineColor(vecolor);
|
||||
}
|
||||
// TODO ability to change line width
|
||||
return mpolyline;
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.proprietary_polyline.Show();
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.proprietary_polyline.Hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
485
public/plugins/Mapstraction/js/mxn.openlayers.core.js
Normal file
@@ -0,0 +1,485 @@
|
||||
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)';
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
var map = this.maps[this.api];
|
||||
// TODO: implement actual layer support
|
||||
return mxn.Mapstraction.ROAD;
|
||||
},
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
391
public/plugins/Mapstraction/js/mxn.yahoo.core.js
Normal file
@@ -0,0 +1,391 @@
|
||||
mxn.register('yahoo', {
|
||||
|
||||
Mapstraction: {
|
||||
|
||||
init: function(element,api) {
|
||||
var me = this;
|
||||
if (YMap) {
|
||||
this.maps[api] = new YMap(element);
|
||||
|
||||
YEvent.Capture(this.maps[api], EventsList.MouseClick, function(event,location) {
|
||||
me.clickHandler(location.Lat, location.Lon, location, me);
|
||||
me.click.fire({'location': new mxn.LatLonPoint(location.Lat, location.Lon)});
|
||||
});
|
||||
YEvent.Capture(this.maps[api], EventsList.changeZoom, function() {
|
||||
me.moveendHandler(me);
|
||||
me.changeZoom.fire();
|
||||
});
|
||||
YEvent.Capture(this.maps[api], EventsList.endPan, function() {
|
||||
me.moveendHandler(me);
|
||||
me.endPan.fire();
|
||||
});
|
||||
YEvent.Capture(this.maps[api], EventsList.endAutoPan, function() {
|
||||
me.endPan.fire();
|
||||
});
|
||||
|
||||
this.loaded[api] = true;
|
||||
me.load.fire();
|
||||
}
|
||||
else {
|
||||
alert(api + ' map script not imported');
|
||||
}
|
||||
},
|
||||
|
||||
applyOptions: function(){
|
||||
|
||||
/*
|
||||
if (this.options.enableDragging) {
|
||||
map.enableDragMap();
|
||||
} else {
|
||||
map.disableDragMap();
|
||||
}*/
|
||||
|
||||
},
|
||||
|
||||
resizeTo: function(width, height){
|
||||
this.maps[this.api].resizeTo(new YSize(width,height));
|
||||
},
|
||||
|
||||
addControls: function( args ) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
if (args.pan) {
|
||||
map.addPanControl();
|
||||
}
|
||||
else {
|
||||
// Yahoo doesn't check the pan control is there before trying to remove it
|
||||
// so throws an exception :(
|
||||
map.addPanControl();
|
||||
map.removePanControl();
|
||||
}
|
||||
|
||||
if (args.zoom == 'large') {
|
||||
map.addZoomLong();
|
||||
}
|
||||
else if ( args.zoom == 'small' ) {
|
||||
map.addZoomShort();
|
||||
}
|
||||
else {
|
||||
map.removeZoomScale();
|
||||
}
|
||||
},
|
||||
|
||||
addSmallControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
map.addPanControl();
|
||||
map.addZoomShort();
|
||||
this.addControlsArgs.pan = true;
|
||||
this.addControlsArgs.zoom = 'small';
|
||||
},
|
||||
|
||||
addLargeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
map.addPanControl();
|
||||
map.addZoomLong();
|
||||
this.addControlsArgs.pan = true; // keep the controls in case of swap
|
||||
this.addControlsArgs.zoom = 'large';
|
||||
},
|
||||
|
||||
addMapTypeControls: function() {
|
||||
var map = this.maps[this.api];
|
||||
map.addTypeControl();
|
||||
},
|
||||
|
||||
dragging: function(on) {
|
||||
var map = this.maps[this.api];
|
||||
if (on) {
|
||||
map.enableDragMap();
|
||||
} else {
|
||||
map.disableDragMap();
|
||||
}
|
||||
},
|
||||
|
||||
setCenterAndZoom: function(point, zoom) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
|
||||
var yzoom = 18 - zoom; // maybe?
|
||||
map.drawZoomAndCenter(pt,yzoom);
|
||||
},
|
||||
|
||||
addMarker: function(marker, old) {
|
||||
var map = this.maps[this.api];
|
||||
var pin = marker.toProprietary(this.api);
|
||||
map.addOverlay(pin);
|
||||
YEvent.Capture(pin, EventsList.MouseClick, function() {
|
||||
marker.click.fire();
|
||||
});
|
||||
YEvent.Capture(pin, EventsList.openSmartWindow, function() {
|
||||
marker.openInfoBubble.fire();
|
||||
});
|
||||
YEvent.Capture(pin, EventsList.closeSmartWindow, function() {
|
||||
marker.closeInfoBubble.fire();
|
||||
});
|
||||
return pin;
|
||||
},
|
||||
|
||||
removeMarker: function(marker) {
|
||||
var map = this.maps[this.api];
|
||||
map.removeOverlay(marker.proprietary_marker);
|
||||
},
|
||||
|
||||
removeAllMarkers: function() {
|
||||
var map = this.maps[this.api];
|
||||
map.removeMarkersAll();
|
||||
},
|
||||
|
||||
declutterMarkers: function(opts) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
addPolyline: function(polyline, old) {
|
||||
var map = this.maps[this.api];
|
||||
var pl = polyline.toProprietary(this.api);
|
||||
map.addOverlay(pl);
|
||||
return pl;
|
||||
},
|
||||
|
||||
removePolyline: function(polyline) {
|
||||
var map = this.maps[this.api];
|
||||
map.removeOverlay(polyline.proprietary_polyline);
|
||||
},
|
||||
|
||||
getCenter: function() {
|
||||
var map = this.maps[this.api];
|
||||
var pt = map.getCenterLatLon();
|
||||
var point = new mxn.LatLonPoint(pt.Lat, pt.Lon);
|
||||
return point;
|
||||
},
|
||||
|
||||
setCenter: function(point, options) {
|
||||
var map = this.maps[this.api];
|
||||
var pt = point.toProprietary(this.api);
|
||||
map.panToLatLon(pt);
|
||||
},
|
||||
|
||||
setZoom: function(zoom) {
|
||||
var map = this.maps[this.api];
|
||||
var yzoom = 18 - zoom; // maybe?
|
||||
map.setZoomLevel(yzoom);
|
||||
},
|
||||
|
||||
getZoom: function() {
|
||||
var map = this.maps[this.api];
|
||||
return 18 - map.getZoomLevel();
|
||||
},
|
||||
|
||||
getZoomLevelForBoundingBox: function( bbox ) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
setMapType: function(type) {
|
||||
var map = this.maps[this.api];
|
||||
|
||||
switch(type) {
|
||||
case mxn.Mapstraction.ROAD:
|
||||
map.setMapType(YAHOO_MAP_REG);
|
||||
break;
|
||||
case mxn.Mapstraction.SATELLITE:
|
||||
map.setMapType(YAHOO_MAP_SAT);
|
||||
break;
|
||||
case mxn.Mapstraction.HYBRID:
|
||||
map.setMapType(YAHOO_MAP_HYB);
|
||||
break;
|
||||
default:
|
||||
map.setMapType(YAHOO_MAP_REG);
|
||||
}
|
||||
},
|
||||
|
||||
getMapType: function() {
|
||||
var map = this.maps[this.api];
|
||||
var type = map.getCurrentMapType();
|
||||
switch(type) {
|
||||
case YAHOO_MAP_REG:
|
||||
return mxn.Mapstraction.ROAD;
|
||||
case YAHOO_MAP_SAT:
|
||||
return mxn.Mapstraction.SATELLITE;
|
||||
case YAHOO_MAP_HYB:
|
||||
return mxn.Mapstraction.HYBRID;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
getBounds: function () {
|
||||
var map = this.maps[this.api];
|
||||
var ybox = map.getBoundsLatLon();
|
||||
return new mxn.BoundingBox(ybox.LatMin, ybox.LonMin, ybox.LatMax, ybox.LonMax);
|
||||
},
|
||||
|
||||
setBounds: function(bounds){
|
||||
var map = this.maps[this.api];
|
||||
var sw = bounds.getSouthWest();
|
||||
var ne = bounds.getNorthEast();
|
||||
|
||||
if(sw.lon > ne.lon) {
|
||||
sw.lon -= 360;
|
||||
}
|
||||
var center = new YGeoPoint((sw.lat + ne.lat)/2, (ne.lon + sw.lon)/2);
|
||||
|
||||
var container = map.getContainerSize();
|
||||
for(var zoom = 1 ; zoom <= 17 ; zoom++){
|
||||
var sw_pix = mxn.util.convertLatLonXY_Yahoo(sw,zoom);
|
||||
var ne_pix = mxn.util.convertLatLonXY_Yahoo(ne,zoom);
|
||||
if(sw_pix.x > ne_pix.x) {
|
||||
sw_pix.x -= (1 << (26 - zoom)); //earth circumference in pixel
|
||||
}
|
||||
if(Math.abs(ne_pix.x - sw_pix.x) <= container.width
|
||||
&& Math.abs(ne_pix.y - sw_pix.y) <= container.height){
|
||||
map.drawZoomAndCenter(center, zoom); //Call drawZoomAndCenter here: OK if called multiple times anyway
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
setImagePosition: function(id) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
addOverlay: function(url, autoCenterAndZoom) {
|
||||
var map = this.maps[this.api];
|
||||
map.addOverlay(new YGeoRSS(url));
|
||||
},
|
||||
|
||||
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
toggleTileLayer: function(tile_url) {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
getPixelRatio: function() {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
mousePosition: function(element) {
|
||||
throw 'Not implemented';
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
LatLonPoint: {
|
||||
|
||||
toProprietary: function() {
|
||||
return new YGeoPoint(this.lat,this.lon);
|
||||
},
|
||||
|
||||
fromProprietary: function(yahooPoint) {
|
||||
this.lat = yahooPoint.Lat;
|
||||
this.lon = yahooPoint.Lon;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Marker: {
|
||||
|
||||
toProprietary: function() {
|
||||
var ymarker, size;
|
||||
var infoBubble, event_action, infoDiv, div;
|
||||
|
||||
if(this.iconSize) {
|
||||
size = new YSize(this.iconSize[0], this.iconSize[1]);
|
||||
}
|
||||
if(this.iconUrl) {
|
||||
if(this.iconSize){
|
||||
ymarker = new YMarker(this.location.toProprietary('yahoo'), new YImage(this.iconUrl, size));
|
||||
}
|
||||
else {
|
||||
ymarker = new YMarker(this.location.toProprietary('yahoo'), new YImage(this.iconUrl));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(this.iconSize) {
|
||||
ymarker = new YMarker(this.location.toProprietary('yahoo'), null, size);
|
||||
}
|
||||
else {
|
||||
ymarker = new YMarker(this.location.toProprietary('yahoo'));
|
||||
}
|
||||
}
|
||||
|
||||
if(this.labelText) {
|
||||
ymarker.addLabel(this.labelText);
|
||||
}
|
||||
|
||||
if(this.infoBubble) {
|
||||
infoBubble = this.infoBubble;
|
||||
if(this.hover) {
|
||||
event_action = EventsList.MouseOver;
|
||||
}
|
||||
else {
|
||||
event_action = EventsList.MouseClick;
|
||||
}
|
||||
YEvent.Capture(ymarker, event_action, function() {
|
||||
ymarker.openSmartWindow(infoBubble);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if(this.infoDiv) {
|
||||
infoDiv = this.infoDiv;
|
||||
div = this.div;
|
||||
if(this.hover) {
|
||||
event_action = EventsList.MouseOver;
|
||||
}
|
||||
else {
|
||||
event_action = EventsList.MouseClick;
|
||||
}
|
||||
YEvent.Capture(ymarker, event_action, function() {
|
||||
document.getElementById(div).innerHTML = infoDiv;
|
||||
});
|
||||
}
|
||||
|
||||
return ymarker;
|
||||
},
|
||||
|
||||
openBubble: function() {
|
||||
var ypin = this.proprietary_marker;
|
||||
ypin.openSmartWindow(this.infoBubble);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.proprietary_marker.hide();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.proprietary_marker.unhide();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
throw 'Not implemented';
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Polyline: {
|
||||
|
||||
toProprietary: function() {
|
||||
var ypolyline;
|
||||
var ypoints = [];
|
||||
for (var i = 0, length = this.points.length ; i< length; i++){
|
||||
ypoints.push(this.points[i].toProprietary('yahoo'));
|
||||
}
|
||||
ypolyline = new YPolyline(ypoints,this.color,this.width,this.opacity);
|
||||
return ypolyline;
|
||||
},
|
||||
|
||||
show: function() {
|
||||
throw 'Not implemented';
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
throw 'Not implemented';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
108
public/plugins/Mapstraction/usermap.js
Normal file
@@ -0,0 +1,108 @@
|
||||
function scrapeNotices(user)
|
||||
{
|
||||
var notices = [];
|
||||
$(".notice").each(function(){
|
||||
var notice = getNoticeFromElement($(this));
|
||||
if (user) {
|
||||
notice['user'] = user;
|
||||
} else {
|
||||
notice['user'] = getUserFromElement($(this));
|
||||
}
|
||||
if(notice['geo'])
|
||||
notices.push(notice);
|
||||
});
|
||||
|
||||
return notices;
|
||||
}
|
||||
|
||||
function scrapeUser()
|
||||
{
|
||||
var avatarURL = $(".entity_profile .entity_depiction img.avatar").attr('src');
|
||||
var profileURL = $(".entity_profile .entity_nickname .url").attr('href');
|
||||
var nickname = $(".entity_profile .entity_nickname .nickname").text();
|
||||
|
||||
return {
|
||||
'profile_image_url': avatarURL,
|
||||
'profile_url': profileURL,
|
||||
'screen_name': nickname
|
||||
};
|
||||
}
|
||||
|
||||
function getNoticeFromElement(noticeElement)
|
||||
{
|
||||
var notice = {};
|
||||
|
||||
if(noticeElement.find(".geo").length) {
|
||||
var latlon = noticeElement.find(".geo").attr('title').split(";");
|
||||
notice['geo']={'coordinates': [
|
||||
parseFloat(latlon[0]),
|
||||
parseFloat(latlon[1])] };
|
||||
}
|
||||
|
||||
notice['html'] = noticeElement.find(".e-content").html();
|
||||
notice['url'] = noticeElement.find("a.timestamp").attr('href');
|
||||
notice['created_at'] = noticeElement.find("abbr.published").text();
|
||||
|
||||
return notice;
|
||||
}
|
||||
|
||||
function getUserFromElement(noticeElement)
|
||||
{
|
||||
var avatarURL = noticeElement.find("img.avatar").attr('src');
|
||||
var profileURL = noticeElement.find(".author a.url").attr('href');
|
||||
var nickname = noticeElement.find(".author .nickname").text();
|
||||
|
||||
return {
|
||||
'profile_image_url': avatarURL,
|
||||
'profile_url': profileURL,
|
||||
'screen_name': nickname
|
||||
};
|
||||
}
|
||||
|
||||
function showMapstraction(element, notices) {
|
||||
if(element instanceof jQuery) element = element[0];
|
||||
if(! $.isArray(notices)) notices = [notices];
|
||||
var mapstraction = new mxn.Mapstraction(element, _provider);
|
||||
|
||||
var minLat = 181.0;
|
||||
var maxLat = -181.0;
|
||||
var minLon = 181.0;
|
||||
var maxLon = -181.0;
|
||||
|
||||
for (var i in notices)
|
||||
{
|
||||
var n = notices[i];
|
||||
|
||||
var lat = n['geo']['coordinates'][0];
|
||||
var lon = n['geo']['coordinates'][1];
|
||||
|
||||
if (lat < minLat) {
|
||||
minLat = lat;
|
||||
}
|
||||
|
||||
if (lat > maxLat) {
|
||||
maxLat = lat;
|
||||
}
|
||||
|
||||
if (lon < minLon) {
|
||||
minLon = lon;
|
||||
}
|
||||
|
||||
if (lon > maxLon) {
|
||||
maxLon = lon;
|
||||
}
|
||||
|
||||
pt = new mxn.LatLonPoint(lat, lon);
|
||||
mkr = new mxn.Marker(pt);
|
||||
|
||||
mkr.setIcon(n['user']['profile_image_url'], [24, 24]);
|
||||
mkr.setInfoBubble('<a href="'+ n['user']['profile_url'] + '">' + n['user']['screen_name'] + '</a>' + ' ' + n['html'] +
|
||||
'<br/><a href="'+ n['url'] + '">'+ n['created_at'] + '</a>');
|
||||
|
||||
mapstraction.addMarker(mkr);
|
||||
}
|
||||
|
||||
bounds = new mxn.BoundingBox(minLat, minLon, maxLat, maxLon);
|
||||
|
||||
mapstraction.setBounds(bounds);
|
||||
}
|