Topic: Marker not showing

I have three scripts:

Script 1, getmylocation() = gets my current location and creates a marker for where I am

OnlineMapsMarker fred = new OnlineMapsMarker();
fred.SetPosition(myLng, myLat);
fred.texture = meMarker;
OnlineMapsMarkerManager.AddItem(fred);
markerLng = myLng; //Statics
markerLat = myLat;


Script 2, CreateMarkerOnClick() = basically the default script supplied out of the box. It gets the position of the lat,lng and stores it in a global static, but doesnt create a marker, instead it opens a new panel.

Script3, SubmitReport() = If report submitted correctly, then marker is created using effectively the same code as in script1. Working as the marker is created and shown in the Online Maps Marker Manager Component, but doesnt show on the map.

If I try use the OnlineMapsMarkerManager.CreateItem(getMyLocation.markerLng, getMyLocation.markerLat, label), it comes up with an error:

OnlineMapsMarker.Init (System.Nullable`1[T] width, System.Nullable`1[T] height) (at Assets/Infinity Code/Online maps/Scripts/Markers/Instances/OnlineMapsMarker.cs:377)
OnlineMapsMarkerManager.Create (System.Double longitude, System.Double latitude, UnityEngine.Texture2D texture, System.String label) (at Assets/Infinity Code/Online maps/Scripts/Markers/Managers/OnlineMapsMarkerManager.cs:112)
OnlineMapsMarkerManager.CreateItem (System.Double longitude, System.Double latitude, System.String label) (at Assets/Infinity Code/Online maps/Scripts/Markers/Managers/OnlineMapsMarkerManager.cs:64)

Re: Marker not showing

Hello.

Your stack trace shows me that you have no map or control.
There can be two scenarios here:
1. The map has not been initialized yet. For example, you are trying to do this in Awake or OnEnable. You can use the map and its objects in Start or later.
2. The map has already been destroyed. For example, you have several maps, have already destroyed the second one, and are trying to use static methods. If you have multiple maps, you need to use component instances and non-static methods.

If the problem persists, please show the complete script so I can test it.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Marker not showing

I Have two problems

A) Using the manual marker creation with the code below works, but doesnt show on the map itself. Do I need to refresh it?? Shows in the marker manager

OnlineMapsMarker fred = new OnlineMapsMarker();
fred.SetPosition(myLng, myLat);
fred.texture = meMarker;
OnlineMapsMarkerManager.AddItem(fred);

B) Issue with using the OnlineMapsMarkerManager.CreateItem(getMyLocation.markerLng, getMyLocation.markerLat, label) is probably due to the fact it I am calling that FROM another panel which doesnt have the Map component attached. I tried referencing the single component instance but no success. Defiantly only a single map, and the instance still alive.

I am wondering why A) doesnt work or do I need to reinvoke a redraw of the map?

Thanks

Re: Marker not showing

So I didnt resolve it as such, but worked around it. The CreateMarkerOnClick() will create the marker irrespective where you have clicked and place it in to the MarkerManager array. When the next page panel opens, and form submission is successful, it will do nothing, but if it is not (or I click cancel), then it will remove the last created marker.

Re: Marker not showing

1. You also need to invoke OnlineMapsMarker.Init.
https://infinity-code.com/doxygen/onlin … 2775d7e243

2. When you have one map and use CreateItem, it doesn't matter where the map is (on this or some other GameObject).

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.