将地址设为经纬度 ti.map
Make address to latitude longitude ti.map
我正在使用 Ti.map 模块。
现在我想将地址更改为经纬度
设置注释引脚。
就像你在 google 地图搜索框中输入地址一样
虽然我在 Ti.map 文档中找不到执行此操作的方法,但我认为这是一个非常简单的功能??
有人可以帮我吗??
您可以使用 Google API 来执行此操作:
var v = encodeURIComponent("YOUR ADDRESS HERE");
var xhr = Titanium.Network.createHTTPClient();
xhr.autoEncodeUrl = false;
xhr.onload = function(e){
if (xhr.status == 200 ){
if(xhr.readyState == 4){
var response = JSON.parse(xhr.responseText);
}
}
};
xhr.onerror = function(e){};
var url = 'https://maps.googleapis.com/maps/api/geocode/json?address='+v+'&sensor=false';
xhr.open('GET', url, true);
xhr.send();
如果你想从你的纬度/经度得到地址,你可以使用Ti.Geolocation.reverseGeocoder()
方法:http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-reverseGeocoder
为什么不使用内置的 GeoLocation 服务? http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation
查看 forwardGeocoder 方法。
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-forwardGeocoder
我正在使用 Ti.map 模块。
现在我想将地址更改为经纬度 设置注释引脚。
就像你在 google 地图搜索框中输入地址一样
虽然我在 Ti.map 文档中找不到执行此操作的方法,但我认为这是一个非常简单的功能??
有人可以帮我吗??
您可以使用 Google API 来执行此操作:
var v = encodeURIComponent("YOUR ADDRESS HERE");
var xhr = Titanium.Network.createHTTPClient();
xhr.autoEncodeUrl = false;
xhr.onload = function(e){
if (xhr.status == 200 ){
if(xhr.readyState == 4){
var response = JSON.parse(xhr.responseText);
}
}
};
xhr.onerror = function(e){};
var url = 'https://maps.googleapis.com/maps/api/geocode/json?address='+v+'&sensor=false';
xhr.open('GET', url, true);
xhr.send();
如果你想从你的纬度/经度得到地址,你可以使用Ti.Geolocation.reverseGeocoder()
方法:http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-reverseGeocoder
为什么不使用内置的 GeoLocation 服务? http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation
查看 forwardGeocoder 方法。 http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-forwardGeocoder