标签: google-maps-api-2

从谷歌地图API的v2升级到v3,建议

我在我的网络应用程序中完全成熟了谷歌地图版本2,具有获取路线,群集标记,选项卡式信息窗口,上下文菜单(右键单击)等功能.实现设计非常差,导致一些问题,所以现在我需要改进核心实现以更好地设计.我正在考虑升级到谷歌地图API的第3版.请建议,如果这是一件好事,我的所有功能都将运行良好(或者我会在更短的时间内完成所有功能的更换).或者我应该坚持谷歌地图API的版本2?

javascript google-maps google-api google-maps-api-3 google-maps-api-2

3
推荐指数
1
解决办法
4597
查看次数

Android支持库v4和Google Maps API中断了编译

我正在尝试在针对v10 API的Android项目中使用Google Maps API v2.阅读开发指南据说,由于片段仅在android api 11中引入,我需要使用Android支持库来使用API​​.

所以我做了以下工作:
- 将android支持库v4 jar
包含到我的项目中 - 包含"google-play-services-lib"库项目并引用它 -
写下以下代码,取自dev开发指南:

package com.darco.darcoapp;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;

public class CardJourneyActivity extends FragmentActivity{
    private GoogleMap myGoogleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_card_journey);

        FragmentManager fm = getSupportFragmentManager();
        Fragment fr = fm.findFragmentById(R.id.mapFragmentCardJourney);
        MapFragment mf = (MapFragment)fr; //this line causes the compilation error

    }
Run Code Online (Sandbox Code Playgroud)

正如评论所指出的那样,问题出现在最后一行代码上.当我添加Eclipse中出现以下错误时(不在该行上,而是在文件的顶部):

The type android.app.Fragment cannot be resolved. It is indirectly referenced from required .class files
Run Code Online (Sandbox Code Playgroud)

和Eclipse拒绝编译项目.

我已经尝试了在项目设置中我能想到的所有可能的配置,但也许有些东西让我不知道......我做错了什么?我在网上发现了一些有类似问题但没有解决方案,或者至少没有他们提出的解决方案.

eclipse android google-maps-api-2 android-support-library

3
推荐指数
1
解决办法
4985
查看次数

java.lang.ClassCastException:android.support.v4.app.NoSaveStateFrameLayout无法强制转换为com.google.android.maps.MapView

这是我的活动代码

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);
    GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
    mapView = (MapView) findViewById(R.id.map);

GoogleMap map = ((SupportMapFragment)  getSupportFragmentManager().findFragmentById(R.id.map))
        .getMap();
}

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.id.map, container, false);
}
Run Code Online (Sandbox Code Playgroud)

这是我的LogCat

03-22 11:53:38.497: E/AndroidRuntime(436): FATAL EXCEPTION: main
03-22 11:53:38.497: E/AndroidRuntime(436): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.alltaskass/com.example.alltaskass.Map}: java.lang.ClassCastException: android.support.v4.app.NoSaveStateFrameLayout cannot be cast to com.google.android.maps.MapView
03-22 11:53:38.497: E/AndroidRuntime(436):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
03-22 11:53:38.497: E/AndroidRuntime(436):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
03-22 11:53:38.497: E/AndroidRuntime(436):  at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-22 11:53:38.497: E/AndroidRuntime(436):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
03-22 11:53:38.497: E/AndroidRuntime(436): …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-maps-api-2 google-maps-android-api-2

3
推荐指数
1
解决办法
4854
查看次数

通过将当前位置作为圆心,在Google地图v2上绘制五个透明圆圈

我需要在Google Maps v2上绘制五个圆圈,将当前位置作为圆心.意味着五个圆中的每一个具有相同的中心但具有不同的半径:第一个圆的半径为10米,第二个圆半径为20米,第三个圆半径为30米,第四个圆半径为40米,第五个圆半径为50米.我正在使用Google Maps v2.

我还需要在圆圈的中心显示一个标记.

我正在尝试这样的东西在谷歌地图v2上绘制圆圈,但它只绘制一个圆而不是五个圆环

CircleOptions circleOptions = new CircleOptions()
                  .center(latLng)   //set center
                  .radius(500)   //set radius in meters
                  .fillColor(Color.TRANSPARENT)  //default
                  .strokeColor(0x10000000)
                  .strokeWidth(5);

                  myCircle = googleMap.addCircle(circleOptions);
Run Code Online (Sandbox Code Playgroud)

我需要像这样绘制圆周 -

在此输入图像描述

任何人都可以帮我吗?我在Google Map v2中创建此圈子时遇到问题.任何帮助将不胜感激.

java android google-maps-api-2

3
推荐指数
1
解决办法
4498
查看次数

如何在Android中的谷歌地图中关注标记

我只是想知道我们是否可以专注于Android应用程序中添加的标记.如果有,怎么样?或者有没有其他方法来完成这项任务.

假设我使用下面的代码添加了一个标记:

map.addMarker(new MarkerOptions()
            .title(title)
            .snippet(snippet)
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE))
            .position(pos)
                );
Run Code Online (Sandbox Code Playgroud)

如何使用最大变焦对焦此标记.如果我要再添加一个标记,它应该以这样的方式调整缩放(最大可能的缩放),以便两个标记一次显示.
这就是我想要做的事情,但它是失败的map.moveCamera(cu);.

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.CancelableCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

public class LocateUserInMap extends FragmentActivity {
    private GoogleMap map;
    private List<Marker> markers;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_locate_user_in_map);

        markers = new ArrayList<Marker>();
        Intent intent = getIntent();
        double frndLatVal = intent.getDoubleExtra("frndLatVal", 0);
        double frndLonVal …
Run Code Online (Sandbox Code Playgroud)

android google-maps-markers google-maps-api-2

3
推荐指数
1
解决办法
1万
查看次数

除非您更新Google Play服务,否则此应用无法运行

我一直在努力让Android V2的谷歌地图工作.我在设备上尝试这个:三星Galaxy S [2.3.3]和仿真器.

我的清单:(我尝试过使用Debug键和Release键)

        <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.klottr"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="18" />

    <permission 
        android:name="com.example.klottr.permission.MAPS_RECEIVE" 
        android:protectionLevel="signature"></permission>
    <uses-permission 
        android:name="com.example.klottr.permission.MAPS_RECEIVE"/>
    <uses-permission 
        android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission 
        android:name="android.permission.INTERNET"/>
    <uses-permission 
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission 
        android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission 
        android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyDqmCXjO-h-Yy_qGsyVrUz_icB9mCTUzLM"/>
        <activity
            android:name="com.example.klottr.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

主要活动xml:

        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
          tools:context=".MainActivity" >

         <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />
    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"/> …
Run Code Online (Sandbox Code Playgroud)

java eclipse android google-maps google-maps-api-2

3
推荐指数
1
解决办法
5885
查看次数

通过将标记保持在中心来移动地图

每当我移动地图时,Marker也随之移动但是我想通过将地图中心的标记保持为常数来移动地图.

我怎么能做到这一点?

android google-maps-markers google-maps-api-2

3
推荐指数
1
解决办法
3943
查看次数

在Google地图Android上显示一个按钮

嗨,我想在谷歌地图上显示一个按钮,有人可以告诉我如何实现这一点,因为我尝试了不同的位置,我的按钮显示在地图后面.

到目前为止这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/BlanchedAlmond" >

<Button
    android:id="@+id/startActivityButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal|center_vertical"   
    android:onClick="startActivity"
    android:text="@string/start_activity" 
    android:layout_alignParentBottom="true"  />

   <fragment        
    android:id="@+id/map"      
    android:name="com.google.android.gms.maps.MapFragment"        
    android:layout_width="wrap_content"        
    android:layout_height="wrap_content"
    android:layout_above="@id/startActivityButton"    
    /> 

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android google-maps-api-2 android-button

3
推荐指数
1
解决办法
1万
查看次数

如何使用Universal ImageLoader加载图像而不显示

我正在尝试做类似这样的事情: Android Map api v2自定义标记与ImageView 但我坚持使用图像加载器.

试:

Bitmap bmImg = imageLoader.loadImageSync(url);
Run Code Online (Sandbox Code Playgroud)

LogCat给了我

 04-13 14:11:44.953: E/ImageLoader(18542): android.os.NetworkOnMainThreadException
Run Code Online (Sandbox Code Playgroud)

这是我的代码.我有一个ArrayList相机,需要所有信息(titrle,position,url等).

public void drawPicsOnMap()
{                       
    String title = null;
    String place = null;        
    for (int i = 0; i<camera.size(); i++)
    {
        Bitmap.Config conf = Bitmap.Config.ARGB_8888;
        Bitmap bmp = Bitmap.createBitmap(80, 80, conf);
        Canvas canvas = new Canvas(bmp);

        // paint defines the text color,
        // stroke width, size
        Paint color = new Paint();
        color.setTextSize(35);
        color.setColor(Color.BLACK);

        Camera cam = camera.get(i);
        LatLng coord = new LatLng(cam.lat, cam.lon);

        title …
Run Code Online (Sandbox Code Playgroud)

java android google-maps-api-2 universal-image-loader

3
推荐指数
1
解决办法
9636
查看次数

谷歌地图动画或突出显示绑定中的特定标记

我有一个边界的多个标记.我想在onclickhtml 的事件中设置动画或突出显示特定标记.

地图代码:

var map = new google.maps.Map(document.getElementById('map-canvas'), {
  mapTypeId: google.maps.MapTypeId.ROADMAP
});
list = [
    [51.503454,-0.119562],
    [51.499633,-0.124755]
];
var bounds = new google.maps.LatLngBounds();
list.forEach(function(data, index, array){

  var marker = new google.maps.Marker({
   position: new google.maps.LatLng(list[index][0],list[index][1]),
   map: map
  });

bounds.extend(marker.position);
});
map.fitBounds(bounds);
Run Code Online (Sandbox Code Playgroud)

我想从html中为地图中的特定标记设置动画onclick.

<button onclick="showme(0)">London Eye</button>
<button onclick="showme(1)">Palace of Westminster</button>
Run Code Online (Sandbox Code Playgroud)

JS:

showme = function(index){
   //How to animate a particular marker by an index?
}
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3 google-maps-markers google-maps-api-2

3
推荐指数
1
解决办法
1万
查看次数