本文整理汇总了Java中com.amap.api.maps2d.model.LatLng类的典型用法代码示例。如果您正苦于以下问题:Java LatLng类的具体用法?Java LatLng怎么用?Java LatLng使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LatLng类属于com.amap.api.maps2d.model包,在下文中一共展示了LatLng类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryLatLngAddress
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
private void queryLatLngAddress(LatLng latlng) {
if(!TextUtils.isEmpty(addressInfo) && latlng.latitude == latitude && latlng.longitude == longitude) {
return;
}
Handler handler = getHandler();
handler.removeCallbacks(runable);
handler.postDelayed(runable, 20 * 1000);// 20s超时
geocoder.queryAddressNow(latlng.latitude, latlng.longitude);
latitude = latlng.latitude;
longitude = latlng.longitude;
this.addressInfo = null;
setPinInfoPanel(false);
}
示例2: onMapClick
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
@Override
public void onMapClick(LatLng point) {
if (isAdd == true){
markWaypoint(point);
Waypoint mWaypoint = new Waypoint(point.latitude, point.longitude, altitude);
//Add Waypoints to Waypoint arraylist;
if (waypointMissionBuilder != null) {
waypointList.add(mWaypoint);
waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
}else
{
waypointMissionBuilder = new WaypointMission.Builder();
waypointList.add(mWaypoint);
waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
}
}else{
setResultToToast("Cannot Add Waypoint");
}
}
示例3: updateDroneLocation
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
private void updateDroneLocation(){
LatLng pos = new LatLng(droneLocationLat, droneLocationLng);
//Create MarkerOptions object
final MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(pos);
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.aircraft));
runOnUiThread(new Runnable() {
@Override
public void run() {
if (droneMarker != null) {
droneMarker.remove();
}
if (checkGpsCoordination(droneLocationLat, droneLocationLng)) {
droneMarker = aMap.addMarker(markerOptions);
}
}
});
}
示例4: onLocationChanged
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
@Override
public void onLocationChanged(NimLocation location) {
if (location != null && location.hasCoordinates()) {
if (firstLocation) {
firstLocation = false;
myAddressInfo = location.getFullAddr();
double latitude = location.getLatitude();
double longitude = location.getLongitude();
myLatLng = new LatLng(latitude, longitude);
// 缩放到可见区
int boundPadding = getResources().getDimensionPixelSize(R.dimen.friend_map_bound_padding);
LatLngBounds bounds = LatLngBounds.builder().include(myLatLng).include(desLatLng).build();
CameraUpdate camera = CameraUpdateFactory.newLatLngBounds(bounds, boundPadding);
amap.moveCamera(camera);
updateMyMarkerLatLng();
updateSendStatus();
}
} else {
showLocationFailTip();
}
clearTimeoutHandler();
}
示例5: Factory
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
public Factory() {
users = new ArrayList<>(7);
posts = new ArrayList<>(8);
friendPosts = new ArrayList<>(6);
messages = new ArrayList<>(5);
users.add(new User("Jason", R.drawable.av1));
users.add(new User("JB", R.drawable.av2));
users.add(new User("Hsg", R.drawable.av3));
users.add(new User("王子尧", R.drawable.av4));
users.add(new User("马幸颖", R.drawable.av5));
users.add(new User("Vincent", R.drawable.av6));
users.add(new User("小姐姐", R.drawable.av7));
posts.add(new Post(randomUser(), R.drawable.p1, "给咱一个地铁站 法师可以玩一天", new LatLng(32.02411, 118.79087)));
posts.add(new Post(randomUser(), R.drawable.p3, "糖果小屋", new LatLng(32.022964, 118.791986)));
posts.add(new Post(randomUser(), R.drawable.p4, "书如画", new LatLng(32.079255,118.816898)));
posts.add(new Post(randomUser(), R.drawable.p5, "梦想在,哪里都是舞台", new LatLng(32.025567, 118.85844)));
posts.add(new Post(randomUser(), R.drawable.p6, "好耐冇逛深水埗", new LatLng(32.155003, 118.848141)));
posts.add(new Post(randomUser(), R.drawable.p7, "海边 等一个人和我牵手", new LatLng(31.985099, 118.672703)));
posts.add(new Post(randomUser(), R.drawable.p2, "Quebec!", new LatLng(32.054379, 118.842647)));
friendPosts.add(new Post(randomUser(),R.drawable.fp10,"Hack Nanjing!", new LatLng(32.054379, 118.842647)));
friendPosts.add(new Post(randomUser(), R.drawable.fp1, "南山南 北海北 南山有墓碑", new LatLng(32.174766, 119.433527)));
friendPosts.add(new Post(randomUser(), R.drawable.fp2, "女人出门果然就是自拍 预祝白白参加中国新歌声成功", new LatLng(32.087097, 118.778995)));
friendPosts.add(new Post(randomUser(), R.drawable.fp3, "斯里兰卡", new LatLng(31.912853, 118.771601)));
friendPosts.add(new Post(randomUser(), R.drawable.fp4, "心里的郁结一下子被风吹走了", new LatLng(32.005033, 118.787235)));
friendPosts.add(new Post(randomUser(), R.drawable.fp5, "永远收不住的放荡不羁", new LatLng(32.042873, 118.763889)));
friendPosts.add(new Post(randomUser(), R.drawable.fp6, "Hey!China!", new LatLng(32.060333, 118.599781)));
User counterpart = randomUser();
messages.add(new Message(counterpart, "嗨嗨嗨~~~", 0, Message.TYPE_RECEIVED, Message.CONTENT_STRING));
messages.add(new Message(counterpart, "看我拍了什么!", 0, Message.TYPE_RECEIVED, Message.CONTENT_STRING));
messages.add(new Message(counterpart, "", R.drawable.test_photo, Message.TYPE_RECEIVED, Message.CONTENT_PHOTO));
messages.add(new Message(me, "真有你的", 0, Message.TYPE_SENT, Message.CONTENT_STRING));
messages.add(new Message(me, "我有两句诗,不知当不当念?", 0, Message.TYPE_SENT, Message.CONTENT_STRING));
}
示例6: onLocationChanged
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (mListener != null && aMapLocation != null) {
if (aMapLocation != null
&& aMapLocation.getErrorCode() == 0) {
LatLng location = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
if (!mFirstFix) {
mFirstFix = true;
addCircle(location, aMapLocation.getAccuracy());//添加定位精度圆
addMarker(location);//添加定位图标
mSensorHelper.setCurrentMarker(mLocMarker);//定位图标旋转
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 18));
} else {
mCircle.setCenter(location);
mCircle.setRadius(aMapLocation.getAccuracy());
mLocMarker.setPosition(location);
mAMap.moveCamera(CameraUpdateFactory.changeLatLng(location));
}
} else {
String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
Log.e("AmapErr", errText);
}
}
}
示例7: onLocationChanged
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//可在其中解析amapLocation获取相应内容。
double locationType = amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
double latitude = amapLocation.getLatitude();//获取纬度
double longitude = amapLocation.getLongitude();//获取纬度
L.i("location", "locationType:" + locationType + ",latitude:" + latitude + ",longitude:" + longitude);
LatLng latLng = new LatLng(latitude, longitude);
getAddressByLatlng(latLng);
} else {
//定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
L.i("location", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
}
}
示例8: sendToChildrenLocation
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
private void sendToChildrenLocation(final String address, final LatLng latLng) {
LocationMessage message = new LocationMessage();
message.setContent("location");
Map<String, Object> map = new HashMap<>();
map.put("id", BmobUser.getCurrentUser(User.class).getUsername());
map.put("address", address);
map.put("latitude", latLng.latitude);
map.put("longitude", latLng.longitude);
message.setExtraMap(map);
L.i("send location");
mConversationManager.sendMessage(message, new MessageSendListener() {
@Override
public void done(BmobIMMessage bmobIMMessage, BmobException e) {
if (e != null) {
L.i("send location failed " + e.getMessage());
} else {
L.i("send location successfully");
L.i("address: " + address);
L.i("latitude: " + latLng.latitude);
L.i("longitude: " + latLng.longitude);
}
}
});
}
示例9: getMarkerOptions
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
private MarkerOptions getMarkerOptions(AMapLocation amapLocation) {
//设置图钉选项
MarkerOptions options = new MarkerOptions();
//图标
options.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_location_on_black_48dp));
//位置
options.position(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude()));
StringBuffer buffer = new StringBuffer();
buffer.append(amapLocation.getCountry() + "" + amapLocation.getProvince() + "" +
amapLocation.getCity() + "" + amapLocation.getDistrict() + "" +
amapLocation.getStreet() + "" + amapLocation.getStreetNum());
//标题
options.title(buffer.toString());
//子标题
// options.snippet("I'am Here!");
//设置多少帧刷新一次图片资源
options.period(60);
return options;
}
示例10: run
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
@Override
public void run() {
super.run();
switch (state){
case AIR_REQUEST:
updateView(getRequestAir((String) params.get("city_name")));break;
case WEATHER_REQUEST:
updateView(getRequestWeather((LatLng) params.get("latLng")));break;
case REQUEST_ALL:
getRequestAll((LatLng)params.get("latLng"));break;
case ERROR:
Log.i("Error","Error in NetworkRequest Thread");
}
}
示例11: getRequestAll
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
private void getRequestAll(LatLng latLng){
final Map<String,String> map=getRequestWeather(latLng);
final int index=(int)params.get("weather_id");
map.putAll(getRequestAir(map.get("city")));
handler.post(new Runnable() {
@Override
public void run() {
((Button)params.get("city")).setText(map.get("city"));
((TextView)params.get("weather")).setText("天气 :"+map.get("天气"));
((TextView)params.get("temperature")).setText("气温 :"+map.get("气温"));
((TextView)params.get("AQI")).setText("AQI(空气质量指数) :"+map.get("AQI(空气质量指数)"));
((TextView)params.get("quality")).setText("空气质量 :"+map.get("空气质量"));
((ImageView)params.get("icon_weather")).setImageResource(Database.icon_id[index]);
params.clear();
params.putAll(map);
CityActivity.initDatabase();
}
});
// params.clear();
// params.putAll(map);
}
示例12: init
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
private void init(){
Intent mIntent = getIntent();
LatLng latLng = mIntent.getParcelableExtra("latLng");
params = new HashMap();
params.put("latLng",latLng);
params.put("city",city_title);
params.put("weather",city_weather);
params.put("temperature",city_temperature);
params.put("AQI",city_AQI);
params.put("quality",city_quality);
params.put("icon_weather",city_weather_icon);
new NetworkRequest(params,handler).start();
favorite_btn.setOnClickListener(this);
back_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
示例13: addMarker
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
private void addMarker(LatLng latLng, String url) {
AsyncImageView imageView = (AsyncImageView) LayoutInflater.from(this).inflate(R.layout.map_marker_view, null);
// AsyncImageView imageView = (AsyncImageView) view.findViewById(R.id.icon);
imageView.setResource(new Resource(url));
// aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
// .position(new LatLng(30.679879, 104.064855)).title("成都市")
// .snippet("成都市:30.679879, 104.064855").draggable(true));
MarkerOptions markerOption = new MarkerOptions();
markerOption.position(new LatLng(34.341568, 108.940174));
// markerOption.title("西安市").snippet("西安市:34.341568, 108.940174");
// markerOption.draggable(true);
// markerOption.icon(BitmapDescriptorFactory.fromResource(R.drawable.rc_default_portrait));
markerOption.icon(BitmapDescriptorFactory.fromView(imageView));
// markerOption.icon(BitmapDescriptorFactory
// .defaultMarker(BitmapDescriptorFactory.HUE_RED));
Marker marker2 = aMap.addMarker(markerOption);
// marker旋转90度
// marker2.setRotateAngle(90);
}
示例14: setMark
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
/**
* 在地图上设置标记图标
*
* @param type 图标的样式
*/
private void setMark(int type, Post post) {
if (type == OTHER_MARK) {
myMarkOption = new MarkerOptions();
//添加用户覆盖物
LatLng postCurrentLatLng = new LatLng(post.getLatitude(), post.getLongitude());
myMarkOption.anchor(0.5f, 0.5f).
position(postCurrentLatLng).title(post.getUsername()).snippet(post.getTag() + "@@" + post.getAddress() + "@@" + post.getTime()).
draggable(false).icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_ic));
myMark = aMap.addMarker(myMarkOption);
} else {
//暂时还没有设计用户定位图标
}
}
示例15: getInfoWindow
import com.amap.api.maps2d.model.LatLng; //导入依赖的package包/类
@Override
public View getInfoWindow(final Marker marker) {
View view = getLayoutInflater().inflate(R.layout.item_poikeywordsearch, null);
TextView title = (TextView) view.findViewById(R.id.title);
title.setText(marker.getTitle());
TextView snippet = (TextView) view.findViewById(R.id.brief);
snippet.setText(marker.getSnippet());
ImageButton button = (ImageButton) view.findViewById(R.id.start_map_app);
// 调起高德地图app
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String title1 = marker.getTitle();
LatLng position1 = marker.getPosition();
Toast.makeText(getApplication(), title1, Toast.LENGTH_SHORT).show();
startURI(title1, position1.latitude, position1.longitude);
}
});
return view;
}