मेरे पास एंड्रॉइड के लिए एकीकृत Google एमएपी एपीआई वी 2 है। मैं माई मार्कर के ऑनक्लिक पर कस्टम इन्फो विंडो रखना चाहता हूं। उस पर यह ठीक है। मैंने इसे एकीकृत किया है।एंड्रॉइड Google मैप एपीआई वी 2: मार्कर के दाहिने तरफ ओपन कस्टम इन्फो विंडो
मुझे क्या चाहिए: मैं मार्कर के शीर्ष के बजाय मार्कर के दाहिने तरफ अपनी कस्टम जानकारी विंडो दिखाना चाहता हूं।
public class MainActivity extends FragmentActivity {
private MainMapFragement mapFragment;
private HashMap<Marker, EventInfo> eventMarkerMap;
Marker ThirdMarker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapFragment = new MainMapFragement();
// FragmentTransaction ft = getFragmentManager().beginTransaction();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.map, mapFragment);
ft.commit();
}
@Override
protected void onStart() {
super.onStart();
setUpEventSpots();
}
private void setUpEventSpots() {
// I'm going to make 2 EventInfo objects and place them on the map
EventInfo firstEventInfo = new EventInfo(new LatLng(50.154, 4.35),
"Right now - event", new Date(), "Party");
EventInfo secondEventInfo = new EventInfo(new LatLng(51.25, 4.15),
"Future Event", new Date(1032, 5, 25), "Convention");
EventInfo thirdEventInfo = new EventInfo(new LatLng(23.25, 72.15),
"Our Next Event", new Date(), "Ahmedabad-India");
// this date constructor is deprecated but it's just to make a simple
// example
Marker firstMarker = mapFragment.placeMarker(firstEventInfo);
Marker secondMarker = mapFragment.placeMarker(secondEventInfo);
ThirdMarker = mapFragment.placeMarker(thirdEventInfo);
eventMarkerMap = new HashMap<Marker, EventInfo>();
eventMarkerMap.put(firstMarker, firstEventInfo);
eventMarkerMap.put(secondMarker, secondEventInfo);
eventMarkerMap.put(ThirdMarker, thirdEventInfo);
// add the onClickInfoWindowListener
mapFragment.getMap().setOnInfoWindowClickListener(
new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
EventInfo eventInfo = eventMarkerMap.get(marker);
Toast.makeText(
getBaseContext(),
"The date of "
+ eventInfo.getName()
+ " is "
+ eventInfo.getSomeDate()
.toLocaleString(),
Toast.LENGTH_LONG).show();
}
});
// Custom Bhavesh
mapFragment.getMap().setInfoWindowAdapter(new InfoWindowAdapter() {
private final View window = getLayoutInflater().inflate(
R.layout.ballonoverlly, null);
@Override
public View getInfoWindow(Marker marker) {
EventInfo eventInfo = eventMarkerMap.get(marker);
String title = marker.getTitle();
TextView txtTitle = ((TextView) window
.findViewById(R.id.textview_name));
if (title != null) {
// Spannable string allows us to edit the formatting of the
// text.
SpannableString titleText = new SpannableString(title);
titleText.setSpan(new ForegroundColorSpan(Color.RED), 0,
titleText.length(), 0);
txtTitle.setText(titleText);
} else {
txtTitle.setText("");
}
// TextView txtType = ((TextView) window
// .findViewById(R.id.textview_aboutme));
// if (eventInfo.getType() != null)
// txtType.setText(eventInfo.getType());
return window;
}
@Override
public View getInfoContents(Marker marker) {
// this method is not called if getInfoWindow(Marker) does not
// return null
return null;
}
});
}
}
xml फ़ाइल:, अब
मैं चाहता हूँ:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RlMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/imageview_comment"
android:layout_width="150dp"
android:layout_height="62dp"
android:background="@drawable/map_comment_back"
android:gravity="center_vertical"
android:orientation="vertical"
android:scaleType="fitXY"
android:visibility="visible" >
<TextView
android:id="@+id/textview_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="Bhavesh Patadiya"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="@+id/textview_aboutme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:maxLines="2"
android:text="How's Going?"
android:textColor="#FFFFFF"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>
नीचे मैं क्या मिल रहा है की स्क्रीन शॉट है
नीचे कोड मैं का उपयोग कर रहा है मेरे कस्टम इन्फोविंडो को शीर्ष के बजाय मार्कर के दाहिने तरफ रखना है।
सभी सहायता की सराहना की जाती है।
अग्रिम में धन्यवाद।
इसके साथ प्रयास करें: आधा बाएं तरफ खाली और आधे दाएं किनारे के साथ एक छवि (पृष्ठभूमि) बनाना -> फिर अपने दाएं हिस्से में सामग्री (टेक्स्ट व्यू) जोड़ें। मुझे उम्मीद है कि यह मार्कर का अधिकार लेगा क्योंकि बाएं तरफ खाली दिखता है – Maddy