Javascript, Change google map marker color

In Google Maps API v3 you can try changing marker icon. For example for green icon use: marker.setIcon(‘http://maps.google.com/mapfiles/ms/icons/green-dot.png’) Or as part of marker init: marker = new google.maps.Marker({ icon: ‘http://…’ }); Other colors: http://maps.google.com/mapfiles/ms/icons/blue-dot.png http://maps.google.com/mapfiles/ms/icons/red-dot.png Etc.

Draw path between two points using Google Maps Android API v2

First of all we will get source and destination points between which we have to draw route. Then we will pass these attribute to below function. public String makeURL (double sourcelat, double sourcelog, double destlat, double destlog ){ StringBuilder urlString = new StringBuilder(); urlString.append(“http://maps.googleapis.com/maps/api/directions/json”); urlString.append(“?origin=”);// from urlString.append(Double.toString(sourcelat)); urlString.append(“,”); urlString.append(Double.toString( sourcelog)); urlString.append(“&destination=”);// to urlString.append(Double.toString( destlat)); urlString.append(“,”); … Read more

Using setZoom() after using fitBounds() with Google Maps API V3

Alright, I’ve figured it out. Apparently, the fitbounds() happens asynchronously, so you have to wait for a bounds_changed event before setting zoom works. map = this.map.map; map.fitBounds(this.map.bounds); zoomChangeBoundsListener = google.maps.event.addListenerOnce(map, ‘bounds_changed’, function(event) { if (this.getZoom()){ this.setZoom(16); } }); setTimeout(function(){google.maps.event.removeListener(zoomChangeBoundsListener)}, 2000); Update: See @Nequin’s answer using addListenerOnce for a better solution that doesn’t require a timeout.

Getting Lat/Lng from Google marker

Here is the JSFiddle Demo. In Google Maps API V3 it’s pretty simple to track the lat and lng of a draggable marker. Let’s start with the following HTML and CSS as our base. <div id=’map_canvas’></div> <div id=”current”>Nothing yet…</div> #map_canvas{ width: 400px; height: 300px; } #current{ padding-top: 25px; } Here is our initial JavaScript initializing … Read more

Custom marker in google maps in android with vector asset icon

You can use this method: private BitmapDescriptor bitmapDescriptorFromVector(Context context, int vectorResId) { Drawable vectorDrawable = ContextCompat.getDrawable(context, vectorResId); vectorDrawable.setBounds(0, 0, vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight()); Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); vectorDrawable.draw(canvas); return BitmapDescriptorFactory.fromBitmap(bitmap); } So your code will look like: map.addMarker(new MarkerOptions() .position(latLng) .icon(bitmapDescriptorFromVector(getActivity(), R.drawable.your_vector_asset)) .title(title); Edit: In Kotlin it may look like: … Read more

Use a URL to link to a Google map with a marker on it

In May 2017 Google launched the official Google Maps URLs documentation. The Google Maps URLs introduces universal cross-platform syntax that you can use in your applications. Have a look at the following document: https://developers.google.com/maps/documentation/urls/guide You can use URLs in search, directions, map and street view modes. For example, to show the marker at specified position … Read more

Resize Google Maps marker icon image

If the original size is 100 x 100 and you want to scale it to 50 x 50, use scaledSize instead of Size. const icon = { url: “../res/sit_marron.png”, // url scaledSize: new google.maps.Size(50, 50), // scaled size origin: new google.maps.Point(0,0), // origin anchor: new google.maps.Point(0, 0) // anchor }; const marker = new google.maps.Marker({ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)