小编eva*_*van的帖子

如何在 Google Place AutoComplete API 上添加会话令牌

我有一个地址搜索输入,它调用谷歌 API 进行自动完成。它有效,但我想在查询中添加会话令牌,但我不知道该怎么做。

我在互联网上到处搜索,但我只看到:“使用 var sessionToken = new google.maps.places.AutocompleteSessionToken(); 生成会话令牌”。好的,但我不知道把这个变量放在哪里:/

<script type="text/javascript"  src="https://maps.googleapis.com/maps/api/js?libraries=places&key=MY_API_KEY"></script>
<form>
    <label>Address</label>
    <input id="user_input_autocomplete_address" placeholder="Votre adresse...">
</form>
<script>
    function initializeAutocomplete(id) {
        var element = document.getElementById(id);

        if (element) {
            var autocomplete = new google.maps.places.Autocomplete(element, { types: ['address'] });
            autocomplete.setComponentRestrictions({'country': ['fr']});
            google.maps.event.addListener(autocomplete, 'place_changed', onPlaceChanged);
        }
    }   
    function onPlaceChanged() {  
        var place = this.getPlace();
        console.log(place);

        for (var i in place.address_components) {    
            var component = place.address_components[i];    

            for (var j in component.types) {
                var type_element = document.getElementById(component.types[j]);      

                if (type_element) {        
                    type_element.value = …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-api google-places-api

9
推荐指数
1
解决办法
8063
查看次数

使用 google API 判断一个地方有多忙

在谷歌搜索场地时,我通常可以看到下图,显示这个地方有多忙:

在此处输入图片说明

我正在查看 Google Places API 文档,但似乎找不到相关信息。

google-maps google-places-api

8
推荐指数
3
解决办法
6906
查看次数

错误:使用 Google 地图 API 的 AGM 地图中出现 ApiTargetBlockedMapError

我尝试将谷歌地图包含在多个位置。

对于一个位置,Iframe 工作正常。我不知道如何在 Iframe 中实现多个位置。所以我尝试了年度股东大会。我也将相同的 APIKey 用于 AGM。但是出现Google Maps JavaScript API 错误: ApiTargetBlockedMapError错误。

这是我的 IFrame 代码

<iframe src="https://www.google.com/maps/embed/v1/place?q=11.0443324,77.04292389999999&key=MY_APIKEY" width="98%" height="100%" frameborder="0"></iframe>

对于 AGM 在 NgModule 中添加密钥

AgmCoreModule.forRoot({AgmCoreModule.forRoot({
     apiKey: 'MY_APIKEY',
     }) 
<agm-marker *ngFor="let loc of mSupplierLocationList" [label]="loc.label" [latitude]="loc.latitude" [longitude]="loc.longitude" >
</agm-marker>
</agm-map>
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3 angular-google-maps angular8

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

请问如何在 flutter 桌面中使用谷歌地图?

我到处搜索有关如何将谷歌地图包含在 flutter 桌面应用程序中的指南。我尝试按照 iOS 指南进行操作,但没有成功。macos/Runner我在目录中的 AppDelegate.swift 中做了以下操作

import Cocoa
import FlutterMacOS
import GoogleMaps

@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
  override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
    GMSServices.provideAPIKey("MY_API_KEY")
    return true
  }
}
Run Code Online (Sandbox Code Playgroud)

但我总是收到以下错误

The following build commands failed:
    CompileSwift normal x86_64 /Users/xxxxx/xxxxx/xxxxxx/xxxxx/macos/Runner/AppDelegate.swift
    CompileSwift normal x86_64 /Users/xxxxxxx/xxxxxx/xxxxxx/xxxxxx/macos/Flutter/GeneratedPluginRegistrant.swift
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(3 failures)
Finished with error: Build process failed
Run Code Online (Sandbox Code Playgroud)

macos google-maps desktop-application flutter

7
推荐指数
1
解决办法
4553
查看次数

MarkerClusterer 中“option”对象下的“gridSize”定义了什么?

我正在使用 MarkerClusterer 库开发 Google 地图和标记聚类。“option”对象中的“gridSize”参数到底定义了什么?如果它是聚类图像的大小(以像素为单位),那么如何针对同一地图中的不同聚类更改它?

我尝试使用此链接提供的文档来使用 MarkerClusterer 库:https://developers.google.com/maps/documentation/javascript/marker-clustering

它没有解释如何更改和添加“选项”对象以及如何根据需要编辑选项代码。

我希望您帮助我使同一地图上不同聚类的聚类图像大小不同。

javascript google-maps markerclusterer

6
推荐指数
1
解决办法
4840
查看次数

Angular 9 Google Maps API Place 自动完成

我有一个 Angular 9(刚从 8 迁移),我需要使用 Google Places API(我有一个 API 密钥)进行地址自动完成,我可以用 @angular/googlemaps 库显示地图,但我不能自动完成工作...

我尝试使用https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete代码,但我无法使 angular 使用 javascript... 或尝试使用@agm/coreand @angular-material-extensions/google-maps-autocomplete,也不工作...

我最好的办法是尽可能地使用它,但我不知道如何在 Angular 中只使用 javascript ......有一个像地图这样的角度原生组件?o 如何实现 Google 在演示中使用的 javascript 方式?

javascript google-maps google-maps-api-3 angular

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

由于 API 密钥无效(格式错误或丢失),操作失败

使用适用于 IOS 的 Google 代码,描述如下:自动完成

\n\n

用户在搜索框中输入第一个字符时,会发生错误:

\n\n
Error:  The operation couldn\xe2\x80\x99t be completed. Operation failed due to an invalid (malformed or missing) API key. See the developer\'s guide (https://developers.google.com/places/ios-sdk/start) for information on creating and using an API key.\ndespite that calls to the API were successful:\nGMS Services Key Valid:  true\nGMS Services SDK version:  3.3.0\nGMS Places Key Valid:  true\nGMS Places SDK version:  3.3.0\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是应用程序的跟踪:

\n\n
2019-08-17 16:46:52.056351-0400 GPDemo[345:15310] [DYMTLInitPlatform] platform initialization successful\nEntering AppDelegate.swift now...\nSending API key to Google Services …
Run Code Online (Sandbox Code Playgroud)

google-maps ios google-places-api swift

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

如何在react-native-google-places-autocomplete中设置搜索图像图标?

如何在react-native-google-places-autocomplete中设置搜索图像图标?

我想知道如何在react-native-google-places-autocomplete中设置左侧的搜索图像图标。

我想要在下面的屏幕中输出这样的输出。所以请帮助我。

在此输入图像描述 但我的设计是这样的。

在此输入图像描述

这是 DiscoveryLocation.js 文件的代码。

import React, { Component } from 'react'
    import { Text, View, TouchableOpacity, TextInput, StyleSheet, Image } from 'react-native'
    import { heightPercentageToDP as hp, widthPercentageToDP as wp } from 'react-native-responsive-screen';
    import { RFPercentage, RFValue } from "react-native-responsive-fontsize";
    import MapView, { PROVIDER_GOOGLE, Marker } from 'react-native-maps';
    import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
    console.disableYellowBox = true;

    export default class DiscoveryLocation extends Component {
        render() {
            return (
                <View style={styles.container}>
                    <View style={styles.vwheader} >
                        <TouchableOpacity
                            onPress={() => { …
Run Code Online (Sandbox Code Playgroud)

google-maps react-native react-native-ios google-places-autocomplete

4
推荐指数
1
解决办法
4275
查看次数

类型错误:无法读取未定义的属性“PlacesService”

我的目标是使用“routeRequest”请求一组符合我的标准的位置并保存它们。为此,我使用谷歌地点来检查地图中心周围的位置。

let map = new google.maps.Map(document.querySelector("#myMap"), {
    center: { lat: 41.148481, lng: -8.606893 },
    zoom: 15
  });

let service = new google.maps.places.PlacesService(map);
service.nearbySearch(routeRequest, callback);


let routeRequest = {
    location: map.center,
    radius: '1000',
    type: [this.typeRoute]
  };


function callback(results, status) {
    if (status == google.maps.places.PlacesServiceStatus.OK) {
      for (const result of results) {
        this.listLocations.push(result);
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

问题是,placesService 似乎无法识别地图

javascript google-maps google-places-api vue.js

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

如何正确使用会话令牌?

我将 Java 客户端用于 Google Places API:

<dependency>
    <groupId>com.google.maps</groupId>
    <artifactId>google-maps-services</artifactId>
    <version>0.9.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

以下是我在服务器上使用自动完成 API 的方式:

public List<AutocompletePrediction> searchAddress(String query) {

    List<AutocompletePrediction> predictions = new ArrayList<>();

    try {
        AutocompletePrediction[] autocompletePredictions = PlacesApi
                .placeAutocomplete(geoApiContext, query, null) 

        predictions.addAll(Arrays.asList(autocompletePredictions));
    } catch (ApiException | InterruptedException | IOException e) {
        e.printStackTrace();
    }

    return predictions;
}
Run Code Online (Sandbox Code Playgroud)

现在,当时我传递nullsessionToken

.placeAutocomplete(geoApiContext, query, null) 
Run Code Online (Sandbox Code Playgroud)

主要是因为我不完全确定这些应该如何工作。

我可以每 2 分钟创建一个令牌并使用该令牌,无论哪个用户当前正在输入。

所以这意味着如果两个用户搜索“位置”和“地点”,传入的查询可能如下所示:

[User 1] 1. lo
[User 2] 2. p
[User 1] 3. loca
[User 2] 4. plac
[User …
Run Code Online (Sandbox Code Playgroud)

java google-maps google-places-api google-places-autocomplete

1
推荐指数
1
解决办法
1641
查看次数