0

I'm looking how to add specific markers to my gmap.

This is the code:

LatLng coord1 = new LatLng (y, x);
advancedModel.addOverlay(new Marker(coord1, "test", "orange.png", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));

I want to add my specific marker which is in /resources/images not this one http://maps.google.com/mapfiles/ms/micons/blue-dot.png

Can you help?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
MedBC
  • 11
  • 9
  • Did you read the fine manual (there is something about 'icons' on markers in there) – Kukeltje Apr 18 '16 at 16:51
  • @Kukeltje yeah i did but i didnt found how to add my own markers :/ – MedBC Apr 19 '16 at 08:45
  • Next time PLEASE, PLEASE, PLEASE post what you tried and what worked or not, saves me investigating things I never used myself in trying to ** help you**... Using icons IS the way to do it... What failed then? 404's in the network inspector? World war IV? – Kukeltje Apr 19 '16 at 13:56
  • im looking for a method to add my own markers (markers that i create them with photoshop ) i tried to add marker in database and call them in the function advancedModel.addOverlay(new Marker(coord1, "test", deserialize(img.get(0).getContents()))); but i got nothing in my map .... just im looking for another method with java not js – MedBC Apr 19 '16 at 14:04
  • Can you get it to work with an image stored in your webapp, not in the database? Try that first. If that works, the next step is to server an image from the database (which is a very generic problem if you just search for solutions like this https://www.google.com/search?q=stackoverflow+image+from+database+java – Kukeltje Apr 19 '16 at 14:43
  • @Kukeltje i dont need to retrieve the icon from my database i just tried it because the first solution of using an image from my webapp didnt work ... and i got this Exception handling request to /webpfe/javax.faces.resource/images/.jsf ... java.lang.NullPointerException – MedBC Apr 19 '16 at 14:50
  • @Kukeltje it's can be workable from my webapp ??? – MedBC Apr 19 '16 at 14:52
  • I would think so (never tried/needed it myself). And if you tried it in a normal way and got an NPE, why not post exactly that code (in [mcve] format) and the stacktrace and try to solve that? – Kukeltje Apr 19 '16 at 15:24
  • because i think that it cant be so easy like that – MedBC Apr 19 '16 at 15:29
  • Why not? Care to explain? Found the duplicate btw? http://stackoverflow.com/questions/27176166/how-change-icon-marker-gmap-primefaces (it was in the 'related' block on the right...!!!) – Kukeltje Apr 19 '16 at 15:52
  • @Kukeltje thank you for the link i used my local adress and its worked ^^ thank you again – MedBC Apr 20 '16 at 09:19

2 Answers2

0

You can add custom markers in Google Maps and you can also change the marker icon, depending on the type of feature the marker's being added to. Each point of interest in the list of campus features has a type attribute.

Below code is a sample code snippet how to add custom markers:

var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
var icons = {
    parking: {
        icon: iconBase + 'parking_lot_maps.png'
    },
    library: {
        icon: iconBase + 'library_maps.png'
    },
    info: {
        icon: iconBase + 'info-i_maps.png'
    }
};

function addMarker(feature) {
    var marker = new google.maps.Marker({
        position: feature.position,
        icon: icons[feature.type].icon,
        map: map
    });
}
Craicerjack
  • 6,203
  • 2
  • 31
  • 39
Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30
0

You can do something like this:

Marker newMarker = new Marker(new LatLng(latitude, longitude));
newMarker.setIcon("resources/media/marker-blue-dot.png");
simpleModel.addOverlay(newMarker);
jrbedard
  • 3,662
  • 5
  • 30
  • 34