codesite-noreply at google.com
2009-Dec-13 19:39 UTC
[Mapstraction] [mapstraction] r65 committed - Use the GeoCommons addOverlay method
Revision: 65
Author: ajturner
Date: Sun Dec 13 11:10:04 2009
Log: Use the GeoCommons addOverlay method
http://code.google.com/p/mapstraction/source/detail?r=65
Modified:
/trunk/source/mxn.geocommons.core.js
/trunk/tests/index.htm
======================================--- /trunk/source/mxn.geocommons.core.js
Sun Dec 13 11:10:00 2009
+++ /trunk/source/mxn.geocommons.core.js Sun Dec 13 11:10:04 2009
@@ -31,21 +31,16 @@
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'';
- F1.Maker.maker_host=''http://localhost:4002'';
- F1.Maker.finder_host=''http://localhost:4001'';
- F1.Maker.core_host=''http://localhost:4000'';
-
this.loaded[this.api] = false; // Loading will take a little
bit.
-
- url = "1";
- new F1.Maker.Map({map_id:url, dom_id:this.element.id,
- flashvars: {"map_id":url},
- onload: function(map){
- me.maps[me.api] = map;
- // f1_swfobject21.getObjectById(this.element.id);
+ F1.Maker.core_host = f1_core_host;
+ F1.Maker.finder_host = f1_finder_host;
+ F1.Maker.maker_host = f1_maker_host;
+
+ new F1.Maker.Map({dom_id:this.element.id,
+ flashvars: {},
+ onload: function(map){
+
+ me.maps[me.api] = map.swf; // Get the actual Flash
object
me.loaded[me.api] = true;
for (var i = 0; i < me.onload[me.api].length; i++) {
me.onload[me.api][i]();
@@ -77,15 +72,21 @@
addSmallControls: function() {
var map = this.maps[this.api];
- showControl("Zoom", args.zoom);
- showControl("Legend", args.legend, "open");
+ this.addControls({
+ zoom: ''small'',
+ legend: "open"
+ });
+ // 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");
+ this.addControls({
+ zoom: ''large'',
+ layers: true,
+ legend: "open"
+ });
},
addMapTypeControls: function() {
@@ -189,13 +190,23 @@
// TODO: Add provider code
},
-
+
+ // URL in this case is either a Maker map ID or the full URL to
the Maker Map
addOverlay: function(url, autoCenterAndZoom) {
var map = this.maps[this.api];
- var me = this;
- new F1.Maker.Map({map_id:url, dom_id:this.element.id,
- onload: function(map){ me.maps[me.api] = map }});
- // setTimeout(function() { me.maps[me.api] =
swfobject.getObjectById(FlashMap.dom_id);}, 500);
+ var match;
+
+ if(typeof(url) === "number") {
+ map.loadMap(url);
+ return;
+ }
+ // Try if we''ve been given either a string of the ID or a
URL
+ match = url.match(/^(\d+)$/)
+ if(match != null){
+ match = url.match(/^.*?maps\/(\d+)(\?\(\[?(.*?)\]?\))?$/);
+ }
+
+ map.loadMap(match[1]);
},
addTileLayer: function(tile_url, opacity, copyright_text,
min_zoom, max_zoom) {
@@ -220,13 +231,52 @@
var map = this.maps[this.api];
// TODO: Add provider code
- }
+ },
+ addMarker: function(marker, old) {
+ var map = this.maps[this.api];
+ var pin = marker.toProprietary(this.api);
+ // TODO: Add provider code
+ // map.addOverlay(pin);
+ return pin;
+ },
+
+ removeMarker: function(marker) {
+ var map = this.maps[this.api];
+ // TODO: Add provider code
+
+ },
+
+ removeAllMarkers: function() {
+ // Done in mxn.core.js
+ },
+
+ declutterMarkers: function(opts) {
+ var map = this.maps[this.api];
+
+ // TODO: Add provider code
+ },
+
+ addPolyline: function(polyline, old) {
+ var map = this.maps[this.api];
+ var pl = polyline.toProprietary(this.api);
+ // TODO: Add provider code
+ // map.addOverlay(pl);
+ return pl;
+ },
+
+ removePolyline: function(polyline) {
+ var map = this.maps[this.api];
+ // TODO: Add provider code
+ }
+
+
},
LatLonPoint: {
toProprietary: function() {
// TODO: Add provider code
+ return {};
},
fromProprietary: function(googlePoint) {
@@ -239,6 +289,7 @@
toProprietary: function() {
// TODO: Add provider code
+ return {};
},
openBubble: function() {
@@ -262,6 +313,7 @@
Polyline: {
toProprietary: function() {
+ return {};
// TODO: Add provider code
},
======================================--- /trunk/tests/index.htm Sun Dec 13
11:10:00 2009
+++ /trunk/tests/index.htm Sun Dec 13 11:10:04 2009
@@ -6,15 +6,13 @@
<script type="text/javascript"
src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAY70wuSo0zF3ZtJVp5bDm1BS1Y2ErAqCHV5rDhHSzgjy23KqwdRRaoSBuZk72oDzzAYxVBjtsLqSmTw"></script>
- <!-- <script type="text/javascript"
src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=5wTxDW_V34GQjK.7glLG6OnJSRxCvfLj7ktMsuOoR42Gkm16vDVEjjw6FGWJ1Gky"></script>
- <script charset="UTF-8" type="text/javascript"
src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>
+ <script type="text/javascript"
src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=5wTxDW_V34GQjK.7glLG6OnJSRxCvfLj7ktMsuOoR42Gkm16vDVEjjw6FGWJ1Gky"></script>
<script
src="http://openlayers.org/api/OpenLayers.js"></script>
- <script
src="../source/mxn.js?(google,yahoo,microsoft,openlayers)"
type="text/javascript"></script> -->
- <script charset="UTF-8" type="text/javascript"
src="http://localhost:4002/javascripts/embed.js"></script>
+ <script charset="UTF-8" type="text/javascript"
src="http://river.dev.fortiusone.local/api.js"></script>
+ <script
src="../source/mxn.js?(google,yahoo,openlayers,geocommons)"
type="text/javascript"></script>
<!--<script src="domReady.js"
type="text/javascript"></script>-->
- <script src="../source/mxn.js?(google, geocommons)"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
@@ -162,12 +160,6 @@
action: function(){
m.swap(''map'', ''yahoo'');
}
- },
- {
- desc: ''Swap API (microsoft)'',
- action: function(){
- m.swap(''map'',
''microsoft'');
- }
},
{
desc: ''Swap API (openlayers)'',
@@ -236,7 +228,7 @@
</style>
</head>
<body>
- <div style="height: 400px; width: 800px; margin: 20px;">
+ <div style="height: 400px; width: 1000px; margin: 20px;">
<div id="map" style="position: relative; width: 500px;
height:
300px;"></div>
<div style="margin-top: 20px;">
Reasonably Related Threads
- [mapstraction commit] r12 - Implemented most Cloudmade functions. Still requires image, tile and KML/GeoRSS overlays
- AddOverlay for GeoRss Feeds, GeoRSS support
- Implementation of openBubble for openlayers
- r30 committed - jslint now passing for google and googlev3
- r54 committed - ...
