How do I placed multiple markers on react-native map? - ios

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
})

Related

How to hide google map markers swift

I want to hide the marker after the zoom level reach 17, someone suggested I use clear method, but the issue with it that I have different marker that will show after some event so clear is not going to work any idea how can I made this possible?
To remove a specific marker
myMarker.map = nil
as far as I know there are no definite references to hiding markers, but you can manipulate marker data displayed on the map #CMIIW
as an example
var markers: [GMSMarker] = []
var tempMarker: [GMSMarker] = []
if zoom == 17 {
// TODO: Create tempMarker filter from markers
} else {
// TODO: Create tempMarker filter from markers
}
// TODO:
// mapView.clear()
// Mapview show markers from tempMarker
iOS Swift Google Maps SDK showing markers at specific zoom level?
//To delete
marker.map = nil
//to hide
marker.opacity = 0.0

Marker not showing up on GMSPanoramaView

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.

cluster google map markers and zoom in on cluster

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>

Google Maps flashes 0,0 water before panning to marker/polyline of interest (using gmaps4rails)

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

Rails + Google maps, show multiple marker

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

Resources