这里的地图不起作用
Here maps is not working
我想在我的应用程序中实现 HERE Maps。我刚刚开始实施一个示例应用程序,它只显示 HERE 地图 。
我的代码:
// map embedded in the map fragment
private Map map = null;
// map fragment embedded in this activity
private MapFragment mapFragment = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_here_maps);
// Search for the map fragment to finish setup by calling init().
mapFragment = (MapFragment) getFragmentManager().findFragmentById(
R.id.mapfragment);
/*com.here.android.mpa.common.MapSettings.setIsolatedDiskCacheRootPath(
"/sdcard/foo/myservice"
, "com.here.android.mpa.service.MapService");*/
mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(
OnEngineInitListener.Error error) {
if (error == OnEngineInitListener.Error.NONE) {
// retrieve a reference of the map from the map fragment
map = mapFragment.getMap();
// Set the map center to the Vancouver region (no animation)
map.setCenter(
new GeoCoordinate(49.196261, -123.004773, 0.0),
Map.Animation.NONE);
// Set the zoom level to the average between min and max
map.setZoomLevel((map.getMaxZoomLevel() + map
.getMinZoomLevel()) / 2);
} else {
System.out.println("ERROR: Cannot initialize Map Fragment");
}
}
});
}
但不幸的是它不起作用。
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- Map Fragment embedded with the map object -->
<fragment
android:id="@+id/mapfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.here.android.mpa.mapping.MapFragment" />
</LinearLayout>
Logcat:
08-13 13:02:48.206: W/System.err(9062): org.xml.sax.SAXParseException: Unexpected end of document
08-13 13:02:48.226: W/System.err(9062): at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:125)
08-13 13:02:48.226: W/System.err(9062): at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:107)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.fh.a(XmlToDocParser.java:24)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.ResourceManager.a(ResourceManager.java:212)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.ResourceManager.a(ResourceManager.java:138)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.as.<init>(GLConfigHelper.java:38)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.y.a(BaseTextureView.java:61)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.y.<init>(BaseTextureView.java:54)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.bx.<init>(MapTextureView.java:36)
08-13 13:02:48.226: W/System.err(9062): at com.here.android.mpa.mapping.MapView.a(MapView.java:320)
08-13 13:02:48.231: W/System.err(9062): at com.here.android.mpa.mapping.MapView.<init>(MapView.java:169)
08-13 13:02:48.231: W/System.err(9062): at com.nokia.maps.bk.a(MapFragmentImpl.java:143)
08-13 13:02:48.231: W/System.err(9062): at com.here.android.mpa.mapping.MapFragment.onCreateView(MapFragment.java:147)
08-13 13:02:48.231: W/System.err(9062): at android.app.Fragment.performCreateView(Fragment.java:1699)
08-13 13:02:48.231: W/System.err(9062): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:879)
08-13 13:02:48.231: W/System.err(9062): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053)
08-13 13:02:48.231: W/System.err(9062): at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1155)
08-13 13:02:48.231: W/System.err(9062): at android.app.Activity.onCreateView(Activity.java:4966)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
08-13 13:02:48.231: W/System.err(9062): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
08-13 13:02:48.231: W/System.err(9062): at android.app.Activity.setContentView(Activity.java:1956)
08-13 13:02:48.231: W/System.err(9062): at com.globetech.gticket.activity.zonar.HereMapsActivity.onCreate(HereMapsActivity.java:30)
08-13 13:02:48.231: W/System.err(9062): at android.app.Activity.performCreate(Activity.java:5372)
08-13 13:02:48.231: W/System.err(9062): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
08-13 13:02:48.231: W/System.err(9062): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
08-13 13:02:48.231: W/System.err(9062): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
08-13 13:02:48.231: W/System.err(9062): at android.app.ActivityThread.access0(ActivityThread.java:159)
08-13 13:02:48.231: W/System.err(9062): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
08-13 13:02:48.236: W/System.err(9062): at android.os.Handler.dispatchMessage(Handler.java:99)
08-13 13:02:48.236: W/System.err(9062): at android.os.Looper.loop(Looper.java:176)
08-13 13:02:48.236: W/System.err(9062): at android.app.ActivityThread.main(ActivityThread.java:5419).android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
我已经添加了manifest.xml
<!-- Here Maps Authenticate -->
<meta-data
android:name="com.here.android.maps.appid"
android:value="AppId" />
<meta-data
android:name="com.here.android.maps.apptoken"
android:value="Apptoken" />
<meta-data
android:name="com.here.android.maps.license.key"
android:value="LIC" />
但还是不行。请小伙伴指点一下。
如我所指https://developer.here.com/mobile-sdks/documentation/android/topics/app-extended.html
所以终于在 5 小时后工作了。
我刚刚将 HERE-sdk/libs
中的 armeabi-v7a
文件夹添加到我的 Eclipse
项目 libs
。
输出:
我想在我的应用程序中实现 HERE Maps。我刚刚开始实施一个示例应用程序,它只显示 HERE 地图 。
我的代码:
// map embedded in the map fragment
private Map map = null;
// map fragment embedded in this activity
private MapFragment mapFragment = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_here_maps);
// Search for the map fragment to finish setup by calling init().
mapFragment = (MapFragment) getFragmentManager().findFragmentById(
R.id.mapfragment);
/*com.here.android.mpa.common.MapSettings.setIsolatedDiskCacheRootPath(
"/sdcard/foo/myservice"
, "com.here.android.mpa.service.MapService");*/
mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(
OnEngineInitListener.Error error) {
if (error == OnEngineInitListener.Error.NONE) {
// retrieve a reference of the map from the map fragment
map = mapFragment.getMap();
// Set the map center to the Vancouver region (no animation)
map.setCenter(
new GeoCoordinate(49.196261, -123.004773, 0.0),
Map.Animation.NONE);
// Set the zoom level to the average between min and max
map.setZoomLevel((map.getMaxZoomLevel() + map
.getMinZoomLevel()) / 2);
} else {
System.out.println("ERROR: Cannot initialize Map Fragment");
}
}
});
}
但不幸的是它不起作用。
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- Map Fragment embedded with the map object -->
<fragment
android:id="@+id/mapfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.here.android.mpa.mapping.MapFragment" />
</LinearLayout>
Logcat:
08-13 13:02:48.206: W/System.err(9062): org.xml.sax.SAXParseException: Unexpected end of document
08-13 13:02:48.226: W/System.err(9062): at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:125)
08-13 13:02:48.226: W/System.err(9062): at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:107)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.fh.a(XmlToDocParser.java:24)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.ResourceManager.a(ResourceManager.java:212)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.ResourceManager.a(ResourceManager.java:138)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.as.<init>(GLConfigHelper.java:38)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.y.a(BaseTextureView.java:61)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.y.<init>(BaseTextureView.java:54)
08-13 13:02:48.226: W/System.err(9062): at com.nokia.maps.bx.<init>(MapTextureView.java:36)
08-13 13:02:48.226: W/System.err(9062): at com.here.android.mpa.mapping.MapView.a(MapView.java:320)
08-13 13:02:48.231: W/System.err(9062): at com.here.android.mpa.mapping.MapView.<init>(MapView.java:169)
08-13 13:02:48.231: W/System.err(9062): at com.nokia.maps.bk.a(MapFragmentImpl.java:143)
08-13 13:02:48.231: W/System.err(9062): at com.here.android.mpa.mapping.MapFragment.onCreateView(MapFragment.java:147)
08-13 13:02:48.231: W/System.err(9062): at android.app.Fragment.performCreateView(Fragment.java:1699)
08-13 13:02:48.231: W/System.err(9062): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:879)
08-13 13:02:48.231: W/System.err(9062): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053)
08-13 13:02:48.231: W/System.err(9062): at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1155)
08-13 13:02:48.231: W/System.err(9062): at android.app.Activity.onCreateView(Activity.java:4966)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
08-13 13:02:48.231: W/System.err(9062): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
08-13 13:02:48.231: W/System.err(9062): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
08-13 13:02:48.231: W/System.err(9062): at android.app.Activity.setContentView(Activity.java:1956)
08-13 13:02:48.231: W/System.err(9062): at com.globetech.gticket.activity.zonar.HereMapsActivity.onCreate(HereMapsActivity.java:30)
08-13 13:02:48.231: W/System.err(9062): at android.app.Activity.performCreate(Activity.java:5372)
08-13 13:02:48.231: W/System.err(9062): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
08-13 13:02:48.231: W/System.err(9062): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
08-13 13:02:48.231: W/System.err(9062): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
08-13 13:02:48.231: W/System.err(9062): at android.app.ActivityThread.access0(ActivityThread.java:159)
08-13 13:02:48.231: W/System.err(9062): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
08-13 13:02:48.236: W/System.err(9062): at android.os.Handler.dispatchMessage(Handler.java:99)
08-13 13:02:48.236: W/System.err(9062): at android.os.Looper.loop(Looper.java:176)
08-13 13:02:48.236: W/System.err(9062): at android.app.ActivityThread.main(ActivityThread.java:5419).android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
我已经添加了manifest.xml
<!-- Here Maps Authenticate -->
<meta-data
android:name="com.here.android.maps.appid"
android:value="AppId" />
<meta-data
android:name="com.here.android.maps.apptoken"
android:value="Apptoken" />
<meta-data
android:name="com.here.android.maps.license.key"
android:value="LIC" />
但还是不行。请小伙伴指点一下。
如我所指https://developer.here.com/mobile-sdks/documentation/android/topics/app-extended.html
所以终于在 5 小时后工作了。
我刚刚将 HERE-sdk/libs
中的 armeabi-v7a
文件夹添加到我的 Eclipse
项目 libs
。