我有一个小应用程序,提供当前位置:经度和纬度。 现在我必须浏览谷歌地图的经度和纬度。 请建议我该怎么做。

我在谷歌地图上有10个标记。我想要尽可能放大,并保持所有标记都在视野中?在早期版本中,这可以从zoomToSpan()实现,但在v2中,我不知道如何做到这一点。此外,我知道需要可见的圆的半径。

我把谷歌地图嵌入到我的网站。一旦谷歌地图被加载,我需要启动一些JavaScript进程。

有没有办法自动检测当谷歌地图已完全加载,包括瓷砖下载和所有?

存在一个tilesloaded()方法,该方法应该完全完成这个任务,但它不起作用。

我有一个纬度和经度:“-27.0000,133.0000”。我想在此基础上制作一张地图。

我试着去这个链接

https://maps.googleapis.com/maps/api/geocode/json?latlng= 27.0000, 133.0000关键= * * * * * *

我一直在浏览器上得到这个错误

{
   "error_message" : "This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

但我想我已经启用了那个API。我登录到我的谷歌控制台,并再次检查。

当我去:https://console.developers.google.com/project/75423435770063/apiui/apis/enabled

我明白了:

启用地理编码+地理定位。

我现在有点卡住了。还有什么我没注意到的吗?

我最近切换到谷歌Maps API V3。我正在处理一个简单的例子,从数组中绘制标记,但是我不知道如何对标记自动居中和缩放。

我已经搜索了净高和低,包括谷歌自己的文档,但没有找到一个明确的答案。我知道我可以简单地取坐标的平均值,但我如何相应地设置缩放?

function initialize() {
  var myOptions = {
    zoom: 10,
    center: new google.maps.LatLng(-33.9, 151.2),


    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);

  setMarkers(map, beaches);
}


var beaches = [
  ['Bondi Beach', -33.890542, 151.274856, 4],
  ['Coogee Beach', -33.423036, 151.259052, 5],
  ['Cronulla Beach', -34.028249, 121.157507, 3],
  ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
  ['Maroubra Beach', -33.450198, 151.259302, 1]
];

function setMarkers(map, locations) {

  var image = new google.maps.MarkerImage('images/beachflag.png',
      new google.maps.Size(20, 32),
      new google.maps.Point(0,0),
      new google.maps.Point(0, 32));
    var shadow = new google.maps.MarkerImage('images/beachflag_shadow.png',

      new google.maps.Size(37, 32),
      new google.maps.Point(0,0),
      new google.maps.Point(0, 32));


      var lat = map.getCenter().lat(); 
      var lng = map.getCenter().lng();      


  var shape = {
      coord: [1, 1, 1, 20, 18, 20, 18 , 1],
      type: 'poly'
  };
  for (var i = 0; i < locations.length; i++) {
    var beach = locations[i];
    var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        shadow: shadow,
        icon: image,
        shape: shape,
        title: beach[0],
        zIndex: beach[3]
    });
  }
}

我有一个使用谷歌地图Android v2 API的应用程序。我已经添加了google-play-services_lib库项目到我的工作空间,并从我的应用程序项目中添加了对它的引用,按照这些页面上的说明:

http://developer.android.com/google/play-services/setup.html。 https://developers.google.com/maps/documentation/android/start

一切似乎都很正常:应用程序显示地图和覆盖默认标记。所以我很确定我已经正确地设置了谷歌播放服务和谷歌地图API。

然而,我在ADT LogCat窗口中看到这条消息每当地图视图初始化(在第二代Nexus 7上):

The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

消息级别是Error,标记是GooglePlayServicesUtil。

这似乎是良性的,因为我的应用程序运行良好。但是我能做些什么来解决问题呢?


进一步的信息:每次“谷歌播放服务资源未找到”消息出现在LogCat中,它前面是这些消息,这是警告和标记ResourceType:

getEntry failing because entryIndex 906 is beyond type entryCount 3

Failure getting entry for 0x7f0b038a (t=10 e=906) in package 0 (error -2147483647)

FWIW,当我搜索项目时,我找不到常量0x7f0b038a,包括gen/R.java文件。

我检查了生成的.apk的内容,它包括了google-play-services_lib/res目录下的所有资源。


另一个更新:添加ActionBarSherlock和更新targetSdkVersion在我的清单从8到17,我现在看到另一个错误在LogCat输出:

Could not find class 'maps.af.k', referenced from method 'maps.ag.an.a'

关于这个问题的更多细节可以在这里找到:谷歌地图在Android上工作正常,但我仍然得到一个错误“无法找到类的Maps . I。K ',引用自方法maps.z.ag.a"

这款应用似乎又一次运行良好。也许忽略这些“错误”是安全的?

在网上搜索了一段时间后,我找不到任何像这样的地址:

宾夕法尼亚大街东南1200号 华盛顿,哥伦比亚特区,20003年

并将其转换为可点击的链接:

http://maps.google.com/maps?f=q&source=s_q&hl=en&q=1200+Pennsylvania+Ave+SE,+Washington,+District+of+Columbia,+20003&sll=37.0625,-95.677068&sspn=44.118686,114.169922&ie=UTF8&cd=1&geocode=FT5MUQIdIDlp-w&split=0&ll=38.882147,-76.99017&spn=0.01064,0.027874&z=16&iwloc=A

