[OpenLayers-Commits] r11279 -
sandbox/camptocamp/mobile/openlayers/examples
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Feb 23 04:26:24 EST 2011
Author: fredj
Date: 2011-02-23 01:26:24 -0800 (Wed, 23 Feb 2011)
New Revision: 11279
Modified:
sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html
sandbox/camptocamp/mobile/openlayers/examples/mobile.js
Log:
use OpenLayers.Control.Geolocate in mobile examples
Modified: sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html 2011-02-23 09:26:17 UTC (rev 11278)
+++ sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html 2011-02-23 09:26:24 UTC (rev 11279)
@@ -85,7 +85,9 @@
$("#minus").click(function(){
map.zoomOut();
});
-
+ $("#locate").click(function(){
+ map.getControlsBy("id", "locate-control")[0].activate();
+ });
$('#query').keydown(function(e){
if (e.which === 13) { // enter
$.mobile.pageLoading();
@@ -128,7 +130,7 @@
<div data-role="footer">
<a href="#searchpage" data-icon="search" data-role="button">Search</a>
- <a href="" data-icon="locate" data-role="button">Locate</a>
+ <a href="#" id="locate" data-icon="locate" data-role="button">Locate</a>
<a href="#layerspage" data-icon="layers" data-role="button">Layers</a>
</div>
<div id="navigation" data-role="controlgroup" data-type="vertical">
Modified: sandbox/camptocamp/mobile/openlayers/examples/mobile.js
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/mobile.js 2011-02-23 09:26:17 UTC (rev 11278)
+++ sandbox/camptocamp/mobile/openlayers/examples/mobile.js 2011-02-23 09:26:24 UTC (rev 11279)
@@ -35,40 +35,20 @@
new OpenLayers.Control.DrawFeature(
vector, OpenLayers.Handler.Polygon, {id: "poly-control"}
),
- new OpenLayers.Control.ModifyFeature(vector, {id: "mod-control"})
+ new OpenLayers.Control.ModifyFeature(vector, {id: "mod-control"}),
+ new OpenLayers.Control.Geolocate({
+ id: "locate-control",
+ options: {
+ enableHighAccuracy: true
+ }
+ })
],
layers: [new OpenLayers.Layer.OSM(), vector],
center: new OpenLayers.LonLat(0, 0),
zoom: 1
});
-
- // attempt to get position
- if (window.navigator && navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(
- updatePosition,
- function failure(error) {
- OpenLayers.Console.log(error.message);
- },
- {
- enableHighAccuracy: true
- }
- );
- }
-
};
-// get position if possible
-var position;
-function updatePosition(pos) {
- position = pos;
- var lon = position.coords.longitude;
- var lat = position.coords.latitude;
- OpenLayers.Console.log("position: lon " + lon + ", lat " + lat);
- map.setCenter(
- new OpenLayers.LonLat(lon, lat).transform(gg, sm)
- );
-}
-
function pan(fx, fy) {
var size = map.getSize();
map.pan(size.w * fx, size.h * fy);
More information about the Commits
mailing list