I have a drop dead simple test app in which i execute the following code
let marker = GMSMarker(position:CLLocationCoordinate2DMake(33.987884, -118.474434))
marker.icon = GMSMarker.markerImageWithColor(UIColor.redColor())
marker.panoramaView = panoramaView;
marker.snippet = "I am Here!"
panoramaView.moveNearCoordinate(marker.position)
If i move the coordinate to some other street off the beach i can see the marker just fine. But from the code above I don't see anything. Does anybody know why I can get an area to show up fine in a GMSPanoramaView however placing a marker there does not work?
I think some implementation was not done. Not sure what are those implementation but I found some tutorials regarding your issue. Or according to the document "Note that if the marker's position is too far away from the panoramaView's current panorama location, it will not be displayed as it will be too small".
Checking the Street View locations and point-of-view (POV):
GMSPanoramaView *panoView_;
panoView_.camera = [GMSPanoramaCamera cameraWithHeading:180
pitch:-10
zoom:1];
Markers within Street View
// Create a marker at the Eiffel Tower
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(48.858,2.294);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
// Add the marker to a GMSPanoramaView object named panoView_
marker.panoramaView = panoView_;
// Add the marker to a GMSMapView object named mapView_
marker.map = mapView_;
That's the first option, another option is Google Maps JavaScript API inside a WebView. https://developers.google.com/maps/documentation/javascript/examples/streetview-overlays
var panorama;
function initMap() {
var astorPlace = {lat: 40.729884, lng: -73.990988};
// Set up the map
var map = new google.maps.Map(document.getElementById('map'), {
center: astorPlace,
zoom: 18,
streetViewControl: false
});
// Set up the markers on the map
var cafeMarker = new google.maps.Marker({
position: {lat: 40.730031, lng: -73.991428},
map: map,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
var bankMarker = new google.maps.Marker({
position: {lat: 40.729681, lng: -73.991138},
map: map,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=dollar|FFFF00',
title: 'Bank'
});
var busMarker = new google.maps.Marker({
position: {lat: 40.729559, lng: -73.990741},
map: map,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=bus|FFFF00',
title: 'Bus Stop'
});
// We get the map's default panorama and set up some defaults.
// Note that we don't yet set it visible.
panorama = map.getStreetView();
panorama.setPosition(astorPlace);
panorama.setPov(/** #type {google.maps.StreetViewPov} */({
heading: 265,
pitch: 0
}));
}
function toggleStreetView() {
var toggle = panorama.getVisible();
if (toggle == false) {
panorama.setVisible(true);
} else {
panorama.setVisible(false);
}
}
Here are links for tutorials and repo of the codes
http://googlegeodevelopers.blogspot.com/2013/09/sun-surveyor-shines-with-street-view.html
https://github.com/ratana/streetview-panorama-demo
I hope this helps.
Related
Hi just learn to use react-native and javascript. How do I placed multiple markers on react-native map?
Just push more data into the marker and setstate to marker and assign to
annotations={this.state.marker}
var tempMarker = [];
for (var p in responseData) {
tempMarker.push({
latitude: region.latitude,
longitude: region.longitude
})
}
this.setState({
marker: tempMarker
})
When a user is zoomed out on the gmsmapview the markers get very close together( there is only a max of like 100 markers). Is there a way to zoom in on markers that are extremely close when a user clicks on them? Rather than just clicking on each individual marker?
Why not using markers clusters..this tecnique show a markers cluster with the numer of cluster in the area and clicking the zoom to marker
I think you need somethings like this: Show also the sample and here the complete source
<script type="text/javascript">
function initialize() {
var center = new google.maps.LatLng(37.4419, -122.1419);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var markers = [];
for (var i = 0; i < 100; i++) {
var dataPhoto = data.photos[i];
var latLng = new google.maps.LatLng(dataPhoto.latitude,
dataPhoto.longitude);
var marker = new google.maps.Marker({
position: latLng
});
markers.push(marker);
}
var markerCluster = new MarkerClusterer(map, markers);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
I have a code like below but "CLLocation loc = mapView.MyLocation;" assigne null to loc object, so i cannot take cuurent location.
How can get my current location in xamarin for ios with google map sdk for ios.
//and many other using
using Google.Maps;
public partial class MapNavigationController : UIViewController
{
MapView mapView;
public override void LoadView ()
{
base.LoadView ();
var camera = CameraPosition.FromCamera (latitude: 7.2935273,
longitude: 80.6387523,
zoom: 13);
mapView = MapView.FromCamera (RectangleF.Empty, camera);
mapView.MyLocationEnabled = true;
mapView.MapType = MapViewType.Hybrid;
CLLocation loc = mapView.MyLocation;
Console.WriteLine("tapped at " + loc.Coordinate.Latitude + "," +loc.Coordinate.Longitude);
}
}
I am not very familiar with Google Maps in iOS.
But I don't think its possible to get you current location from the MapView.
You can maybe show it (by enabling an option (showOwnLocation or something similar)).
If you want to do it the right way you have to do it with the CLLocationManager from the iOS SDK. I don't have a sample available right now but if you google it you will find some.
Hopefully this helps you.
You need to get that info from CCLocationManager, like so:
CameraPosition camera = CameraPosition.FromCamera(latitude: App.MyLatitude,
longitude: App.MyLongitude,
zoom:50);
mapView = MapView.FromCamera(CGRect.Empty, camera);
mapView.Settings.ScrollGestures = true;
mapView.Settings.ZoomGestures = true;
mapView.MyLocationEnabled = true;
mapView.MapType = MapViewType.Satellite;
CLLocation loc = iPhoneLocationManager.Location;
// My position
var Marker = new Marker()
{
Title = App.PinTitle,
Snippet = App.PinLabel,
Position = new CLLocationCoordinate2D(latitude: loc.Coordinate.Latitude, longitude: loc.Coordinate.Longitude),
Map = mapView
};
I'm using gmaps4rails to display a single marker, but I can't get it to not show a flash of lat/lon 0,0 water before panning over to the marker.
My (coffeescript) code is very simple:
handler = Gmaps.build('Google')
handler.buildMap { provider: {}, internal: { id: 'my-map-id' } }, ->
marker = handler.addMarker
lat: 41.0
lng: -96.0
marker.panTo()
handler.getMap().setZoom(14)
The map displays blue water then quickly jumps over to the desired location. I've tried using the bounds-oriented methods instead of the marker.panTo(), with the same results:
handler.bounds.extendWith(marker)
handler.fitMapToBounds()
handler.getMap().setZoom(14)
It seems like I need to either prevent display of the map until the marker and location is set, or I need to add the markers in earlier. Neither of which I've figured out how to do.
Thanks to the quick tip from #apneadiving, this took care of it:
lat = 41.0
lng = -96.0
options =
center: new google.maps.LatLng(lat, lng)
zoom: 14
handler = Gmaps.build('Google')
handler.buildMap { provider: options, internal: { id: 'contact-map' } }, ->
marker = handler.addMarker
lat: lat
lng: lng
I need to show the position of an user inside my Rails application, I used the following code and it works well:
function showLocations(){
<% if #profile.location.latitude.nil? || #profile.location.longitude.nil? %>
canvas = $('#map_canvas');
canvas.html("<h1>The user have not specified his location yet</h1>")
canvas.slideDown();
<%else%>
var latlng = new google.maps.LatLng(<%=#profile.location.latitude%>, <%=#profile.location.longitude%>);
var myOptions = {
zoom: 12,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var canvas = document.getElementById("map_canvas")
var map = new google.maps.Map(canvas,
myOptions);
var marker = new google.maps.Marker({
position: latlng,
title:"<%=#profile.full_name%>"
});
marker.setMap(map);
<%end%>
$('#map_canvas').slideDown('slow');
}
Now, I want to take an Array of users and show mutiple marker on the map, so suppose that I no longer have #profile but #profile_array, and each of them have to be represented by a marker on the map. How do you think could I change the code above in order to achieve what I want ?
Tnx