在android中创建地图链接

时间:2014-06-07 11:48:45

标签: android google-maps maps

我想生成地图链接,并希望发送该链接的邮件。当用户点击该链接时,应该在该位置的浏览器中打开地图。我已生成链接并显示位置但问题是它没有显示当前位置的引脚。如何修改链接以便我可以在地图上得到别针。我生成的链接如下,

https://www.google.com/maps/preview/@ “+纬度+”, “+经度+”,16Z

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

创建包含图钉(称为图钉)的GIF图像并将其复制到res / drawable-mdpi 现有项目的文件夹

import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.os.Bundle;
import android.view.KeyEvent;

public classLBSActivity extendsMapActivity {

MapView mapView;
MapController mc;
GeoPoint p;
private classMapOverlay extendscom.google.android.maps.Overlay
{
@Override
public booleandraw(Canvas canvas, MapView mapView,
booleanshadow, longwhen)
{
super.draw(canvas, mapView, shadow);
//---translate the GeoPoint to screen pixels---Point screenPts = newPoint();
mapView.getProjection().toPixels(p, screenPts);
//---add the marker---FIGURE 9-10
Displaying Maps
❘ 367
Bitmap bmp = BitmapFactory.decodeResource(
getResources(), R.drawable.pushpin);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);
return true;
}
}
/** Called when the activity is first created. */
@Override
public voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView= (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
mapView.setTraffic(true);
mc= mapView.getController();
String coordinates[] = {“1.352566007”, “103.78921587”};
doublelat = Double.parseDouble(coordinates[0]);
doublelng = Double.parseDouble(coordinates[1]);
p= newGeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));
mc.animateTo(p);
mc.setZoom(13);
//---Add a location marker---MapOverlay mapOverlay = newMapOverlay();
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
mapView.invalidate();
}
public booleanonKeyDown(intkeyCode, KeyEvent event) 
{
//...
}
@Override
protected booleanisRouteDisplayed() {
//...
}
}