GoogleMap addMarker - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for GoogleMap addMarker method.

This code example shows how to use the following methods:addMarker, animateCamera, setOnMarkerClickListener, setOnMarkerDragListener
/* 
 * Copyright (C) 2012 The Android Open Source Project 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */ 
 
package com.example.mapdemo; 
 
import com.google.android.gms.maps.CameraUpdateFactory; 
import com.google.android.gms.maps.GoogleMap; 

6
CodeRank
This code example shows how to use the following methods:addMarker
              R.string.downtown_club, R.string.heisman_trophy); 
  } 
 
  private void addMarker(GoogleMap map, double lat, double lon,
                         int title, int snippet) {
    map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
                                     .title(getString(title))
                                     .snippet(getString(snippet)));
  } 
} 
7
CodeRank
This code example shows how to use the following methods:addCircle, addMarker, clear, getCameraPosition, setLocationSource
	public MapHelperClass(GoogleMap map, int distanceWhenWPReached) {
 
		this.map = map;
		this.distanceWhenWPReached = distanceWhenWPReached;
 
		map.setLocationSource(this);
		map.setMyLocationEnabled(true);
		map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
 
		CleanMap(); 
	} 
 
	public void RedrawLines() { 
		if (WPPathPolyLine != null) {
			WPPathPolyLine.remove();
			WPPathPolyLine = null;
		} 
		PolylineOptions polylineOptions = new PolylineOptions().color(Color.CYAN).width(4);
		for (Marker m : markers) {
			polylineOptions.add(m.getPosition());

7
CodeRank
This code example shows how to use the following methods:addMarker
    bar.setListNavigationCallbacks(nav, this);
  } 
 
  private void addMarker(GoogleMap map, double lat, double lon,
                         int title, int snippet) {
    map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
                                     .title(getString(title))
                                     .snippet(getString(snippet)));
  } 
} 
7
CodeRank
This code example shows how to use the following methods:addMarker, getUiSettings, moveCamera, setMapType, setMyLocationEnabled
        super.onResume(); 
        setUpMapIfNeeded(); 
    } 
 
    private void setUpMap() { 
        mMap.addMarker(new MarkerOptions().position(new LatLng(37.233181, -76.646596)).title("Austria"));
        mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
        mMap.setMyLocationEnabled(false);
        mMap.getUiSettings().setZoomControlsEnabled(false);
        mMap.moveCamera(CameraUpdateFactory.newCameraPosition(HOME));
    } 
 
    private void setUpMapIfNeeded() { 
        // Do a null check to confirm that we have not already instantiated the map. 
        if (mMap == null) {
            // Try to obtain the map from the SupportMapFragment. 
            mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                    .getMap();
            // Check if we were successful in obtaining the map. 
            if (mMap != null) {
6
CodeRank
This code example shows how to use the following methods:addMarker
    bar.setListNavigationCallbacks(nav, this);
  } 
 
  private void addMarker(GoogleMap map, double lat, double lon,
                         int title, int snippet) {
    map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
                                     .title(getString(title))
                                     .snippet(getString(snippet)));
  } 
} 
7
CodeRank
This code example shows how to use the following methods:addMarker, getUiSettings, moveCamera, setMapType, setMyLocationEnabled
        super.onResume(); 
        setUpMapIfNeeded(); 
    } 
 
    private void setUpMap() { 
        mMap.addMarker(new MarkerOptions().position(new LatLng(37.233305,-76.648709)).title("Canada"));
        mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
        mMap.setMyLocationEnabled(false);
        mMap.getUiSettings().setZoomControlsEnabled(false);
        mMap.moveCamera(CameraUpdateFactory.newCameraPosition(HOME));
    } 
 
    private void setUpMapIfNeeded() { 
        // Do a null check to confirm that we have not already instantiated the map. 
        if (mMap == null) {
            // Try to obtain the map from the SupportMapFragment. 
            mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                    .getMap();
            // Check if we were successful in obtaining the map. 
            if (mMap != null) {
6
CodeRank
This code example shows how to use the following methods:addMarker
    bar.setListNavigationCallbacks(nav, this);
  } 
 
  private void addMarker(GoogleMap map, double lat, double lon,
                         int title, int snippet, int hue) {
    map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
                                     .title(getString(title))
                                     .snippet(getString(snippet))
                                     .icon(BitmapDescriptorFactory.defaultMarker(hue)));
  } 
} 
6
CodeRank
This code example shows how to use the following methods:addMarker, animateCamera, getUiSettings, moveCamera, setMapType
         
        LatLng CENTRO = new LatLng(lati1, lngi1);
         
         
		 
		nMapa.addMarker(new MarkerOptions()
				.position(new LatLng(lati1, lngi1))
				.title(name)
				.snippet("pensamos en el futuro"));
		nMapa.setMapType(GoogleMap.MAP_TYPE_NORMAL);
		nMapa.moveCamera(CameraUpdateFactory.newLatLngZoom(CENTRO, 15));
		nMapa.animateCamera(CameraUpdateFactory.zoomIn());
		nMapa.setMyLocationEnabled(true);
		nMapa.getUiSettings().setCompassEnabled(true);
	} 
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present. 
		getMenuInflater().inflate(R.menu.activity_main, menu);
		 
6
CodeRank
This code example shows how to use the following methods:addCircle, addMarker, addPolygon, addPolyline, getUiSettings
				map:cameraZoom="14" 
		 *  
		 * They've been removed from the xml.  Now, the same functionality done with code: 
		 */ 
		 
		UiSettings settings = mMap.getUiSettings();
		 
		settings.setZoomControlsEnabled(true);
		settings.setCompassEnabled(true);
		settings.setTiltGesturesEnabled(false);
		 
		settings.setMyLocationButtonEnabled(true);
		 
		CameraUpdate camUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(45.53, -73.59), 14);
		mMap.moveCamera(camUpdate);
		 
		 
		 
		/** 
		 * "Markers" lesson 

6
CodeRank

Related GoogleMap addMarker Questions & Answers:

Other GoogleMap addMarker Examples

23:	    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
24:	        .getMap();
25:	    Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
26:	        .title("Hamburg"));
27:	    Marker kiel = map.addMarker(new MarkerOptions()
-
25:	    Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
26:	        .title("Hamburg"));
27:	    Marker kiel = map.addMarker(new MarkerOptions()
28:	        .position(KIEL)
29:	        .title("Kiel")

Read More

addMarker Method Overview
Adds a marker to this map.
See Code Examples for other Android GoogleMap Methods: