如何在 Flash 中的 Google Maps API 中按街道名称缩放到某个地点?

发布于 2024-09-26 02:36:11 字数 214 浏览 2 评论 0原文

如果我问一个基本问题,我很抱歉,但我在任何地方都找不到它,而且我对提供的文档了解不多。基本上,我想制作一个 *.SWF,其中用户在第一帧中插入地址,然后在第二帧中 Google 地图显示该地点。问题是我不知道如何在没有 LatLng 参数的情况下缩放点。地理编码可能是解决方案,但正如我之前所说,我不明白它在 Flash 中是如何工作的。有人可以发布几行内容或指导我查看 Flash 中的地理编码示例吗?非常感谢。

I'm sorry if I'm asking a basic question, but I can't find it anywhere and I don't understand too much from the provided documentation. Basically, I want to make a *.SWF in which the user inserts an address in the first frame, then in the second frame Google Maps shows that place. The problem is that I don't know how to zoom on a point without LatLng parameter. Probably, Geocoding would be the solution, but as I said earlier, I don't understand how it works in Flash. Could someone please either post a few lines or direct me to an example of geocoding in Flash? Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦幻的心爱 2024-10-03 02:36:12

您可以使用 com.google.maps.services.ClientGeocoder 来实现此目的。

以下是一些代码片段,不是完整的代码,但它可能会给您一些开始的东西:

import com.google.maps.services.ClientGeocoder;
import com.google.maps.services.GeocodingEvent;

var geocoder:ClientGeocoder = new ClientGeocoder();

geocoder.addEventListener(GeocodingEvent.GEOCODING_SUCCESS, onGeocodeDone);
geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE, onGeocodeFault);

geocoder.geocode("The address goes here");

function onGeocodeDone(e:GeocodingEvent):void
{
   trace("lat: " + e.response.placemarks[0].point.lat());
   trace("lng: " + e.response.placemarks[0].point.lng());
}

function onGeocodeFault(e:GeocodingEvent):void
{
   trace("Geocoding failed: " + e.status);
}

You would use a com.google.maps.services.ClientGeocoder for that.

Here are some code fragments, not complete code, but it may give you something to start with:

import com.google.maps.services.ClientGeocoder;
import com.google.maps.services.GeocodingEvent;

var geocoder:ClientGeocoder = new ClientGeocoder();

geocoder.addEventListener(GeocodingEvent.GEOCODING_SUCCESS, onGeocodeDone);
geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE, onGeocodeFault);

geocoder.geocode("The address goes here");

function onGeocodeDone(e:GeocodingEvent):void
{
   trace("lat: " + e.response.placemarks[0].point.lat());
   trace("lng: " + e.response.placemarks[0].point.lng());
}

function onGeocodeFault(e:GeocodingEvent):void
{
   trace("Geocoding failed: " + e.status);
}
吲‖鸣 2024-10-03 02:36:12

除了Lars的回答之外,将地图设置为地理编码结果的方法(包括根据结果的准确性缩放到适当的级别)是这样的:

_map.setCenter(placemarks[0].point);

var box:Object = placemarks[0].ExtendedData.LatLonBox;
var bounds:LatLngBounds = new LatLngBounds(
    new LatLng(box.south, box.west), 
    new LatLng(box.north, box.east));
var zoom:int = _map.getBoundsZoomLevel(bounds);
_map.setZoom(zoom);

这些字段的参考取自这篇文章:

< a href="https://groups.google.com/group/google-maps-api-for-flash/browse_thread/thread/1a6ede093d053903" rel="nofollow">https://groups.google.com/group/ google-maps-api-for-flash/browse_thread/thread/1a6ede093d053903

其中引用了此示例:

http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/GeocodingDetails/GeocodingDetails.html

In addition to Lars's answer, the way to set the map to the result of the geocode (including zooming to an appropriate level based on the accuracy of the result), is like this:

_map.setCenter(placemarks[0].point);

var box:Object = placemarks[0].ExtendedData.LatLonBox;
var bounds:LatLngBounds = new LatLngBounds(
    new LatLng(box.south, box.west), 
    new LatLng(box.north, box.east));
var zoom:int = _map.getBoundsZoomLevel(bounds);
_map.setZoom(zoom);

The reference for these fields is taken from this post:

https://groups.google.com/group/google-maps-api-for-flash/browse_thread/thread/1a6ede093d053903

Which references this sample:

http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/GeocodingDetails/GeocodingDetails.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文