Created
December 2, 2009 22:09
-
-
Save whitmo/247651 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function coordToLonlat(coords, from, to, transform){ | |
| // transform is the default, change to make more reusable | |
| if(from == null){ | |
| to = OpenLayers.Projection("EPSG:900913"); | |
| from = OpenLayers.Projection("EPSG:4326"); | |
| } | |
| var lonlat = new OpenLayers.LonLat(coords.longitude, coords.latitude); | |
| console.log('here!!'); | |
| lonlat.transform(from, to); | |
| return lonlat; | |
| } | |
| var map, vectors, tools; | |
| function map_init(){ | |
| var cw = Titanium.UI.currentWindow; | |
| map = new OpenLayers.Map('map', { | |
| controls: [ | |
| new IOL.Control.Navigation() | |
| ], | |
| maxResolution: 156543.03390625, | |
| maxExtent: new OpenLayers.Bounds( | |
| -2.003750834E7,-2.003750834E7, | |
| 2.003750834E7,2.003750834E7 | |
| ), | |
| projection: "EPSG:900913", | |
| numZoomLevels: 7 | |
| }); | |
| cw.olmap = map; | |
| var wms = new OpenLayers.Layer.WMS( | |
| "Base Layer", "http://demo.opengeo.org/geoserver_openstreetmap/gwc/service/wms", | |
| {layers: 'openstreetmap', | |
| format: 'image/png' | |
| } | |
| ); | |
| map.addLayers([wms]); | |
| console.log('map created'); | |
| var position = Titanium.Geolocation.getCurrentPosition( | |
| function(pos) { | |
| var coords = pos.coords; | |
| var lonlat = coordToLonlat(pos.coords); | |
| map.setCenter(lonlat, 6); | |
| var lonlat = map.getCenter(); | |
| console.log('Your lonlat is:' + lonlat.lon + ' ' +lonlat.lat); | |
| }); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment