2012-12-26 26 views
1

我正在为有4个办公室/建筑物的医疗诊所创建移动应用程序。我想创建一个标记所有4个位置的Google地图,并为用户提供选项以获取每个位置的路线。Google地图:在移动应用程序中嵌入多个位置和路线

我在Phonegap和Jquery mobile中构建这个应用程序。到目前为止,我发现的最接近的东西是:Direction example

如果GPS已启用或使用地理位置,我还想将“from”字段默认设置为用户的位置。

这样做的常见做法(从可用性的角度来看)是什么?你知道我可以提及的任何资源吗?

回答

1

对于在项目中使用的GPS可以用以下

if (navigator.geolocation) { 
navigator.geolocation.getCurrentPosition( 

    function (position) { 

    // Did we get the position correctly? 
    // alert (position.coords.latitude); 

    // To see everything available in the position.coords array: 
    // for (key in position.coords) {alert(key)} 

    mapServiceProvider(position.coords.latitude,position.coords.longitude); 

    }, 
    // next function is the error callback 
    function (error) 
    { 
     switch(error.code) 
     { 
      case error.TIMEOUT: 
       alert ('Timeout'); 
       break; 
      case error.POSITION_UNAVAILABLE: 
       alert ('Position unavailable'); 
       break; 
      case error.PERMISSION_DENIED: 
       alert ('Permission denied'); 
       break; 
      case error.UNKNOWN_ERROR: 
       alert ('Unknown error'); 
       break; 
     } 
    }); 
} 

的代码,可以发现herephonegap docs 当你有,你可以改变你的 形式值的位置。那么是否使用谷歌地图插件 的问题。我个人并没有使用任何。由于 您正在使用jQuery手机,您可以使用this

创建在init事件地图(所以你只创建一次),并 触发在pageshow事件resize事件,所以你不会有问题 与地图出现在你的屏幕等 的左上角如果您使用我提到的插件,请查找刷新方法。 地图的容器必须具有大小。如果不是, 将无法​​正常显示,因为jqm会将最小尺寸 添加到容器中。您可以通过编程(检查窗口高度和宽度)来计算空间(如果存在 标题,则必须将其包含在计算中)。 最后,如果您有在this

+0

感谢您的详细回答变焦看问题。 – farjam

+0

如果这回答了你的问题,你为什么不接受它? http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 – alkis

相关问题