hansemannn / titanium-googlemaps

🗺 Use the Google Maps SDK in Titanium
Other
87 stars 26 forks source link

Map Pin Colors #9

Closed ghost closed 8 years ago

ghost commented 8 years ago

Nice Module!

Is there a method to change the map pin colours?

Cheers

yozef commented 8 years ago

var marker = maps.createMarker({ icon: "pin.png", // <---- here you can use your own pin image });

ghost commented 8 years ago

Thanks yozef

I spotted that "icon" property at about the same time that you posted your reply!

Do you know if there is a programmatic way of activating a particular pin's annotation?

Cheers

yozef commented 8 years ago

Hi Burgons, what do you mean by activating? (adding it to the map?)

ghost commented 8 years ago

To show the info window (or annotation) associated with the map pin. So that I can highlight a particular one. I think it may be associated with this event: [INFO] : { [INFO] : bubbles = 1; [INFO] : cancelBubble = 0; [INFO] : marker = "[object TiGooglemapsMarker]"; [INFO] : source = "[object TiGooglemapsMapView]"; [INFO] : type = markerclick; [INFO] : }

ghost commented 8 years ago

OK, I've found that you can identify a single Pin if you give it a custom attribute "id: 1" upon creation, like this: var marker = Alloy.Globals.googleMap.createMarker({ latitude: location.latitude, longitude: location.longitude, title: location.title, snippet: location.city, id: 1, icon: "images/imagefiles_location_map_pin_pink6.png" });

I can then retrieve that info as follows:

mapView.addEventListener("markerclick", handlerMarkerClickEvent); function handlerMarkerClickEvent(e) { Ti.API.info("\"markerclick\" event fired!"); Ti.API.info("source: " +JSON.stringify(e.source)); }

and here's my console output, where I can see the "annotation.id = 1":

{ "horizontalWrap": true, "visible": true, "mapType": 3, "camera": { "zoom": 10, "longitude": -1.613172, "latitude": 54.980541 }, "annotation": { "id": 1 } }

yozef commented 8 years ago

After adding the annotation on the map, the user can tap the annotation to show the infoWindow (these can be set with these params of the createMarker, title : "Appcelerator, Inc" and snippet : "1732 N. 1st Street, San Jose". However I think you would like to programatically display the infoWindow?

ghost commented 8 years ago

Yes that would be my plan...

yozef commented 8 years ago

oh I see. Ok :)

yozef commented 8 years ago

I am not sure if selectedMarker was implemented, however this is the method you're looking for to programatically display the infoWindow.

ghost commented 8 years ago

I can't find a way to activate the selectedMarker.

Anyway, I think I spoke too soon. For some reason I can't now retrieve the pin ID. It's not appearing in the object any longer. Any ideas?

hansemannn commented 8 years ago

hey @burgons & @yozef, thanks for asking! I will update the module right now to support the following:

marker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]];

I will also expose the new property selectedMarker. Stay tuned!

hansemannn commented 8 years ago

New marker properties "image" for pin images and "pinColor" for pin tinting are now pushed. Please try the changes, I will release the version in the next weeks after I have some more time to test.

hansemannn commented 8 years ago

Closing this issue for now, please reopen if it does not work!

ghost commented 8 years ago

Thanks Hans

I'll give it a try and feed back.

Cheers

Sent from my iPhone

On 29 Feb 2016, at 22:05, Hans Knoechel notifications@github.com wrote:

New marker properties "image" for pin images and "pinColor" for pin tinting are now pushed. Please try the changes, I will release the version in the next weeks after I have some more time to test.

— Reply to this email directly or view it on GitHub.

ghost commented 8 years ago

Thanks Hans.

The previous update (to enable marker color) is working perfectly.

Much appreciated!

On 29 Feb 2016, at 20:56, Hans Knoechel notifications@github.com wrote:

hey @burgons https://github.com/burgons & @yozef https://github.com/yozef, thanks for asking! I will update the module right now to support the following:

marker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]]; I will also expose the new property selectedMarker. Stay tuned!

— Reply to this email directly or view it on GitHub https://github.com/hansemannn/Ti.GoogleMaps/issues/9#issuecomment-190385294.