相关疑难解决方法(0)

如何使用Google Maps API v3获取客户位置?

How do you get Client location using Google Maps API v3? I tried the following code but kept getting the "google.loader.ClientLocation is null or not an object" error. Any ideas why ??

if (google.loader.ClientLocation) {
            alert(google.loader.ClientLocation.latitude+" "+google.loader.ClientLocation.longitude);
        }
Run Code Online (Sandbox Code Playgroud)

Thank You

javascript google-maps

17
推荐指数
3
解决办法
12万
查看次数

如何使用javascript在谷歌地图中设置标记

我正在使用下面的 javascript 代码来显示地图和标记。地图加载时正在加载标记,但如果单击名为“添加标记”的按钮,我想加载标记。标记应指向当前位置。如何在这里做。

js。

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder = new google.maps.Geocoder();

function updateMarkerStatus(str) {
  document.getElementById('markerStatus').innerHTML = str;
}

function updateMarkerPosition(latLng) {
  document.getElementById('info').innerHTML = [
    latLng.lat(),
    latLng.lng()
  ].join(', ');
}

function updateMarkerAddress(str) {
  document.getElementById('address').innerHTML = str;
}

function initialize() {
  var latLng = new google.maps.LatLng(-29.3456, 151.4346);
  var map = new google.maps.Map(document.getElementById('mapCanvas'), {
    zoom: 8,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });
  var marker = new google.maps.Marker({
    position: latLng,
    title: 'Marker',
    map: map,
    draggable: true
  }); …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery google-maps google-maps-markers

5
推荐指数
1
解决办法
2万
查看次数