jQuery或PHP是首选或者任何有用的信息。

当我使用Android Studio构建我的应用程序时,我遇到了这个错误。APK被编译,但当我试图在Android P模拟器上运行应用程序时,它会崩溃并抛出以下错误。详情请见附件:

java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion

这是我的身材。级文件。如果有人对问题有什么建议,我将不胜感激。多谢。

android {

     compileSdkVersion 'android-P'
     buildToolsVersion '28-rc1'
   
    useLibrary 'org.apache.http.legacy'

    //for Lambda
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {

        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    defaultConfig {
        applicationId "xxx.xxx.xxx"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode xxxx
        versionName "Vx.x.x"

        multiDexEnabled true
     

     //other setting required
        ndk {
            abiFilters 'armeabi', 'armeabi-v7a', 'armeabi-v8a', 'x86', 'x86_64', 'mips', 'mips64'
        }

当我单击JavaFX应用程序的按钮时,我一直试图在地图上显示一个标记。当我点击那个按钮时,我把位置写在JSON文件中,这个文件会被加载到包含地图的html文件中。问题是,当我在浏览器中打开html页面时,它工作得很好,但在JavaFX的web视图中什么都没有发生,我不知道为什么!

这是html文件:

<!DOCTYPE html>
<html>
  <head>
  <title>Simple Map</title>
  <meta name="viewport" content="initial-scale=1.0">
  <meta charset="utf-8">
  <style>
  /* Always set the map height explicitly to define the size of the div
   * element that contains the map. */
  /*#map {
    height: 100%;
  }*/
  #map{width:100%;height:100%;margin:auto;}
  /* Optional: Makes the sample page fill the window. */
  html, body {
    height: 100%;
    margin: 0;
    padding: 0;
  }
</style>
</head>
<body>
<div id="map"></div>
<script>
  var map;
  var marker;
  // Multiple Markers
  var markers = [];
  var pos = {lat: 46.662388, lng: 0.3599617};
  var itinerary_markers = [];

  function initMap() {

    var currentLat, currentLng;//Latitude et longtitude courante

    $.ajax({
      url: 'https://maps.googleapis.com/maps/api/geocode/json?address=My+ADDRESS&key=MY_KEY',
      async: false,
      dataType: 'json',
      success: function (data) {
        currentLat = data.results[0].geometry.location.lat;
        currentLng = data.results[0].geometry.location.lng;
      }
    });

    map = new google.maps.Map(document.getElementById('map'), {
      center: {lat: currentLat, lng: currentLng},
      zoom: 15,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });


    /*MARQUEUR*/ 
    $.ajax({
        async: false,
        url: 'test.json',
        data: "",
        accepts:'application/json',
        dataType: 'json',
        success: function (data) {
            for (var i = 0; i < data.hydrants.length; i++) {
                markers.push( data.hydrants[i]);
            }
        }
    });

      var posi = new google.maps.LatLng(markers[0].Lat, markers[0].Lng);
      marker = new google.maps.Marker({
          position: posi,
          map: map,
          //title: markers[i][0]
          title: markers[0].Name
        });

  }
</script>

<script
    src="https://code.jquery.com/jquery-3.2.1.min.js"
    integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
    crossorigin="anonymous">
</script>


<script src="https://maps.googleapis.com/maps/api/js?key=MY_KEY&callback=initMap&language=fr"
async defer></script>

</body>
</html>

当我点击按钮,我填充JSON文件(这是完美的工作),然后我执行这个刷新webview:

this.webView.getEngine().load(getClass().getResource("/data/index.html").toString());

如前所述,当我在浏览器上打开文件时,我看到了预期的结果,但我不知道JavaFX有什么问题。 如果有更好的办法请告诉我。

编辑:

我通过使用executeScript()方法将数据(GPS坐标)从JavaFX直接发送到Javascript找到了解决方案,因此我不需要json文件作为两个平台之间的桥梁。 下面是代码的示例:

eng.executeScript("updateMarker(" + lat + ", " + lng + ")");//eng is a WebEngine instance

这里是Javascript:

/*The initial latitude and longtitude*/
var currentLat = the latitude;
var currentLng = the longtitude;

function initMap() {

    map = new google.maps.Map(document.getElementById('map'), {
      center: {lat: currentLat, lng: currentLng},
      zoom: 15,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var posi = new google.maps.LatLng(currentLat, currentLng);
    marker = new google.maps.Marker({
        position: posi,
        map: map,
        visible: false
    });
  }

/*The method that is I call from JavaFX*/
function updateMarker(_lat, _lng){
    marker.setPosition({lat: _lat, lng: _lng});
    map.setCenter(new google.maps.LatLng(_lat, _lng));
    marker.setVisible(true);
  }

谢谢你的评论和回答,还有reddit的特别枪战。

我的应用程序需要显示谷歌地图方向从A到B,但我不想把谷歌地图到我的应用程序-相反,我想用一个意图启动它。这可能吗?如果是,怎么做?